unsigned long __unisys_vmcall_gnuc(unsigned long tuple, unsigned long reg_ebx,
                                   unsigned long reg_ecx) {
  unsigned long result = 0;
  unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
  cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx);
  if (!(cpuid_ecx & 0x80000000))
    return -1;
  __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1"
                       : "=a"(result)
                       : "a"(tuple), "b"(reg_ebx), "c"(reg_ecx));
  return result;
}


x86 assembly (clang, -O0):
<__unisys_vmcall_gnuc>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x38,%rsp
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    $0x1,%edi
lea    -0x34(%rbp),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
lea    -0x40(%rbp),%r8
mov    $0x0,%al
call   1030 <cpuid@plt>
mov    -0x3c(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
jne    1167 <__unisys_vmcall_gnuc+0x57>
movq   $0xffffffffffffffff,-0x10(%rbp)
ff
jmp    1182 <__unisys_vmcall_gnuc+0x72>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rbx
mov    -0x28(%rbp),%rcx
vmcall
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<__unisys_vmcall_gnuc>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
lea    0x4(%rsp),%r8
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <cpuid@plt>
mov    $0xffffffffffffffff,%rax
cmpl   $0x0,(%rsp)
jns    1159 <__unisys_vmcall_gnuc+0x49>
mov    %rbx,%rax
mov    %r15,%rbx
mov    %r14,%rcx
vmcall
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @__unisys_vmcall_gnuc(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 0, i64* %8
%13 = call i32 (i32, i32*, i32*, i32*, i32*, ...) bitcast (i32 (...)* @cpuid to i32 (i32, i32*, i32*, i32*, i32*, ...)*)(i32 1, i32* %9, i32* %10, i32* %11, i32* %12)
%14 = load i32, i32* %11
%15 = and i32 %14, -2147483648
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %3
store i64 -1, i64* %4
br label %24
18: ; preds = %3
%19 = load i64, i64* %5
%20 = load i64, i64* %6
%21 = load i64, i64* %7
%22 = call i64 asm sideeffect ".byte 0x00f, 0x001, 0x0c1", "={ax},{ax},{bx},{cx},~{dirflag},~{fpsr},~{flags}"(i64 %19, i64 %20, i64 %21)
store i64 %22, i64* %8
%23 = load i64, i64* %8
store i64 %23, i64* %4
br label %24
24: ; preds = %18, %17
%25 = load i64, i64* %4
ret i64 %25
}

LLVM IR (-O2):
define i64 @__unisys_vmcall_gnuc(i64 %0, i64 %1, i64 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = bitcast i32* %7 to i8*
%12 = call i32 (i32, i32*, i32*, i32*, i32*, ...) bitcast (i32 (...)* @cpuid to i32 (i32, i32*, i32*, i32*, i32*, ...)*)(i32 1, i32* %4, i32* %5, i32* %6, i32* %7)
%13 = load i32, i32* %6
%14 = icmp sgt i32 %13, -1
br i1 %14, label %17, label %15
15: ; preds = %3
%16 = call i64 asm sideeffect ".byte 0x00f, 0x001, 0x0c1", "={ax},{ax},{bx},{cx},~{dirflag},~{fpsr},~{flags}"(i64 %0, i64 %1, i64 %2)
br label %17
17: ; preds = %3, %15
%18 = phi i64 [ %16, %15 ], [ -1, %3 ]
ret i64 %18
}