int sys$device_scan(void *return_devnam, unsigned short int *retlen,
                    void *search_devnam, void *itmlst,
                    unsigned long long *contxt) {
  return ({
    unsigned long resultvar;
    register long int _a5 asm("r8") = (long)(contxt);
    register long int _a4 asm("r10") = (long)(itmlst);
    register long int _a3 asm("rdx") = (long)(search_devnam);
    register long int _a2 asm("rsi") = (long)(retlen);
    register long int _a1 asm("rdi") = (long)(return_devnam);
    asm volatile("movq %1, %%rax\n\t"
                 "int $0x81\n\t"
                 : "=a"(resultvar)
                 : "i"(77), "r"(_a1), "r"(_a2), "r"(_a3), "r"(_a4), "r"(_a5)
                 : "memory", "cc", "r11", "cx");
    (long)resultvar;
  });
}


x86 assembly (clang, -O0):
<sys$device_scan>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x40(%rbp),%r10
mov    -0x38(%rbp),%r8
mov    $0x4d,%rax
int    $0x81
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sys$device_scan>:
mov    %rcx,%r10
mov    $0x4d,%rax
int    $0x81
ret

LLVM IR (-O0):
define i32 @"sys$device_scan"(i8* %0, i16* %1, i8* %2, i8* %3, i64* %4) {
%6 = alloca i8*
%7 = alloca i16*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
store i8* %0, i8** %6
store i16* %1, i16** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i64* %4, i64** %10
%18 = load i64*, i64** %10
%19 = ptrtoint i64* %18 to i64
store i64 %19, i64* %12
%20 = load i8*, i8** %9
%21 = ptrtoint i8* %20 to i64
store i64 %21, i64* %13
%22 = load i8*, i8** %8
%23 = ptrtoint i8* %22 to i64
store i64 %23, i64* %14
%24 = load i16*, i16** %7
%25 = ptrtoint i16* %24 to i64
store i64 %25, i64* %15
%26 = load i8*, i8** %6
%27 = ptrtoint i8* %26 to i64
store i64 %27, i64* %16
%28 = load i64, i64* %16
%29 = load i64, i64* %15
%30 = load i64, i64* %14
%31 = load i64, i64* %13
%32 = load i64, i64* %12
%33 = call i64 asm sideeffect "movq $1, %rax\0A\09int $$0x81\0A\09", "={ax},i,{rdi},{rsi},{rdx},{r10},{r8},~{memory},~{cc},~{r11},~{cx},~{dirflag},~{fpsr},~{flags}"(i32 77, i64 %28, i64 %29, i64 %30, i64 %31, i64 %32)
store i64 %33, i64* %11
%34 = load i64, i64* %11
store i64 %34, i64* %17
%35 = load i64, i64* %17
%36 = trunc i64 %35 to i32
ret i32 %36
}

LLVM IR (-O2):
define i32 @"sys$device_scan"(i8* %0, i16* %1, i8* %2, i8* %3, i64* %4) {
%6 = ptrtoint i64* %4 to i64
%7 = ptrtoint i8* %3 to i64
%8 = ptrtoint i8* %2 to i64
%9 = ptrtoint i16* %1 to i64
%10 = ptrtoint i8* %0 to i64
%11 = tail call i64 asm sideeffect "movq $1, %rax\0A\09int $$0x81\0A\09", "={ax},i,{rdi},{rsi},{rdx},{r10},{r8},~{memory},~{cc},~{r11},~{cx},~{dirflag},~{fpsr},~{flags}"(i32 77, i64 %10, i64 %9, i64 %8, i64 %7, i64 %6)
%12 = trunc i64 %11 to i32
ret i32 %12
}