#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ tmpfname;
struct TYPE_2__ {
  int /*<<< orphan*/ sigev_notify;
};
struct aiocb {
  int aio_fildes;
  int aio_nbytes;
  TYPE_1__ aio_sigevent;
  scalar_t__ aio_offset;
  int /*<<< orphan*/ *aio_buf;
};

/* Variables and functions */
scalar_t__ EINPROGRESS;
int O_CREAT;
int O_EXCL;
int O_RDWR;
int /*<<< orphan*/ SIGEV_NONE;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ _SC_ASYNCHRONOUS_IO;
scalar_t__ aio_error(struct aiocb *);
int aio_write(struct aiocb *);
struct aiocb *calloc(int, int);
int /*<<< orphan*/ errno;
int getpid();
int /*<<< orphan*/ *malloc(int);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
char *strerror(int /*<<< orphan*/);
long sysconf(int /*<<< orphan*/);
int /*<<< orphan*/ unlink(char *);
int main(void) {
  char tmpfname[256];
  int fd;
  struct aiocb *aiocb[128];
  int i;
  int ret;
  if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
    return 4;
  snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_aio_error_2_1_%d", getpid());
  unlink(tmpfname);
  fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR);
  if (fd == -1) {
    printf("aio_error/2-1.c"
           " Error at open(): %s\n",
           strerror(errno));
    return 2;
  }
  unlink(tmpfname);
  for (i = 0; i < 128; i++) {
    aiocb[i] = calloc(1, sizeof(struct aiocb));
    if (aiocb[i] == NULL) {
      printf("aio_error/2-1.c"
             " Error at malloc(): %s\n",
             strerror(errno));
      return 2;
    }
    aiocb[i]->aio_fildes = fd;
    aiocb[i]->aio_buf = malloc(1024);
    if (aiocb[i]->aio_buf == NULL) {
      printf("aio_error/2-1.c"
             " Error at malloc(): %s\n",
             strerror(errno));
      return 2;
    }
    aiocb[i]->aio_nbytes = 1024;
    aiocb[i]->aio_offset = 0;
    aiocb[i]->aio_sigevent.sigev_notify = SIGEV_NONE;
    if (aio_write(aiocb[i]) == -1) {
      printf("aio_error/2-1.c"
             " loop %d: Error at aio_write(): %s\n",
             i, strerror(errno));
      return 1;
    }
  }
  ret = 2;
  for (i = 0; i < 128; i++) {
    if (aio_error(aiocb[i]) == EINPROGRESS) {
      ret = 0;
      break;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x540,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
call   10c0 <sysconf@plt>
cmp    $0x30db0,%rax
jge    11e8 <main+0x38>
movl   $0x4,-0x4(%rbp)
jmp    14d2 <main+0x322>
lea    -0x110(%rbp),%rax
mov    %rax,-0x530(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x530(%rbp),%rdi
mov    %eax,%ecx
mov    $0x100,%esi
lea    0xdee(%rip),%rdx
call   1070 <snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <unlink@plt>
lea    -0x110(%rbp),%rdi
mov    0x2dc7(%rip),%rax
mov    (%rax),%esi
mov    0x2d9e(%rip),%rax
or     (%rax),%esi
mov    0x2d6d(%rip),%rax
or     (%rax),%esi
mov    0x2d54(%rip),%rax
mov    (%rax),%edx
mov    0x2d6b(%rip),%rax
or     (%rax),%edx
call   10b0 <open@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0xffffffff,-0x114(%rbp)
jne    129a <main+0xea>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %rax,%rsi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    14d2 <main+0x322>
lea    -0x110(%rbp),%rdi
call   1030 <unlink@plt>
movl   $0x0,-0x524(%rbp)
cmpl   $0x80,-0x524(%rbp)
jge    1459 <main+0x2a9>
mov    $0x1,%edi
mov    $0x20,%esi
call   1080 <calloc@plt>
mov    %rax,%rcx
movslq -0x524(%rbp),%rax
mov    %rcx,-0x520(%rbp,%rax,8)
ff
movslq -0x524(%rbp),%rax
cmpq   $0x0,-0x520(%rbp,%rax,8)
jne    1322 <main+0x172>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %rax,%rsi
lea    0xd30(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    14d2 <main+0x322>
mov    -0x114(%rbp),%ecx
movslq -0x524(%rbp),%rax
mov    -0x520(%rbp,%rax,8),%rax
ff
mov    %ecx,(%rax)
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,%rcx
movslq -0x524(%rbp),%rax
mov    -0x520(%rbp,%rax,8),%rax
ff
mov    %rcx,0x18(%rax)
movslq -0x524(%rbp),%rax
mov    -0x520(%rbp,%rax,8),%rax
ff
cmpq   $0x0,0x18(%rax)
jne    139e <main+0x1ee>
mov    0x2c2e(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %rax,%rsi
lea    0xcb4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    14d2 <main+0x322>
movslq -0x524(%rbp),%rax
mov    -0x520(%rbp,%rax,8),%rax
ff
movl   $0x400,0x4(%rax)
movslq -0x524(%rbp),%rax
mov    -0x520(%rbp,%rax,8),%rax
ff
movq   $0x0,0x10(%rax)
mov    0x2c1e(%rip),%rax
mov    (%rax),%ecx
movslq -0x524(%rbp),%rax
mov    -0x520(%rbp,%rax,8),%rax
ff
mov    %ecx,0x8(%rax)
movslq -0x524(%rbp),%rax
mov    -0x520(%rbp,%rax,8),%rdi
ff
call   1050 <aio_write@plt>
cmp    $0xffffffff,%eax
jne    1440 <main+0x290>
mov    -0x524(%rbp),%eax
mov    %eax,-0x534(%rbp)
mov    0x2b92(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x534(%rbp),%esi
mov    %rax,%rdx
lea    0xc39(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14d2 <main+0x322>
jmp    1445 <main+0x295>
mov    -0x524(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x524(%rbp)
jmp    12b0 <main+0x100>
movl   $0x2,-0x528(%rbp)
movl   $0x0,-0x524(%rbp)
cmpl   $0x80,-0x524(%rbp)
jge    14c9 <main+0x319>
movslq -0x524(%rbp),%rax
mov    -0x520(%rbp,%rax,8),%rdi
ff
call   1090 <aio_error@plt>
mov    0x2b38(%rip),%rcx
cmp    (%rcx),%rax
jne    14b0 <main+0x300>
movl   $0x0,-0x528(%rbp)
jmp    14c9 <main+0x319>
jmp    14b5 <main+0x305>
mov    -0x524(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x524(%rbp)
jmp    146d <main+0x2bd>
mov    -0x528(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x540,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x508,%rsp
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
call   10c0 <sysconf@plt>
mov    $0x4,%ebx
cmp    $0x30db0,%rax
jl     133c <main+0x18c>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe16(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %eax,%ecx
call   1070 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    0x2ded(%rip),%rax
mov    0x2dc6(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d93(%rip),%rax
or     (%rax),%esi
mov    0x2d7a(%rip),%rax
mov    0x2d93(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %rbx,%rdi
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
je     1301 <main+0x151>
mov    %eax,%r14d
mov    %rsp,%rdi
call   1030 <unlink@plt>
xor    %ebx,%ebx
mov    0x2d9a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    $0x1,%edi
mov    $0x20,%esi
call   1080 <calloc@plt>
mov    %rax,0x100(%rsp,%rbx,8)
test   %rax,%rax
je     1318 <main+0x168>
mov    %rax,%rbp
mov    %r14d,(%rax)
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,0x18(%rbp)
test   %rax,%rax
je     1318 <main+0x168>
movl   $0x400,0x4(%rbp)
movq   $0x0,0x10(%rbp)
mov    (%r15),%eax
mov    %eax,0x8(%rbp)
mov    %rbp,%rdi
call   1050 <aio_write@plt>
cmp    $0xffffffff,%eax
je     134c <main+0x19c>
add    $0x1,%rbx
cmp    $0x80,%rbx
jne    1260 <main+0xb0>
xor    %ebx,%ebx
mov    0x2cfb(%rip),%r14
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    0x100(%rsp,%rbp,8),%rdi
call   1090 <aio_error@plt>
cmp    (%r14),%rax
je     133c <main+0x18c>
add    $0x1,%rbp
cmp    $0x80,%rbp
jne    12e0 <main+0x130>
jmp    1337 <main+0x187>
mov    0x2ca0(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd04(%rip),%rdi
jmp    132d <main+0x17d>
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd12(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x2,%ebx
mov    %ebx,%eax
add    $0x508,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd05(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%ebx
jmp    133c <main+0x18c>

LLVM IR (-O0):
%struct.aiocb = type { i32, i32, %struct.TYPE_2__, i64, i32* }
%struct.TYPE_2__ = type { i32 }
@_SC_ASYNCHRONOUS_IO = global i32 0
@.str = [26 x i8] c"/tmp/pts_aio_error_2_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_error/2-1.c Error at open(): %s\0A\00"
@errno = global i32 0
@.str.2 = [39 x i8] c"aio_error/2-1.c Error at malloc(): %s\0A\00"
@SIGEV_NONE = global i32 0
@.str.3 = [51 x i8] c"aio_error/2-1.c loop %d: Error at aio_write(): %s\0A\00"
@EINPROGRESS = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = alloca [128 x %struct.aiocb*]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = load i32, i32* @_SC_ASYNCHRONOUS_IO
%8 = call i64 @sysconf(i32 %7)
%9 = icmp slt i64 %8, 200112
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 4, i32* %1
br label %129
11: ; preds = %0
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%13 = call i32 (...) @getpid()
%14 = call i32 @snprintf(i8* %12, i32 256, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%16 = call i32 @unlink(i8* %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%18 = load i32, i32* @O_CREAT
%19 = load i32, i32* @O_RDWR
%20 = or i32 %18, %19
%21 = load i32, i32* @O_EXCL
%22 = or i32 %20, %21
%23 = load i32, i32* @S_IRUSR
%24 = load i32, i32* @S_IWUSR
%25 = or i32 %23, %24
%26 = call i32 @open(i8* %17, i32 %22, i32 %25)
store i32 %26, i32* %3
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %33
29: ; preds = %11
%30 = load i32, i32* @errno
%31 = call i8* @strerror(i32 %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %31)
store i32 2, i32* %1
br label %129
33: ; preds = %11
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%35 = call i32 @unlink(i8* %34)
store i32 0, i32* %5
br label %36
36: ; preds = %107, %33
%37 = load i32, i32* %5
%38 = icmp slt i32 %37, 128
br i1 %38, label %39, label %110
39: ; preds = %36
%40 = call %struct.aiocb* @calloc(i32 1, i32 32)
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [128 x %struct.aiocb*], [128 x %struct.aiocb*]* %4, i64 0, i64 %42
store %struct.aiocb* %40, %struct.aiocb** %43
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [128 x %struct.aiocb*], [128 x %struct.aiocb*]* %4, i64 0, i64 %45
%47 = load %struct.aiocb*, %struct.aiocb** %46
%48 = icmp eq %struct.aiocb* %47, null
br i1 %48, label %49, label %53
49: ; preds = %39
%50 = load i32, i32* @errno
%51 = call i8* @strerror(i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %51)
store i32 2, i32* %1
br label %129
53: ; preds = %39
%54 = load i32, i32* %3
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [128 x %struct.aiocb*], [128 x %struct.aiocb*]* %4, i64 0, i64 %56
%58 = load %struct.aiocb*, %struct.aiocb** %57
%59 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %58, i32 0, i32 0
store i32 %54, i32* %59
%60 = call i32* @malloc(i32 1024)
%61 = load i32, i32* %5
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [128 x %struct.aiocb*], [128 x %struct.aiocb*]* %4, i64 0, i64 %62
%64 = load %struct.aiocb*, %struct.aiocb** %63
%65 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %64, i32 0, i32 4
store i32* %60, i32** %65
%66 = load i32, i32* %5
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [128 x %struct.aiocb*], [128 x %struct.aiocb*]* %4, i64 0, i64 %67
%69 = load %struct.aiocb*, %struct.aiocb** %68
%70 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %69, i32 0, i32 4
%71 = load i32*, i32** %70
%72 = icmp eq i32* %71, null
br i1 %72, label %73, label %77
73: ; preds = %53
%74 = load i32, i32* @errno
%75 = call i8* @strerror(i32 %74)
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %75)
store i32 2, i32* %1
br label %129
77: ; preds = %53
%78 = load i32, i32* %5
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [128 x %struct.aiocb*], [128 x %struct.aiocb*]* %4, i64 0, i64 %79
%81 = load %struct.aiocb*, %struct.aiocb** %80
%82 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %81, i32 0, i32 1
store i32 1024, i32* %82
%83 = load i32, i32* %5
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [128 x %struct.aiocb*], [128 x %struct.aiocb*]* %4, i64 0, i64 %84
%86 = load %struct.aiocb*, %struct.aiocb** %85
%87 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %86, i32 0, i32 3
store i64 0, i64* %87
%88 = load i32, i32* @SIGEV_NONE
%89 = load i32, i32* %5
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [128 x %struct.aiocb*], [128 x %struct.aiocb*]* %4, i64 0, i64 %90
%92 = load %struct.aiocb*, %struct.aiocb** %91
%93 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %92, i32 0, i32 2
%94 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %93, i32 0, i32 0
store i32 %88, i32* %94
%95 = load i32, i32* %5
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [128 x %struct.aiocb*], [128 x %struct.aiocb*]* %4, i64 0, i64 %96
%98 = load %struct.aiocb*, %struct.aiocb** %97
%99 = call i32 @aio_write(%struct.aiocb* %98)
%100 = icmp eq i32 %99, -1
br i1 %100, label %101, label %106
101: ; preds = %77
%102 = load i32, i32* %5
%103 = load i32, i32* @errno
%104 = call i8* @strerror(i32 %103)
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i32 %102, i8* %104)
store i32 1, i32* %1
br label %129
106: ; preds = %77
br label %107
107: ; preds = %106
%108 = load i32, i32* %5
%109 = add nsw i32 %108, 1
store i32 %109, i32* %5
br label %36
110: ; preds = %36
store i32 2, i32* %6
store i32 0, i32* %5
br label %111
111: ; preds = %124, %110
%112 = load i32, i32* %5
%113 = icmp slt i32 %112, 128
br i1 %113, label %114, label %127
114: ; preds = %111
%115 = load i32, i32* %5
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [128 x %struct.aiocb*], [128 x %struct.aiocb*]* %4, i64 0, i64 %116
%118 = load %struct.aiocb*, %struct.aiocb** %117
%119 = call i64 @aio_error(%struct.aiocb* %118)
%120 = load i64, i64* @EINPROGRESS
%121 = icmp eq i64 %119, %120
br i1 %121, label %122, label %123
122: ; preds = %114
store i32 0, i32* %6
br label %127
123: ; preds = %114
br label %124
124: ; preds = %123
%125 = load i32, i32* %5
%126 = add nsw i32 %125, 1
store i32 %126, i32* %5
br label %111
127: ; preds = %122, %111
%128 = load i32, i32* %6
store i32 %128, i32* %1
br label %129
129: ; preds = %127, %101, %73, %49, %29, %10
%130 = load i32, i32* %1
ret i32 %130
}

LLVM IR (-O2):
%struct.aiocb = type { i32, i32, %struct.TYPE_2__, i64, i32* }
%struct.TYPE_2__ = type { i32 }
@_SC_ASYNCHRONOUS_IO = global i32 0
@.str = [26 x i8] c"/tmp/pts_aio_error_2_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_error/2-1.c Error at open(): %s\0A\00"
@errno = global i32 0
@.str.2 = [39 x i8] c"aio_error/2-1.c Error at malloc(): %s\0A\00"
@SIGEV_NONE = global i32 0
@.str.3 = [51 x i8] c"aio_error/2-1.c loop %d: Error at aio_write(): %s\0A\00"
@EINPROGRESS = global i64 0
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [128 x %struct.aiocb*]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = bitcast [128 x %struct.aiocb*]* %2 to i8*
%5 = load i32, i32* @_SC_ASYNCHRONOUS_IO
%6 = tail call i64 @sysconf(i32 %5)
%7 = icmp slt i64 %6, 200112
br i1 %7, label %71, label %8
8: ; preds = %0
%9 = tail call i32 (...) @getpid()
%10 = call i32 @snprintf(i8* %3, i32 256, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @unlink(i8* %3)
%12 = load i32, i32* @O_CREAT
%13 = load i32, i32* @O_RDWR
%14 = or i32 %13, %12
%15 = load i32, i32* @O_EXCL
%16 = or i32 %14, %15
%17 = load i32, i32* @S_IRUSR
%18 = load i32, i32* @S_IWUSR
%19 = or i32 %18, %17
%20 = call i32 @open(i8* %3, i32 %16, i32 %19)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %26
22: ; preds = %8
%23 = load i32, i32* @errno
%24 = call i8* @strerror(i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %71
26: ; preds = %8
%27 = call i32 @unlink(i8* %3)
br label %28
28: ; preds = %26, %58
%29 = phi i64 [ 0, %26 ], [ %59, %58 ]
%30 = call %struct.aiocb* @calloc(i32 1, i32 32)
%31 = getelementptr inbounds [128 x %struct.aiocb*], [128 x %struct.aiocb*]* %2, i64 0, i64 %29
store %struct.aiocb* %30, %struct.aiocb** %31
%32 = icmp eq %struct.aiocb* %30, null
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load i32, i32* @errno
%35 = call i8* @strerror(i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %35)
br label %71
37: ; preds = %28
%38 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %30, i64 0, i32 0
store i32 %20, i32* %38
%39 = call i32* @malloc(i32 1024)
%40 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %30, i64 0, i32 4
store i32* %39, i32** %40
%41 = icmp eq i32* %39, null
br i1 %41, label %42, label %46
42: ; preds = %37
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %44)
br label %71
46: ; preds = %37
%47 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %30, i64 0, i32 1
store i32 1024, i32* %47
%48 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %30, i64 0, i32 3
store i64 0, i64* %48
%49 = load i32, i32* @SIGEV_NONE
%50 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %30, i64 0, i32 2, i32 0
store i32 %49, i32* %50
%51 = call i32 @aio_write(%struct.aiocb* %30)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %58
53: ; preds = %46
%54 = trunc i64 %29 to i32
%55 = load i32, i32* @errno
%56 = call i8* @strerror(i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i32 %54, i8* %56)
br label %71
58: ; preds = %46
%59 = add nuw nsw i64 %29, 1
%60 = icmp eq i64 %59, 128
br i1 %60, label %64, label %28
61: ; preds = %64
%62 = add nuw nsw i64 %65, 1
%63 = icmp eq i64 %62, 128
br i1 %63, label %71, label %64
64: ; preds = %58, %61
%65 = phi i64 [ %62, %61 ], [ 0, %58 ]
%66 = getelementptr inbounds [128 x %struct.aiocb*], [128 x %struct.aiocb*]* %2, i64 0, i64 %65
%67 = load %struct.aiocb*, %struct.aiocb** %66
%68 = call i64 @aio_error(%struct.aiocb* %67)
%69 = load i64, i64* @EINPROGRESS
%70 = icmp eq i64 %68, %69
br i1 %70, label %71, label %61
71: ; preds = %61, %64, %0, %53, %42, %33, %22
%72 = phi i32 [ 2, %22 ], [ 2, %33 ], [ 2, %42 ], [ 1, %53 ], [ 4, %0 ], [ 0, %64 ], [ 2, %61 ]
ret i32 %72
}