#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_8_1_%d", getpid());
  unlink(tmpfname);
  fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR);
  if (fd == -1) {
    printf("aio_fsync/8-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/8-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/8-1.c"
           " Error at aio_error() : %s\n",
           strerror(ret));
    exit(1);
  }
  memset(&aiocb_fsync, 0, sizeof(aiocb_fsync));
  aiocb_fsync.aio_fildes = fd;
  aiocb_fsync.aio_nbytes = -1;
  if (aio_fsync(O_SYNC, &aiocb_fsync) != 0) {
    printf("aio_fsync/8-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/8-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    14f0 <main+0x300>
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)
movl   $0xffffffff,-0x1a8(%rbp)
ff ff ff
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
lea    -0x1b8(%rbp),%rsi
call   10c0 <aio_fsync@plt>
cmp    $0x0,%rax
je     1433 <main+0x243>
mov    0x2b97(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %rax,%rsi
lea    0xc72(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1438 <main+0x248>
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    0x2b6f(%rip),%rcx
cmp    (%rcx),%eax
je     1438 <main+0x248>
lea    -0x1b8(%rbp),%rdi
call   10b0 <aio_return@plt>
mov    %eax,-0x188(%rbp)
cmpl   $0x0,-0x188(%rbp)
je     14d0 <main+0x2e0>
mov    -0x188(%rbp),%eax
mov    %eax,-0x1c4(%rbp)
mov    0x2b0d(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x1c4(%rbp),%esi
mov    %rax,%rdx
lea    0xc0c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x184(%rbp),%edi
call   1090 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f0 <main+0x300>
mov    -0x184(%rbp),%edi
call   1090 <close@plt>
lea    0xc0c(%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     13ca <main+0x1ca>
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     13d6 <main+0x1d6>
mov    %eax,%r14d
lea    0xa0(%rsp),%rdi
call   1030 <unlink@plt>
lea    0x18(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    %r14d,0x18(%rsp)
lea    0x30(%rsp),%rax
mov    %rax,0x20(%rsp)
movl   $0x6f,0x28(%rsp)
mov    %rbp,%rdi
call   1060 <aio_write@plt>
cmp    $0xffffffff,%eax
je     13ff <main+0x1ff>
lea    0x18(%rsp),%rbp
mov    0x2cdf(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2710,%edi
call   1120 <usleep@plt>
mov    %rbp,%rdi
call   10b0 <aio_error@plt>
cmp    (%rbx),%eax
je     1300 <main+0x100>
test   %eax,%eax
js     1416 <main+0x216>
mov    %rsp,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    %r14d,(%rsp)
movl   $0xffffffff,0x10(%rsp)
ff
mov    0x2c95(%rip),%rax
mov    (%rax),%edi
mov    %rbp,%rsi
call   10d0 <aio_fsync@plt>
test   %rax,%rax
jne    1426 <main+0x226>
mov    %rsp,%rbp
nopl   0x0(%rax)
mov    $0x2710,%edi
call   1120 <usleep@plt>
mov    %rbp,%rdi
call   10b0 <aio_error@plt>
cmp    (%rbx),%eax
je     1360 <main+0x160>
mov    %rsp,%rdi
call   10c0 <aio_return@plt>
test   %eax,%eax
je     13b4 <main+0x1b4>
mov    %eax,%ebp
mov    0x2c1d(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xd25(%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    13ca <main+0x1ca>
mov    %r14d,%edi
call   10a0 <close@plt>
lea    0xd2b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2bcb(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xc2f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x2,%edi
call   1100 <exit@plt>
mov    0x2ba2(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xc2b(%rip),%rdi
jmp    143b <main+0x23b>
mov    %eax,%edi
call   1110 <strerror@plt>
lea    0xc45(%rip),%rdi
jmp    143b <main+0x23b>
mov    0x2b7b(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xc59(%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_8_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/8-1.c Error at open(): %s\0A\00"
@errno = global i32 0
@.str.2 = [42 x i8] c"aio_fsync/8-1.c Error at aio_write(): %s\0A\00"
@EINPROGRESS = global i32 0
@.str.3 = [43 x i8] c"aio_fsync/8-1.c Error at aio_error() : %s\0A\00"
@O_SYNC = global i32 0
@.str.4 = [42 x i8] c"aio_fsync/8-1.c Error at aio_fsync(): %s\0A\00"
@.str.5 = [48 x i8] c"aio_fsync/8-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 %103
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 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %7, i32 0, i32 2
store i32 -1, i32* %71
%72 = load i32, i32* @O_SYNC
%73 = call i64 @aio_fsync(i32 %72, %struct.aiocb* %7)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %80
75: ; preds = %67
%76 = load i32, i32* @errno
%77 = call i8* @strerror(i32 %76)
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %77)
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %67
br label %81
81: ; preds = %84, %80
%82 = call i32 @usleep(i32 10000)
%83 = call i32 @aio_error(%struct.aiocb* %7)
store i32 %83, i32* %5
br label %84
84: ; preds = %81
%85 = load i32, i32* %5
%86 = load i32, i32* @EINPROGRESS
%87 = icmp eq i32 %85, %86
br i1 %87, label %81, label %88
88: ; preds = %84
%89 = call i32 @aio_return(%struct.aiocb* %7)
store i32 %89, i32* %5
%90 = load i32, i32* %5
%91 = icmp ne i32 %90, 0
br i1 %91, label %92, label %99
92: ; preds = %88
%93 = load i32, i32* %5
%94 = load i32, i32* @errno
%95 = call i8* @strerror(i32 %94)
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 %93, i8* %95)
%97 = load i32, i32* %4
%98 = call i32 @close(i32 %97)
store i32 1, i32* %1
br label %103
99: ; preds = %88
%100 = load i32, i32* %4
%101 = call i32 @close(i32 %100)
%102 = 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 %103
103: ; preds = %99, %92, %11
%104 = load i32, i32* %1
ret i32 %104
}

LLVM IR (-O2):
%struct.aiocb = type { i32, i8*, i32 }
@_SC_ASYNCHRONOUS_IO = global i32 0
@.str = [26 x i8] c"/tmp/pts_aio_fsync_8_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/8-1.c Error at open(): %s\0A\00"
@errno = global i32 0
@.str.2 = [42 x i8] c"aio_fsync/8-1.c Error at aio_write(): %s\0A\00"
@EINPROGRESS = global i32 0
@.str.3 = [43 x i8] c"aio_fsync/8-1.c Error at aio_error() : %s\0A\00"
@O_SYNC = global i32 0
@.str.4 = [42 x i8] c"aio_fsync/8-1.c Error at aio_fsync(): %s\0A\00"
@.str.5 = [48 x i8] c"aio_fsync/8-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 %83, 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 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %4, i64 0, i32 2
store i32 -1, i32* %58
%59 = load i32, i32* @O_SYNC
%60 = call i64 @aio_fsync(i32 %59, %struct.aiocb* %4)
%61 = icmp eq i64 %60, 0
br i1 %61, label %67, label %62
62: ; preds = %55
%63 = load i32, i32* @errno
%64 = call i8* @strerror(i32 %63)
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %64)
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %55, %67
%68 = call i32 @usleep(i32 10000)
%69 = call i32 @aio_error(%struct.aiocb* %4)
%70 = load i32, i32* @EINPROGRESS
%71 = icmp eq i32 %69, %70
br i1 %71, label %67, label %72
72: ; preds = %67
%73 = call i32 @aio_return(%struct.aiocb* %4)
%74 = icmp eq i32 %73, 0
br i1 %74, label %80, label %75
75: ; preds = %72
%76 = load i32, i32* @errno
%77 = call i8* @strerror(i32 %76)
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 %73, i8* %77)
%79 = call i32 @close(i32 %24)
br label %83
80: ; preds = %72
%81 = call i32 @close(i32 %24)
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %83
83: ; preds = %0, %80, %75
%84 = phi i32 [ 1, %75 ], [ 0, %80 ], [ 4, %0 ]
ret i32 %84
}