// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// This file is automatically generated. Do not edit.
//
// Source: https://github.com/NuxiNL/cloudabi

#define ENTRY(name)      \
  .text;                 \
  .p2align 2;            \
  .global name;          \
  .type name, %function; \
name:

#define END(name) .size name, . - name

ENTRY(cloudabi_sys_clock_res_get)
  str r0, [sp, #-16]
  str r1, [sp, #-20]
  mov r0, #0
  sub r2, sp, #16
  swi 0
  ldrcc r1, [sp, #-20]
  ldrcc r2, [sp, #-16]
  strcc r2, [r1, #0]
  ldrcc r2, [sp, #-12]
  strcc r2, [r1, #4]
  bx lr
END(cloudabi_sys_clock_res_get)

ENTRY(cloudabi_sys_clock_time_get)
  str r0, [sp, #-16]
  str r2, [sp, #-8]
  str r3, [sp, #-4]
  mov r0, #1
  sub r2, sp, #16
  swi 0
  ldrcc r1, [sp, #0]
  ldrcc r2, [sp, #-16]
  strcc r2, [r1, #0]
  ldrcc r2, [sp, #-12]
  strcc r2, [r1, #4]
  bx lr
END(cloudabi_sys_clock_time_get)

ENTRY(cloudabi_sys_condvar_signal)
  str r0, [sp, #-24]
  mov r0, #0
  str r0, [sp, #-20]
  str r1, [sp, #-16]
  str r2, [sp, #-8]
  mov r0, #2
  sub r2, sp, #24
  swi 0
  bx lr
END(cloudabi_sys_condvar_signal)

ENTRY(cloudabi_sys_fd_close)
  str r0, [sp, #-16]
  mov r0, #3
  sub r2, sp, #16
  swi 0
  bx lr
END(cloudabi_sys_fd_close)

ENTRY(cloudabi_sys_fd_create1)
  str r0, [sp, #-16]
  str r1, [sp, #-20]
  mov r0, #4
  sub r2, sp, #16
  swi 0
  ldrcc r1, [sp, #-20]
  ldrcc r2, [sp, #-16]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_fd_create1)

ENTRY(cloudabi_sys_fd_create2)
  str r0, [sp, #-16]
  str r1, [sp, #-20]
  str r2, [sp, #-24]
  mov r0, #5
  sub r2, sp, #16
  swi 0
  ldrcc r1, [sp, #-20]
  ldrcc r2, [sp, #-16]
  strcc r2, [r1, #0]
  ldrcc r1, [sp, #-24]
  ldrcc r2, [sp, #-8]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_fd_create2)

ENTRY(cloudabi_sys_fd_datasync)
  str r0, [sp, #-16]
  mov r0, #6
  sub r2, sp, #16
  swi 0
  bx lr
END(cloudabi_sys_fd_datasync)

ENTRY(cloudabi_sys_fd_dup)
  str r0, [sp, #-16]
  str r1, [sp, #-20]
  mov r0, #7
  sub r2, sp, #16
  swi 0
  ldrcc r1, [sp, #-20]
  ldrcc r2, [sp, #-16]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_fd_dup)

ENTRY(cloudabi_sys_fd_pread)
  str r0, [sp, #-32]
  str r1, [sp, #-24]
  mov r0, #0
  str r0, [sp, #-20]
  str r2, [sp, #-16]
  str r0, [sp, #-12]
  ldr r1, [sp, #0]
  str r1, [sp, #-8]
  ldr r1, [sp, #4]
  str r1, [sp, #-4]
  mov r0, #8
  sub r2, sp, #32
  swi 0
  ldrcc r1, [sp, #8]
  ldrcc r2, [sp, #-32]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_fd_pread)

ENTRY(cloudabi_sys_fd_pwrite)
  str r0, [sp, #-32]
  str r1, [sp, #-24]
  mov r0, #0
  str r0, [sp, #-20]
  str r2, [sp, #-16]
  str r0, [sp, #-12]
  ldr r1, [sp, #0]
  str r1, [sp, #-8]
  ldr r1, [sp, #4]
  str r1, [sp, #-4]
  mov r0, #9
  sub r2, sp, #32
  swi 0
  ldrcc r1, [sp, #8]
  ldrcc r2, [sp, #-32]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_fd_pwrite)

ENTRY(cloudabi_sys_fd_read)
  str r0, [sp, #-24]
  str r1, [sp, #-16]
  mov r0, #0
  str r0, [sp, #-12]
  str r2, [sp, #-8]
  str r0, [sp, #-4]
  str r3, [sp, #-28]
  mov r0, #10
  sub r2, sp, #24
  swi 0
  ldrcc r1, [sp, #-28]
  ldrcc r2, [sp, #-24]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_fd_read)

ENTRY(cloudabi_sys_fd_replace)
  str r0, [sp, #-16]
  str r1, [sp, #-8]
  mov r0, #11
  sub r2, sp, #16
  swi 0
  bx lr
END(cloudabi_sys_fd_replace)

ENTRY(cloudabi_sys_fd_seek)
  str r0, [sp, #-24]
  str r2, [sp, #-16]
  str r3, [sp, #-12]
  ldr r1, [sp, #0]
  str r1, [sp, #-8]
  mov r0, #12
  sub r2, sp, #24
  swi 0
  ldrcc r1, [sp, #4]
  ldrcc r2, [sp, #-24]
  strcc r2, [r1, #0]
  ldrcc r2, [sp, #-20]
  strcc r2, [r1, #4]
  bx lr
END(cloudabi_sys_fd_seek)

ENTRY(cloudabi_sys_fd_stat_get)
  str r0, [sp, #-16]
  str r1, [sp, #-8]
  mov r0, #0
  str r0, [sp, #-4]
  mov r0, #13
  sub r2, sp, #16
  swi 0
  bx lr
END(cloudabi_sys_fd_stat_get)

ENTRY(cloudabi_sys_fd_stat_put)
  str r0, [sp, #-24]
  str r1, [sp, #-16]
  mov r0, #0
  str r0, [sp, #-12]
  str r2, [sp, #-8]
  mov r0, #14
  sub r2, sp, #24
  swi 0
  bx lr
END(cloudabi_sys_fd_stat_put)

ENTRY(cloudabi_sys_fd_sync)
  str r0, [sp, #-16]
  mov r0, #15
  sub r2, sp, #16
  swi 0
  bx lr
END(cloudabi_sys_fd_sync)

ENTRY(cloudabi_sys_fd_write)
  str r0, [sp, #-24]
  str r1, [sp, #-16]
  mov r0, #0
  str r0, [sp, #-12]
  str r2, [sp, #-8]
  str r0, [sp, #-4]
  str r3, [sp, #-28]
  mov r0, #16
  sub r2, sp, #24
  swi 0
  ldrcc r1, [sp, #-28]
  ldrcc r2, [sp, #-24]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_fd_write)

ENTRY(cloudabi_sys_file_advise)
  str r0, [sp, #-32]
  str r2, [sp, #-24]
  str r3, [sp, #-20]
  ldr r1, [sp, #0]
  str r1, [sp, #-16]
  ldr r1, [sp, #4]
  str r1, [sp, #-12]
  ldr r1, [sp, #8]
  str r1, [sp, #-8]
  mov r0, #17
  sub r2, sp, #32
  swi 0
  bx lr
END(cloudabi_sys_file_advise)

ENTRY(cloudabi_sys_file_allocate)
  str r0, [sp, #-24]
  str r2, [sp, #-16]
  str r3, [sp, #-12]
  ldr r1, [sp, #0]
  str r1, [sp, #-8]
  ldr r1, [sp, #4]
  str r1, [sp, #-4]
  mov r0, #18
  sub r2, sp, #24
  swi 0
  bx lr
END(cloudabi_sys_file_allocate)

ENTRY(cloudabi_sys_file_create)
  str r0, [sp, #-32]
  str r1, [sp, #-24]
  mov r0, #0
  str r0, [sp, #-20]
  str r2, [sp, #-16]
  str r0, [sp, #-12]
  str r3, [sp, #-8]
  mov r0, #19
  sub r2, sp, #32
  swi 0
  bx lr
END(cloudabi_sys_file_create)

ENTRY(cloudabi_sys_file_link)
  str r0, [sp, #-48]
  str r1, [sp, #-44]
  str r2, [sp, #-40]
  mov r0, #0
  str r0, [sp, #-36]
  str r3, [sp, #-32]
  str r0, [sp, #-28]
  ldr r1, [sp, #0]
  str r1, [sp, #-24]
  ldr r1, [sp, #4]
  str r1, [sp, #-16]
  str r0, [sp, #-12]
  ldr r1, [sp, #8]
  str r1, [sp, #-8]
  str r0, [sp, #-4]
  mov r0, #20
  sub r2, sp, #48
  swi 0
  bx lr
END(cloudabi_sys_file_link)

ENTRY(cloudabi_sys_file_open)
  str r0, [sp, #-40]
  str r1, [sp, #-36]
  str r2, [sp, #-32]
  mov r0, #0
  str r0, [sp, #-28]
  str r3, [sp, #-24]
  str r0, [sp, #-20]
  ldr r1, [sp, #0]
  str r1, [sp, #-16]
  ldr r1, [sp, #4]
  str r1, [sp, #-8]
  str r0, [sp, #-4]
  mov r0, #21
  sub r2, sp, #40
  swi 0
  ldrcc r1, [sp, #8]
  ldrcc r2, [sp, #-40]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_file_open)

ENTRY(cloudabi_sys_file_readdir)
  str r0, [sp, #-32]
  str r1, [sp, #-24]
  mov r0, #0
  str r0, [sp, #-20]
  str r2, [sp, #-16]
  str r0, [sp, #-12]
  ldr r1, [sp, #0]
  str r1, [sp, #-8]
  ldr r1, [sp, #4]
  str r1, [sp, #-4]
  mov r0, #22
  sub r2, sp, #32
  swi 0
  ldrcc r1, [sp, #8]
  ldrcc r2, [sp, #-32]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_file_readdir)

ENTRY(cloudabi_sys_file_readlink)
  str r0, [sp, #-40]
  str r1, [sp, #-32]
  mov r0, #0
  str r0, [sp, #-28]
  str r2, [sp, #-24]
  str r0, [sp, #-20]
  str r3, [sp, #-16]
  str r0, [sp, #-12]
  ldr r1, [sp, #0]
  str r1, [sp, #-8]
  str r0, [sp, #-4]
  mov r0, #23
  sub r2, sp, #40
  swi 0
  ldrcc r1, [sp, #4]
  ldrcc r2, [sp, #-40]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_file_readlink)

ENTRY(cloudabi_sys_file_rename)
  str r0, [sp, #-48]
  str r1, [sp, #-40]
  mov r0, #0
  str r0, [sp, #-36]
  str r2, [sp, #-32]
  str r0, [sp, #-28]
  str r3, [sp, #-24]
  ldr r1, [sp, #0]
  str r1, [sp, #-16]
  str r0, [sp, #-12]
  ldr r1, [sp, #4]
  str r1, [sp, #-8]
  str r0, [sp, #-4]
  mov r0, #24
  sub r2, sp, #48
  swi 0
  bx lr
END(cloudabi_sys_file_rename)

ENTRY(cloudabi_sys_file_stat_fget)
  str r0, [sp, #-16]
  str r1, [sp, #-8]
  mov r0, #0
  str r0, [sp, #-4]
  mov r0, #25
  sub r2, sp, #16
  swi 0
  bx lr
END(cloudabi_sys_file_stat_fget)

ENTRY(cloudabi_sys_file_stat_fput)
  str r0, [sp, #-24]
  str r1, [sp, #-16]
  mov r0, #0
  str r0, [sp, #-12]
  str r2, [sp, #-8]
  mov r0, #26
  sub r2, sp, #24
  swi 0
  bx lr
END(cloudabi_sys_file_stat_fput)

ENTRY(cloudabi_sys_file_stat_get)
  str r0, [sp, #-32]
  str r1, [sp, #-28]
  str r2, [sp, #-24]
  mov r0, #0
  str r0, [sp, #-20]
  str r3, [sp, #-16]
  str r0, [sp, #-12]
  ldr r1, [sp, #0]
  str r1, [sp, #-8]
  str r0, [sp, #-4]
  mov r0, #27
  sub r2, sp, #32
  swi 0
  bx lr
END(cloudabi_sys_file_stat_get)

ENTRY(cloudabi_sys_file_stat_put)
  str r0, [sp, #-40]
  str r1, [sp, #-36]
  str r2, [sp, #-32]
  mov r0, #0
  str r0, [sp, #-28]
  str r3, [sp, #-24]
  str r0, [sp, #-20]
  ldr r1, [sp, #0]
  str r1, [sp, #-16]
  str r0, [sp, #-12]
  ldr r1, [sp, #4]
  str r1, [sp, #-8]
  mov r0, #28
  sub r2, sp, #40
  swi 0
  bx lr
END(cloudabi_sys_file_stat_put)

ENTRY(cloudabi_sys_file_symlink)
  str r0, [sp, #-40]
  mov r0, #0
  str r0, [sp, #-36]
  str r1, [sp, #-32]
  str r0, [sp, #-28]
  str r2, [sp, #-24]
  str r3, [sp, #-16]
  str r0, [sp, #-12]
  ldr r1, [sp, #0]
  str r1, [sp, #-8]
  str r0, [sp, #-4]
  mov r0, #29
  sub r2, sp, #40
  swi 0
  bx lr
END(cloudabi_sys_file_symlink)

ENTRY(cloudabi_sys_file_unlink)
  str r0, [sp, #-32]
  str r1, [sp, #-24]
  mov r0, #0
  str r0, [sp, #-20]
  str r2, [sp, #-16]
  str r0, [sp, #-12]
  str r3, [sp, #-8]
  mov r0, #30
  sub r2, sp, #32
  swi 0
  bx lr
END(cloudabi_sys_file_unlink)

ENTRY(cloudabi_sys_lock_unlock)
  str r0, [sp, #-16]
  mov r0, #0
  str r0, [sp, #-12]
  str r1, [sp, #-8]
  mov r0, #31
  sub r2, sp, #16
  swi 0
  bx lr
END(cloudabi_sys_lock_unlock)

ENTRY(cloudabi_sys_mem_advise)
  str r0, [sp, #-24]
  mov r0, #0
  str r0, [sp, #-20]
  str r1, [sp, #-16]
  str r0, [sp, #-12]
  str r2, [sp, #-8]
  mov r0, #32
  sub r2, sp, #24
  swi 0
  bx lr
END(cloudabi_sys_mem_advise)

ENTRY(cloudabi_sys_mem_map)
  str r0, [sp, #-48]
  mov r0, #0
  str r0, [sp, #-44]
  str r1, [sp, #-40]
  str r0, [sp, #-36]
  str r2, [sp, #-32]
  str r3, [sp, #-24]
  ldr r1, [sp, #0]
  str r1, [sp, #-16]
  ldr r1, [sp, #8]
  str r1, [sp, #-8]
  ldr r1, [sp, #12]
  str r1, [sp, #-4]
  mov r0, #33
  sub r2, sp, #48
  swi 0
  ldrcc r1, [sp, #16]
  ldrcc r2, [sp, #-48]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_mem_map)

ENTRY(cloudabi_sys_mem_protect)
  str r0, [sp, #-24]
  mov r0, #0
  str r0, [sp, #-20]
  str r1, [sp, #-16]
  str r0, [sp, #-12]
  str r2, [sp, #-8]
  mov r0, #34
  sub r2, sp, #24
  swi 0
  bx lr
END(cloudabi_sys_mem_protect)

ENTRY(cloudabi_sys_mem_sync)
  str r0, [sp, #-24]
  mov r0, #0
  str r0, [sp, #-20]
  str r1, [sp, #-16]
  str r0, [sp, #-12]
  str r2, [sp, #-8]
  mov r0, #35
  sub r2, sp, #24
  swi 0
  bx lr
END(cloudabi_sys_mem_sync)

ENTRY(cloudabi_sys_mem_unmap)
  str r0, [sp, #-16]
  mov r0, #0
  str r0, [sp, #-12]
  str r1, [sp, #-8]
  str r0, [sp, #-4]
  mov r0, #36
  sub r2, sp, #16
  swi 0
  bx lr
END(cloudabi_sys_mem_unmap)

ENTRY(cloudabi_sys_poll)
  str r0, [sp, #-24]
  mov r0, #0
  str r0, [sp, #-20]
  str r1, [sp, #-16]
  str r0, [sp, #-12]
  str r2, [sp, #-8]
  str r0, [sp, #-4]
  str r3, [sp, #-28]
  mov r0, #37
  sub r2, sp, #24
  swi 0
  ldrcc r1, [sp, #-28]
  ldrcc r2, [sp, #-24]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_poll)

ENTRY(cloudabi_sys_proc_exec)
  str r0, [sp, #-40]
  str r1, [sp, #-32]
  mov r0, #0
  str r0, [sp, #-28]
  str r2, [sp, #-24]
  str r0, [sp, #-20]
  str r3, [sp, #-16]
  str r0, [sp, #-12]
  ldr r1, [sp, #0]
  str r1, [sp, #-8]
  str r0, [sp, #-4]
  mov r0, #38
  sub r2, sp, #40
  swi 0
  bx lr
END(cloudabi_sys_proc_exec)

ENTRY(cloudabi_sys_proc_exit)
  str r0, [sp, #-16]
  mov r0, #39
  sub r2, sp, #16
  swi 0
END(cloudabi_sys_proc_exit)

ENTRY(cloudabi_sys_proc_fork)
  str r0, [sp, #-20]
  str r1, [sp, #-24]
  mov r0, #40
  sub r2, sp, #16
  swi 0
  ldrcc r1, [sp, #-20]
  ldrcc r2, [sp, #-16]
  strcc r2, [r1, #0]
  ldrcc r1, [sp, #-24]
  ldrcc r2, [sp, #-8]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_proc_fork)

ENTRY(cloudabi_sys_proc_raise)
  str r0, [sp, #-16]
  mov r0, #41
  sub r2, sp, #16
  swi 0
  bx lr
END(cloudabi_sys_proc_raise)

ENTRY(cloudabi_sys_random_get)
  str r0, [sp, #-16]
  mov r0, #0
  str r0, [sp, #-12]
  str r1, [sp, #-8]
  str r0, [sp, #-4]
  mov r0, #42
  sub r2, sp, #16
  swi 0
  bx lr
END(cloudabi_sys_random_get)

ENTRY(cloudabi_sys_sock_recv)
  str r0, [sp, #-24]
  str r1, [sp, #-16]
  mov r0, #0
  str r0, [sp, #-12]
  str r2, [sp, #-8]
  str r0, [sp, #-4]
  mov r0, #43
  sub r2, sp, #24
  swi 0
  bx lr
END(cloudabi_sys_sock_recv)

ENTRY(cloudabi_sys_sock_send)
  str r0, [sp, #-24]
  str r1, [sp, #-16]
  mov r0, #0
  str r0, [sp, #-12]
  str r2, [sp, #-8]
  str r0, [sp, #-4]
  mov r0, #44
  sub r2, sp, #24
  swi 0
  bx lr
END(cloudabi_sys_sock_send)

ENTRY(cloudabi_sys_sock_shutdown)
  str r0, [sp, #-16]
  str r1, [sp, #-8]
  mov r0, #45
  sub r2, sp, #16
  swi 0
  bx lr
END(cloudabi_sys_sock_shutdown)

ENTRY(cloudabi_sys_thread_create)
  str r0, [sp, #-16]
  mov r0, #0
  str r0, [sp, #-12]
  str r1, [sp, #-20]
  mov r0, #46
  sub r2, sp, #16
  swi 0
  ldrcc r1, [sp, #-20]
  ldrcc r2, [sp, #-16]
  strcc r2, [r1, #0]
  bx lr
END(cloudabi_sys_thread_create)

ENTRY(cloudabi_sys_thread_exit)
  str r0, [sp, #-16]
  mov r0, #0
  str r0, [sp, #-12]
  str r1, [sp, #-8]
  mov r0, #47
  sub r2, sp, #16
  swi 0
END(cloudabi_sys_thread_exit)

ENTRY(cloudabi_sys_thread_yield)
  mov r0, #48
  sub r2, sp, #16
  swi 0
  bx lr
END(cloudabi_sys_thread_yield)
