#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 */
typedef scalar_t__ aio_context_t;

/* Variables and functions */
int io_destroy(scalar_t__);
int io_setup(int, scalar_t__ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sleep(int);
int main() {
  aio_context_t ctx;
  int ret;
  ctx = 0;
  ret = io_setup(128, &ctx);
  if (ret < 0) {
    perror("io_setup error");
    return -1;
  }
  sleep(10000);
  ret = io_destroy(ctx);
  if (ret < 0) {
    perror("io_destroy error");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x80,%edi
lea    -0x10(%rbp),%rsi
call   1030 <io_setup@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    118a <main+0x4a>
lea    0xe87(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c9 <main+0x89>
mov    $0x2710,%edi
call   1060 <sleep@plt>
mov    -0x10(%rbp),%rdi
call   1040 <io_destroy@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11c2 <main+0x82>
lea    0xe5e(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c9 <main+0x89>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movq   $0x0,(%rsp)
mov    %rsp,%rsi
mov    $0x80,%edi
call   1030 <io_setup@plt>
test   %eax,%eax
js     1177 <main+0x37>
mov    $0x2710,%edi
call   1060 <sleep@plt>
mov    (%rsp),%rdi
call   1040 <io_destroy@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
js     1180 <main+0x40>
pop    %rcx
ret
lea    0xe82(%rip),%rdi
jmp    1187 <main+0x47>
lea    0xe88(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"io_setup error\00"
@.str.1 = [17 x i8] c"io_destroy error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %2
%4 = call i32 @io_setup(i32 128, i64* %2)
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %18
9: ; preds = %0
%10 = call i32 @sleep(i32 10000)
%11 = load i64, i64* %2
%12 = call i32 @io_destroy(i64 %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %18
17: ; preds = %9
store i32 0, i32* %1
br label %18
18: ; preds = %17, %15, %7
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [15 x i8] c"io_setup error\00"
@.str.1 = [17 x i8] c"io_destroy error\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%3 = call i32 @io_setup(i32 128, i64* %1)
%4 = icmp slt i32 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %0
%6 = call i32 @sleep(i32 10000)
%7 = load i64, i64* %1
%8 = call i32 @io_destroy(i64 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5, %0
%11 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %5 ]
%12 = call i32 @perror(i8* %11)
br label %13
13: ; preds = %10, %5
%14 = phi i32 [ 0, %5 ], [ -1, %10 ]
ret i32 %14
}