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) {
    __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1"
                         : "=a"(result)
                         : "a"(tuple), "b"(reg_ebx), "c"(reg_ecx));
  } else {
    result = -1;
  }
  return result;
}


x86 assembly (clang, -O0):
<__unisys_vmcall_gnuc>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x38,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    $0x1,%edi
lea    -0x2c(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x34(%rbp),%rcx
lea    -0x38(%rbp),%r8
mov    $0x0,%al
call   1030 <cpuid@plt>
mov    -0x34(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     1172 <__unisys_vmcall_gnuc+0x62>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rbx
mov    -0x20(%rbp),%rcx
vmcall
mov    %rax,-0x28(%rbp)
jmp    117a <__unisys_vmcall_gnuc+0x6a>
movq   $0xffffffffffffffff,-0x28(%rbp)
ff
mov    -0x28(%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 i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
store i64 0, i64* %7
%12 = call i32 (i32, i32*, i32*, i32*, i32*, ...) bitcast (i32 (...)* @cpuid to i32 (i32, i32*, i32*, i32*, i32*, ...)*)(i32 1, i32* %8, i32* %9, i32* %10, i32* %11)
%13 = load i32, i32* %10
%14 = and i32 %13, -2147483648
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %3
%17 = load i64, i64* %4
%18 = load i64, i64* %5
%19 = load i64, i64* %6
%20 = call i64 asm sideeffect ".byte 0x00f, 0x001, 0x0c1", "={ax},{ax},{bx},{cx},~{dirflag},~{fpsr},~{flags}"(i64 %17, i64 %18, i64 %19)
store i64 %20, i64* %7
br label %22
21: ; preds = %3
store i64 -1, i64* %7
br label %22
22: ; preds = %21, %16
%23 = load i64, i64* %7
ret i64 %23
}

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
}