#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ mbox_property(int, unsigned int *);
unsigned execute_qpu(int file_desc, unsigned num_qpus, unsigned control,
                     unsigned noflush, unsigned timeout) {
  int i = 0;
  unsigned p[32];
  p[i++] = 0;
  p[i++] = 0x00000000;
  p[i++] = 0x30011;
  p[i++] = 16;
  p[i++] = 16;
  p[i++] = num_qpus;
  p[i++] = control;
  p[i++] = noflush;
  p[i++] = timeout;
  p[i++] = 0x00000000;
  p[0] = i * sizeof *p;
  if (mbox_property(file_desc, p) < 0)
    return 0;
  return p[5];
}


x86 assembly (clang, -O0):
<execute_qpu>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movl   $0x0,-0xa0(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movl   $0x0,-0xa0(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movl   $0x30011,-0xa0(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movl   $0x10,-0xa0(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movl   $0x10,-0xa0(%rbp,%rax,4)
mov    -0xc(%rbp),%ecx
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %ecx,-0xa0(%rbp,%rax,4)
mov    -0x10(%rbp),%ecx
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %ecx,-0xa0(%rbp,%rax,4)
mov    -0x14(%rbp),%ecx
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %ecx,-0xa0(%rbp,%rax,4)
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %ecx,-0xa0(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movl   $0x0,-0xa0(%rbp,%rax,4)
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,-0xa0(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xa0(%rbp),%rsi
call   1030 <mbox_property@plt>
cmp    $0x0,%rax
jge    1251 <execute_qpu+0x141>
movl   $0x0,-0x4(%rbp)
jmp    125a <execute_qpu+0x14a>
mov    -0x8c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_qpu>:
sub    $0x88,%rsp
movl   $0x10,0x10(%rsp)
mov    %esi,0x14(%rsp)
mov    %edx,0x18(%rsp)
mov    %ecx,0x1c(%rsp)
mov    %r8d,0x20(%rsp)
movl   $0x0,0x24(%rsp)
movaps 0xec1(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
call   1030 <mbox_property@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
js     1159 <execute_qpu+0x49>
mov    0x14(%rsp),%eax
add    $0x88,%rsp
ret

LLVM IR (-O0):
define i32 @execute_qpu(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [32 x i32]
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 0, i32* %12
%14 = load i32, i32* %12
%15 = add nsw i32 %14, 1
store i32 %15, i32* %12
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 %16
store i32 0, i32* %17
%18 = load i32, i32* %12
%19 = add nsw i32 %18, 1
store i32 %19, i32* %12
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 %20
store i32 0, i32* %21
%22 = load i32, i32* %12
%23 = add nsw i32 %22, 1
store i32 %23, i32* %12
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 %24
store i32 196625, i32* %25
%26 = load i32, i32* %12
%27 = add nsw i32 %26, 1
store i32 %27, i32* %12
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 %28
store i32 16, i32* %29
%30 = load i32, i32* %12
%31 = add nsw i32 %30, 1
store i32 %31, i32* %12
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 %32
store i32 16, i32* %33
%34 = load i32, i32* %8
%35 = load i32, i32* %12
%36 = add nsw i32 %35, 1
store i32 %36, i32* %12
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 %37
store i32 %34, i32* %38
%39 = load i32, i32* %9
%40 = load i32, i32* %12
%41 = add nsw i32 %40, 1
store i32 %41, i32* %12
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 %42
store i32 %39, i32* %43
%44 = load i32, i32* %10
%45 = load i32, i32* %12
%46 = add nsw i32 %45, 1
store i32 %46, i32* %12
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 %47
store i32 %44, i32* %48
%49 = load i32, i32* %11
%50 = load i32, i32* %12
%51 = add nsw i32 %50, 1
store i32 %51, i32* %12
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 %52
store i32 %49, i32* %53
%54 = load i32, i32* %12
%55 = add nsw i32 %54, 1
store i32 %55, i32* %12
%56 = sext i32 %54 to i64
%57 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 %56
store i32 0, i32* %57
%58 = load i32, i32* %12
%59 = sext i32 %58 to i64
%60 = mul i64 %59, 4
%61 = trunc i64 %60 to i32
%62 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 0
store i32 %61, i32* %62
%63 = load i32, i32* %7
%64 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 0
%65 = call i64 @mbox_property(i32 %63, i32* %64)
%66 = icmp slt i64 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %5
store i32 0, i32* %6
br label %71
68: ; preds = %5
%69 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 5
%70 = load i32, i32* %69
store i32 %70, i32* %6
br label %71
71: ; preds = %68, %67
%72 = load i32, i32* %6
ret i32 %72
}

LLVM IR (-O2):
define i32 @execute_qpu(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [32 x i32]
%7 = bitcast [32 x i32]* %6 to i8*
%8 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%9 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 4
store i32 16, i32* %9
%10 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 5
store i32 %1, i32* %10
%11 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 6
store i32 %2, i32* %11
%12 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 7
store i32 %3, i32* %12
%13 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 8
store i32 %4, i32* %13
%14 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 9
store i32 0, i32* %14
%15 = bitcast [32 x i32]* %6 to <4 x i32>*
store <4 x i32> <i32 40, i32 0, i32 196625, i32 16>, <4 x i32>* %15
%16 = call i64 @mbox_property(i32 %0, i32* %8)
%17 = icmp slt i64 %16, 0
%18 = load i32, i32* %10
%19 = select i1 %17, i32 0, i32 %18
ret i32 %19
}