#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 */
int /*<<< orphan*/ _SC_ASYNCHRONOUS_IO;
int do_test(int, int);
int /*<<< orphan*/ printf(char *, int);
long sysconf(int /*<<< orphan*/);
int main(void) {
  int aio_cbs = 10;
  int buf_size = 1024 * 64;
  int ret;
  if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
    return 4;
  do {
    ret = do_test(aio_cbs, buf_size);
    buf_size += buf_size / 4;
  } while (ret == -1);
  if (ret != 0)
    return ret;
  printf("(buf_size = %i)\nTest PASSED\n", buf_size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0x10000,-0xc(%rbp)
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
cmp    $0x30db0,%rax
jge    1173 <main+0x43>
movl   $0x4,-0x4(%rbp)
jmp    11cc <main+0x9c>
jmp    1178 <main+0x48>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <do_test@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
je     1178 <main+0x48>
cmpl   $0x0,-0x10(%rbp)
je     11b6 <main+0x86>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11cc <main+0x9c>
mov    -0xc(%rbp),%esi
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
mov    %rax,%rcx
mov    $0x4,%eax
cmp    $0x30db0,%rcx
jl     1190 <main+0x60>
mov    $0x10000,%esi
cs nopw 0x0(%rax,%rax,1)
nop
mov    %esi,%ebx
mov    $0xa,%edi
call   1040 <do_test@plt>
lea    0x3(%rbx),%esi
test   %ebx,%ebx
cmovns %ebx,%esi
sar    $0x2,%esi
add    %ebx,%esi
cmp    $0xffffffff,%eax
je     1160 <main+0x30>
test   %eax,%eax
jne    1190 <main+0x60>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@_SC_ASYNCHRONOUS_IO = global i32 0
@.str = [29 x i8] c"(buf_size = %i)\0ATest PASSED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
store i32 65536, i32* %3
%5 = load i32, i32* @_SC_ASYNCHRONOUS_IO
%6 = call i64 @sysconf(i32 %5)
%7 = icmp slt i64 %6, 200112
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 4, i32* %1
br label %29
9: ; preds = %0
br label %10
10: ; preds = %18, %9
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = call i32 @do_test(i32 %11, i32 %12)
store i32 %13, i32* %4
%14 = load i32, i32* %3
%15 = sdiv i32 %14, 4
%16 = load i32, i32* %3
%17 = add nsw i32 %16, %15
store i32 %17, i32* %3
br label %18
18: ; preds = %10
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, -1
br i1 %20, label %10, label %21
21: ; preds = %18
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = load i32, i32* %4
store i32 %25, i32* %1
br label %29
26: ; preds = %21
%27 = load i32, i32* %3
%28 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %27)
store i32 0, i32* %1
br label %29
29: ; preds = %26, %24, %8
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@_SC_ASYNCHRONOUS_IO = global i32 0
@.str = [29 x i8] c"(buf_size = %i)\0ATest PASSED\0A\00"
define i32 @main() {
%1 = load i32, i32* @_SC_ASYNCHRONOUS_IO
%2 = tail call i64 @sysconf(i32 %1)
%3 = icmp slt i64 %2, 200112
br i1 %3, label %11, label %4
4: ; preds = %0, %4
%5 = phi i32 [ %8, %4 ], [ 65536, %0 ]
%6 = tail call i32 @do_test(i32 10, i32 %5)
%7 = sdiv i32 %5, 4
%8 = add nsw i32 %7, %5
switch i32 %6, label %11 [
i32 -1, label %4
i32 0, label %9
]
9: ; preds = %4
%10 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %11
11: ; preds = %4, %0, %9
%12 = phi i32 [ 0, %9 ], [ 4, %0 ], [ %6, %4 ]
ret i32 %12
}