#include <stdint.h>
#include <uprintf.h>

uint64_t syscall(uint64_t num, uint64_t arg1, uint64_t arg2,
    uint64_t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6) {
  uint64_t ret;
  asm volatile(
    "mov %[a4], %%r10\n"
    "mov %[a5], %%r8\n"
    "mov %[a6], %%r9\n"
    "int $0x80\n"
    : "=a"(ret)
    : "a"(num), "D"(arg1), "S"(arg2), "d"(arg3),
      [a4]"r"(arg4), [a5]"r"(arg5), [a6]"r"(arg6)
    : "r10", "r8", "r9", "memory", "cc"
  );
  return ret;
}
