#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 timespec {
  int member_1;
  int /*<<< orphan*/ member_0;
};
struct aiocb {
  int aio_fildes;
  char *aio_buf;
  int aio_nbytes;
  int aio_offset;
};
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 /*<<< orphan*/ nanosleep(struct timespec *, int /*<<< orphan*/ *);
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 main(void) {
  char tmpfname[256];
  char buf[111];
  int fd;
  int ret;
  struct aiocb aiocb_write;
  struct aiocb aiocb_fsync;
  struct timespec aio_wait_ts = {0, 10000000};
  if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
    return 4;
  snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_aio_fsync_8_4_%d", getpid());
  unlink(tmpfname);
  fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR);
  if (fd == -1) {
    printf("aio_fsync/8-4.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-4.c"
           " Error at aio_write(): %s\n",
           strerror(errno));
    exit(1);
  }
  do {
    nanosleep(&aio_wait_ts, NULL);
    ret = aio_error(&aiocb_write);
  } while (ret == EINPROGRESS);
  if (ret < 0) {
    printf("aio_fsync/8-4.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_offset = -1;
  if (aio_fsync(O_SYNC, &aiocb_fsync) != 0) {
    printf("aio_fsync/8-4.c"
           " Error at aio_fsync(): %s\n",
           strerror(errno));
    exit(1);
  }
  do {
    nanosleep(&aio_wait_ts, NULL);
    ret = aio_error(&aiocb_fsync);
  } while (ret == EINPROGRESS);
  ret = aio_return(&aiocb_fsync);
  if (ret) {
    printf("aio_fsync/8-4.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    0xdf7(%rip),%rax
mov    %rax,-0x1c0(%rbp)
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
call   10f0 <sysconf@plt>
cmp    $0x30db0,%rax
jge    1236 <main+0x46>
movl   $0x4,-0x4(%rbp)
jmp    150a <main+0x31a>
lea    -0x110(%rbp),%rax
mov    %rax,-0x1c8(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x1c8(%rbp),%rdi
mov    %eax,%ecx
mov    $0x100,%esi
lea    0xda8(%rip),%rdx
call   1070 <snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <unlink@plt>
lea    -0x110(%rbp),%rdi
mov    0x2d79(%rip),%rax
mov    (%rax),%esi
mov    0x2d58(%rip),%rax
or     (%rax),%esi
mov    0x2d1f(%rip),%rax
or     (%rax),%esi
mov    0x2d06(%rip),%rax
mov    (%rax),%edx
mov    0x2d1d(%rip),%rax
or     (%rax),%edx
call   10e0 <open@plt>
mov    %eax,-0x184(%rbp)
cmpl   $0xffffffff,-0x184(%rbp)
jne    12e6 <main+0xf6>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    %rax,%rsi
lea    0xd4d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x2,%edi
call   1100 <exit@plt>
lea    -0x110(%rbp),%rdi
call   1030 <unlink@plt>
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <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    1367 <main+0x177>
mov    0x2c63(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    %rax,%rsi
lea    0xcf1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
jmp    136c <main+0x17c>
lea    -0x1c0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <nanosleep@plt>
lea    -0x1a0(%rbp),%rdi
call   10b0 <aio_error@plt>
mov    %eax,-0x188(%rbp)
mov    -0x188(%rbp),%eax
mov    0x2c35(%rip),%rcx
cmp    (%rcx),%eax
je     136c <main+0x17c>
cmpl   $0x0,-0x188(%rbp)
jge    13d6 <main+0x1e6>
mov    -0x188(%rbp),%edi
call   1110 <strerror@plt>
mov    %rax,%rsi
lea    0xcac(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    -0x1b8(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    -0x184(%rbp),%eax
mov    %eax,-0x1b8(%rbp)
movl   $0xffffffff,-0x1a4(%rbp)
ff ff ff
mov    0x2bd2(%rip),%rax
mov    (%rax),%edi
lea    -0x1b8(%rbp),%rsi
call   10d0 <aio_fsync@plt>
cmp    $0x0,%rax
je     1447 <main+0x257>
mov    0x2b83(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    %rax,%rsi
lea    0xc66(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
jmp    144c <main+0x25c>
lea    -0x1c0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <nanosleep@plt>
lea    -0x1b8(%rbp),%rdi
call   10b0 <aio_error@plt>
mov    %eax,-0x188(%rbp)
mov    -0x188(%rbp),%eax
mov    0x2b55(%rip),%rcx
cmp    (%rcx),%eax
je     144c <main+0x25c>
lea    -0x1b8(%rbp),%rdi
call   10c0 <aio_return@plt>
mov    %eax,-0x188(%rbp)
cmpl   $0x0,-0x188(%rbp)
je     14ea <main+0x2fa>
mov    -0x188(%rbp),%eax
mov    %eax,-0x1cc(%rbp)
mov    0x2af3(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x1cc(%rbp),%esi
mov    %rax,%rdx
lea    0xbfa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x184(%rbp),%edi
call   10a0 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    150a <main+0x31a>
mov    -0x184(%rbp),%edi
call   10a0 <close@plt>
lea    0xbfa(%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   %r15
push   %r14
push   %rbx
sub    $0x1b8,%rsp
movabs $0x98968000000000,%rax
mov    %rax,0x8(%rsp)
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
call   1100 <sysconf@plt>
mov    %rax,%rcx
mov    $0x4,%eax
cmp    $0x30db0,%rcx
jl     13ed <main+0x1ed>
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xdb3(%rip),%rdx
lea    0xb0(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %eax,%ecx
call   1080 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    0x2d85(%rip),%rax
mov    0x2d66(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d2b(%rip),%rax
or     (%rax),%esi
mov    0x2d12(%rip),%rax
mov    0x2d2b(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %rbx,%rdi
call   10f0 <open@plt>
cmp    $0xffffffff,%eax
je     13fb <main+0x1fb>
mov    %eax,%r14d
lea    0xb0(%rsp),%rdi
call   1030 <unlink@plt>
lea    0x28(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10a0 <memset@plt>
mov    %r14d,0x28(%rsp)
lea    0x40(%rsp),%rax
mov    %rax,0x30(%rsp)
movl   $0x6f,0x38(%rsp)
mov    %rbx,%rdi
call   1060 <aio_write@plt>
cmp    $0xffffffff,%eax
je     1424 <main+0x224>
lea    0x8(%rsp),%rbp
lea    0x28(%rsp),%rbx
mov    0x2cc9(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %esi,%esi
call   1090 <nanosleep@plt>
mov    %rbx,%rdi
call   10c0 <aio_error@plt>
cmp    (%r15),%eax
je     1310 <main+0x110>
test   %eax,%eax
js     143b <main+0x23b>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10a0 <memset@plt>
mov    %r14d,0x10(%rsp)
movl   $0xffffffff,0x24(%rsp)
ff
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   10e0 <aio_fsync@plt>
test   %rax,%rax
jne    144b <main+0x24b>
lea    0x8(%rsp),%rbx
lea    0x10(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <nanosleep@plt>
mov    %rbp,%rdi
call   10c0 <aio_error@plt>
cmp    (%r15),%eax
je     1380 <main+0x180>
lea    0x10(%rsp),%rdi
call   10d0 <aio_return@plt>
test   %eax,%eax
je     13d7 <main+0x1d7>
mov    %eax,%ebp
mov    0x2bfa(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xd02(%rip),%rdi
mov    %ebp,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
mov    $0x1,%eax
jmp    13ed <main+0x1ed>
mov    %r14d,%edi
call   10b0 <close@plt>
lea    0xd08(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x1b8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ba6(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xc0a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x2,%edi
call   1110 <exit@plt>
mov    0x2b7d(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xc06(%rip),%rdi
jmp    1460 <main+0x260>
mov    %eax,%edi
call   1120 <strerror@plt>
lea    0xc20(%rip),%rdi
jmp    1460 <main+0x260>
mov    0x2b56(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xc34(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

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

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