#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 int /*<<< orphan*/ tmpfname;
struct aiocb {
  int aio_fildes;
  char *aio_buf;
  int aio_nbytes;
};
typedef int /*<<< orphan*/ aiocb_write;
typedef int /*<<< orphan*/ aiocb_fsync;

/* Variables and functions */
int EINPROGRESS;
int O_CREAT;
int O_EXCL;
int O_RDWR;
int /*<<< orphan*/ O_SYNC;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ _SC_ASYNCHRONOUS_IO;
int aio_error(struct aiocb *);
scalar_t__ aio_fsync(int /*<<< orphan*/, struct aiocb *);
int aio_return(struct aiocb *);
int aio_write(struct aiocb *);
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ exit(int);
int getpid();
int /*<<< orphan*/ memset(struct aiocb *, int /*<<< orphan*/, int);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
char *strerror(int);
long sysconf(int /*<<< orphan*/);
int /*<<< orphan*/ unlink(char *);
int /*<<< orphan*/ usleep(int);
int main(void) {
  char tmpfname[256];
  char buf[111];
  int fd;
  int ret;
  struct aiocb aiocb_write;
  struct aiocb aiocb_fsync;
  if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
    return 4;
  snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_aio_fsync_9_1_%d", getpid());
  unlink(tmpfname);
  fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR);
  if (fd == -1) {
    printf("aio_fsync/9-1.c"
           " Error at open(): %s\n",
           strerror(errno));
    exit(2);
  }
  unlink(tmpfname);
  memset(&aiocb_write, 0, sizeof(aiocb_write));
  aiocb_write.aio_fildes = fd;
  aiocb_write.aio_buf = buf;
  aiocb_write.aio_nbytes = 111;
  if (aio_write(&aiocb_write) == -1) {
    printf("aio_fsync/9-1.c"
           " Error at aio_write(): %s\n",
           strerror(errno));
    exit(1);
  }
  do {
    usleep(10000);
    ret = aio_error(&aiocb_write);
  } while (ret == EINPROGRESS);
  if (ret < 0) {
    printf("aio_fsync/9-1.c"
           " Error at aio_error() : %s\n",
           strerror(ret));
    exit(1);
  }
  memset(&aiocb_fsync, 0, sizeof(aiocb_fsync));
  aiocb_fsync.aio_fildes = fd;
  if (aio_fsync(O_SYNC, &aiocb_fsync) != 0) {
    printf("aio_fsync/9-1.c"
           " Error at aio_fsync(): %s\n",
           strerror(errno));
    exit(1);
  }
  do {
    usleep(10000);
    ret = aio_error(&aiocb_fsync);
  } while (ret == EINPROGRESS);
  ret = aio_return(&aiocb_fsync);
  if (ret) {
    printf("aio_fsync/9-1.c"
           " Error at aio_return(): %d (%s)\n",
           ret, strerror(errno));
    close(fd);
    return 1;
  }
  close(fd);
  printf("Test PASSED\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
call   10e0 <sysconf@plt>
cmp    $0x30db0,%rax
jge    1228 <main+0x38>
movl   $0x4,-0x4(%rbp)
jmp    14e6 <main+0x2f6>
lea    -0x110(%rbp),%rax
mov    %rax,-0x1c0(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x1c0(%rbp),%rdi
mov    %eax,%ecx
mov    $0x100,%esi
lea    0xdae(%rip),%rdx
call   1070 <snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <unlink@plt>
lea    -0x110(%rbp),%rdi
mov    0x2d87(%rip),%rax
mov    (%rax),%esi
mov    0x2d66(%rip),%rax
or     (%rax),%esi
mov    0x2d2d(%rip),%rax
or     (%rax),%esi
mov    0x2d14(%rip),%rax
mov    (%rax),%edx
mov    0x2d2b(%rip),%rax
or     (%rax),%edx
call   10d0 <open@plt>
mov    %eax,-0x184(%rbp)
cmpl   $0xffffffff,-0x184(%rbp)
jne    12d8 <main+0xe8>
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %rax,%rsi
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x2,%edi
call   10f0 <exit@plt>
lea    -0x110(%rbp),%rdi
call   1030 <unlink@plt>
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    -0x184(%rbp),%eax
mov    %eax,-0x1a0(%rbp)
lea    -0x180(%rbp),%rax
mov    %rax,-0x198(%rbp)
movl   $0x6f,-0x190(%rbp)
lea    -0x1a0(%rbp),%rdi
call   1050 <aio_write@plt>
cmp    $0xffffffff,%eax
jne    1359 <main+0x169>
mov    0x2c71(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %rax,%rsi
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    135e <main+0x16e>
mov    $0x2710,%edi
call   1110 <usleep@plt>
lea    -0x1a0(%rbp),%rdi
call   10a0 <aio_error@plt>
mov    %eax,-0x188(%rbp)
mov    -0x188(%rbp),%eax
mov    0x2c49(%rip),%rcx
cmp    (%rcx),%eax
je     135e <main+0x16e>
cmpl   $0x0,-0x188(%rbp)
jge    13c2 <main+0x1d2>
mov    -0x188(%rbp),%edi
call   1100 <strerror@plt>
mov    %rax,%rsi
lea    0xcb8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    -0x1b8(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    -0x184(%rbp),%eax
mov    %eax,-0x1b8(%rbp)
mov    0x2bf0(%rip),%rax
mov    (%rax),%edi
lea    -0x1b8(%rbp),%rsi
call   10c0 <aio_fsync@plt>
cmp    $0x0,%rax
je     1429 <main+0x239>
mov    0x2ba1(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %rax,%rsi
lea    0xc7c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    142e <main+0x23e>
mov    $0x2710,%edi
call   1110 <usleep@plt>
lea    -0x1b8(%rbp),%rdi
call   10a0 <aio_error@plt>
mov    %eax,-0x188(%rbp)
mov    -0x188(%rbp),%eax
mov    0x2b79(%rip),%rcx
cmp    (%rcx),%eax
je     142e <main+0x23e>
lea    -0x1b8(%rbp),%rdi
call   10b0 <aio_return@plt>
mov    %eax,-0x188(%rbp)
cmpl   $0x0,-0x188(%rbp)
je     14c6 <main+0x2d6>
mov    -0x188(%rbp),%eax
mov    %eax,-0x1c4(%rbp)
mov    0x2b17(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x1c4(%rbp),%esi
mov    %rax,%rdx
lea    0xc16(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x184(%rbp),%edi
call   1090 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    14e6 <main+0x2f6>
mov    -0x184(%rbp),%edi
call   1090 <close@plt>
lea    0xc16(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1a0,%rsp
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   10f0 <sysconf@plt>
mov    %rax,%rcx
mov    $0x4,%eax
cmp    $0x30db0,%rcx
jl     13bc <main+0x1bc>
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xdc4(%rip),%rdx
lea    0xa0(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %eax,%ecx
call   1080 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    0x2d96(%rip),%rax
mov    0x2d77(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d3c(%rip),%rax
or     (%rax),%esi
mov    0x2d23(%rip),%rax
mov    0x2d3c(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %rbx,%rdi
call   10e0 <open@plt>
cmp    $0xffffffff,%eax
je     13c8 <main+0x1c8>
mov    %eax,%r14d
lea    0xa0(%rsp),%rdi
call   1030 <unlink@plt>
mov    %rsp,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    %r14d,(%rsp)
lea    0x30(%rsp),%rax
mov    %rax,0x8(%rsp)
movl   $0x6f,0x10(%rsp)
mov    %rbp,%rdi
call   1060 <aio_write@plt>
cmp    $0xffffffff,%eax
je     13f1 <main+0x1f1>
mov    %rsp,%rbp
mov    0x2ce4(%rip),%rbx
nopl   0x0(%rax)
mov    $0x2710,%edi
call   1120 <usleep@plt>
mov    %rbp,%rdi
call   10b0 <aio_error@plt>
cmp    (%rbx),%eax
je     12f0 <main+0xf0>
test   %eax,%eax
js     1408 <main+0x208>
lea    0x18(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    %r14d,0x18(%rsp)
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
mov    %rbp,%rsi
call   10d0 <aio_fsync@plt>
test   %rax,%rax
jne    1418 <main+0x218>
lea    0x18(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    $0x2710,%edi
call   1120 <usleep@plt>
mov    %rbp,%rdi
call   10b0 <aio_error@plt>
cmp    (%rbx),%eax
je     1350 <main+0x150>
lea    0x18(%rsp),%rdi
call   10c0 <aio_return@plt>
test   %eax,%eax
je     13a6 <main+0x1a6>
mov    %eax,%ebp
mov    0x2c2b(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xd33(%rip),%rdi
mov    %ebp,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14d,%edi
call   10a0 <close@plt>
mov    $0x1,%eax
jmp    13bc <main+0x1bc>
mov    %r14d,%edi
call   10a0 <close@plt>
lea    0xd39(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2bd9(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xc3d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x2,%edi
call   1100 <exit@plt>
mov    0x2bb0(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xc39(%rip),%rdi
jmp    142d <main+0x22d>
mov    %eax,%edi
call   1110 <strerror@plt>
lea    0xc53(%rip),%rdi
jmp    142d <main+0x22d>
mov    0x2b89(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xc67(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.aiocb = type { i32, i8*, i32 }
@_SC_ASYNCHRONOUS_IO = global i32 0
@.str = [26 x i8] c"/tmp/pts_aio_fsync_9_1_%d\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@O_EXCL = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.1 = [37 x i8] c"aio_fsync/9-1.c Error at open(): %s\0A\00"
@errno = global i32 0
@.str.2 = [42 x i8] c"aio_fsync/9-1.c Error at aio_write(): %s\0A\00"
@EINPROGRESS = global i32 0
@.str.3 = [43 x i8] c"aio_fsync/9-1.c Error at aio_error() : %s\0A\00"
@O_SYNC = global i32 0
@.str.4 = [42 x i8] c"aio_fsync/9-1.c Error at aio_fsync(): %s\0A\00"
@.str.5 = [48 x i8] c"aio_fsync/9-1.c Error at aio_return(): %d (%s)\0A\00"
@.str.6 = [13 x i8] c"Test PASSED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca [111 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.aiocb
%7 = alloca %struct.aiocb
store i32 0, i32* %1
%8 = load i32, i32* @_SC_ASYNCHRONOUS_IO
%9 = call i64 @sysconf(i32 %8)
%10 = icmp slt i64 %9, 200112
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 4, i32* %1
br label %102
12: ; preds = %0
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%14 = call i32 (...) @getpid()
%15 = call i32 @snprintf(i8* %13, i32 256, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%17 = call i32 @unlink(i8* %16)
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%19 = load i32, i32* @O_CREAT
%20 = load i32, i32* @O_RDWR
%21 = or i32 %19, %20
%22 = load i32, i32* @O_EXCL
%23 = or i32 %21, %22
%24 = load i32, i32* @S_IRUSR
%25 = load i32, i32* @S_IWUSR
%26 = or i32 %24, %25
%27 = call i32 @open(i8* %18, i32 %23, i32 %26)
store i32 %27, i32* %4
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %35
30: ; preds = %12
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 2)
unreachable
35: ; preds = %12
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%37 = call i32 @unlink(i8* %36)
%38 = call i32 @memset(%struct.aiocb* %6, i32 0, i32 24)
%39 = load i32, i32* %4
%40 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %6, i32 0, i32 0
store i32 %39, i32* %40
%41 = getelementptr inbounds [111 x i8], [111 x i8]* %3, i64 0, i64 0
%42 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %6, i32 0, i32 1
store i8* %41, i8** %42
%43 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %6, i32 0, i32 2
store i32 111, i32* %43
%44 = call i32 @aio_write(%struct.aiocb* %6)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %51
46: ; preds = %35
%47 = load i32, i32* @errno
%48 = call i8* @strerror(i32 %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %48)
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %35
br label %52
52: ; preds = %55, %51
%53 = call i32 @usleep(i32 10000)
%54 = call i32 @aio_error(%struct.aiocb* %6)
store i32 %54, i32* %5
br label %55
55: ; preds = %52
%56 = load i32, i32* %5
%57 = load i32, i32* @EINPROGRESS
%58 = icmp eq i32 %56, %57
br i1 %58, label %52, label %59
59: ; preds = %55
%60 = load i32, i32* %5
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %67
62: ; preds = %59
%63 = load i32, i32* %5
%64 = call i8* @strerror(i32 %63)
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %64)
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %59
%68 = call i32 @memset(%struct.aiocb* %7, i32 0, i32 24)
%69 = load i32, i32* %4
%70 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %7, i32 0, i32 0
store i32 %69, i32* %70
%71 = load i32, i32* @O_SYNC
%72 = call i64 @aio_fsync(i32 %71, %struct.aiocb* %7)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %79
74: ; preds = %67
%75 = load i32, i32* @errno
%76 = call i8* @strerror(i32 %75)
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %76)
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %67
br label %80
80: ; preds = %83, %79
%81 = call i32 @usleep(i32 10000)
%82 = call i32 @aio_error(%struct.aiocb* %7)
store i32 %82, i32* %5
br label %83
83: ; preds = %80
%84 = load i32, i32* %5
%85 = load i32, i32* @EINPROGRESS
%86 = icmp eq i32 %84, %85
br i1 %86, label %80, label %87
87: ; preds = %83
%88 = call i32 @aio_return(%struct.aiocb* %7)
store i32 %88, i32* %5
%89 = load i32, i32* %5
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %98
91: ; preds = %87
%92 = load i32, i32* %5
%93 = load i32, i32* @errno
%94 = call i8* @strerror(i32 %93)
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 %92, i8* %94)
%96 = load i32, i32* %4
%97 = call i32 @close(i32 %96)
store i32 1, i32* %1
br label %102
98: ; preds = %87
%99 = load i32, i32* %4
%100 = call i32 @close(i32 %99)
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %1
br label %102
102: ; preds = %98, %91, %11
%103 = load i32, i32* %1
ret i32 %103
}

LLVM IR (-O2):
%struct.aiocb = type { i32, i8*, i32 }
@_SC_ASYNCHRONOUS_IO = global i32 0
@.str = [26 x i8] c"/tmp/pts_aio_fsync_9_1_%d\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@O_EXCL = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.1 = [37 x i8] c"aio_fsync/9-1.c Error at open(): %s\0A\00"
@errno = global i32 0
@.str.2 = [42 x i8] c"aio_fsync/9-1.c Error at aio_write(): %s\0A\00"
@EINPROGRESS = global i32 0
@.str.3 = [43 x i8] c"aio_fsync/9-1.c Error at aio_error() : %s\0A\00"
@O_SYNC = global i32 0
@.str.4 = [42 x i8] c"aio_fsync/9-1.c Error at aio_fsync(): %s\0A\00"
@.str.5 = [48 x i8] c"aio_fsync/9-1.c Error at aio_return(): %d (%s)\0A\00"
@str = [12 x i8] c"Test PASSED\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [111 x i8]
%3 = alloca %struct.aiocb
%4 = alloca %struct.aiocb
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [111 x i8], [111 x i8]* %2, i64 0, i64 0
%7 = bitcast %struct.aiocb* %3 to i8*
%8 = bitcast %struct.aiocb* %4 to i8*
%9 = load i32, i32* @_SC_ASYNCHRONOUS_IO
%10 = tail call i64 @sysconf(i32 %9)
%11 = icmp slt i64 %10, 200112
br i1 %11, label %82, label %12
12: ; preds = %0
%13 = tail call i32 (...) @getpid()
%14 = call i32 @snprintf(i8* %5, i32 256, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 @unlink(i8* %5)
%16 = load i32, i32* @O_CREAT
%17 = load i32, i32* @O_RDWR
%18 = or i32 %17, %16
%19 = load i32, i32* @O_EXCL
%20 = or i32 %18, %19
%21 = load i32, i32* @S_IRUSR
%22 = load i32, i32* @S_IWUSR
%23 = or i32 %22, %21
%24 = call i32 @open(i8* %5, i32 %20, i32 %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %31
26: ; preds = %12
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 2)
unreachable
31: ; preds = %12
%32 = call i32 @unlink(i8* %5)
%33 = call i32 @memset(%struct.aiocb* %3, i32 0, i32 24)
%34 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %3, i64 0, i32 0
store i32 %24, i32* %34
%35 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %3, i64 0, i32 1
store i8* %6, i8** %35
%36 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %3, i64 0, i32 2
store i32 111, i32* %36
%37 = call i32 @aio_write(%struct.aiocb* %3)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %44
39: ; preds = %31
%40 = load i32, i32* @errno
%41 = call i8* @strerror(i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %41)
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %31, %44
%45 = call i32 @usleep(i32 10000)
%46 = call i32 @aio_error(%struct.aiocb* %3)
%47 = load i32, i32* @EINPROGRESS
%48 = icmp eq i32 %46, %47
br i1 %48, label %44, label %49
49: ; preds = %44
%50 = icmp slt i32 %46, 0
br i1 %50, label %51, label %55
51: ; preds = %49
%52 = call i8* @strerror(i32 %46)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %52)
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %49
%56 = call i32 @memset(%struct.aiocb* %4, i32 0, i32 24)
%57 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %4, i64 0, i32 0
store i32 %24, i32* %57
%58 = load i32, i32* @O_SYNC
%59 = call i64 @aio_fsync(i32 %58, %struct.aiocb* %4)
%60 = icmp eq i64 %59, 0
br i1 %60, label %66, label %61
61: ; preds = %55
%62 = load i32, i32* @errno
%63 = call i8* @strerror(i32 %62)
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %63)
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %55, %66
%67 = call i32 @usleep(i32 10000)
%68 = call i32 @aio_error(%struct.aiocb* %4)
%69 = load i32, i32* @EINPROGRESS
%70 = icmp eq i32 %68, %69
br i1 %70, label %66, label %71
71: ; preds = %66
%72 = call i32 @aio_return(%struct.aiocb* %4)
%73 = icmp eq i32 %72, 0
br i1 %73, label %79, label %74
74: ; preds = %71
%75 = load i32, i32* @errno
%76 = call i8* @strerror(i32 %75)
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 %72, i8* %76)
%78 = call i32 @close(i32 %24)
br label %82
79: ; preds = %71
%80 = call i32 @close(i32 %24)
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %82
82: ; preds = %0, %79, %74
%83 = phi i32 [ 1, %74 ], [ 0, %79 ], [ 4, %0 ]
ret i32 %83
}