#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 */
struct timespec {
  int tv_sec;
  scalar_t__ tv_nsec;
};
struct TYPE_2__ {
  void *sigev_notify;
};
struct aiocb {
  int aio_fildes;
  char *aio_buf;
  int aio_nbytes;
  TYPE_1__ aio_sigevent;
  scalar_t__ aio_reqprio;
  scalar_t__ aio_offset;
};

/* Variables and functions */
scalar_t__ EAGAIN;
scalar_t__ EBADF;
scalar_t__ EINPROGRESS;
scalar_t__ ENOSYS;
int /*<<< orphan*/ O_SYNC;
void *SIGEV_NONE;
int aio_cancel(int, struct aiocb *);
scalar_t__ aio_error(struct aiocb *);
int aio_fsync(int /*<<< orphan*/, struct aiocb *);
int aio_read(struct aiocb *);
int aio_suspend(struct aiocb const *const *, int const, struct timespec *);
scalar_t__ errno;
int /*<<< orphan*/ error(int, scalar_t__, char *);
int mkstemp(char *);
int /*<<< orphan*/ perror(char *);
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
scalar_t__ unlink(char *);
int /*<<< orphan*/ usleep(int);
int write(int, char *, int);
int do_test(void) {
  int result = 0;
  int piped[2];
  if (pipe(piped) < 0) {
    perror("pipe");
    return 1;
  }
  {
    struct aiocb cb;
    int fd = -1;
    cb.aio_fildes = fd;
    cb.aio_offset = 0;
    cb.aio_buf = NULL;
    cb.aio_nbytes = 0;
    cb.aio_reqprio = 0;
    cb.aio_sigevent.sigev_notify = SIGEV_NONE;
    errno = 0;
    if (aio_cancel(fd, &cb) != -1 || errno != EBADF) {
      if (errno == ENOSYS) {
        puts("no aio support in this configuration");
        return 0;
      }
      puts("aio_cancel( -1, {-1..} ) did not return -1 or errno != EBADF");
      ++result;
    }
    cb.aio_fildes = -2;
    errno = 0;
    if (aio_cancel(fd, &cb) != -1 || errno != EBADF)
      puts("aio_cancel( -1, {-2..} ) did not return -1 or errno != EBADF");
  }
  {
    struct aiocb cb;
    int fd = -1;
    cb.aio_fildes = fd;
    cb.aio_offset = 0;
    cb.aio_buf = NULL;
    cb.aio_nbytes = 0;
    cb.aio_reqprio = 0;
    cb.aio_sigevent.sigev_notify = SIGEV_NONE;
    errno = 0;
    if (aio_fsync(O_SYNC, &cb) != -1 || errno != EBADF) {
      puts("aio_fsync( op, {-1..} ) did not return -1 or errno != EBADF");
      ++result;
    }
  }
  {
    const int ELEMS = 2;
    int i, r, fd;
    static char buff[8];
    char name[] = "/tmp/aio7.XXXXXX";
    struct timespec timeout;
    static struct aiocb cb0, cb1;
    struct aiocb *list[ELEMS];
    fd = mkstemp(name);
    if (fd < 0)
      error(1, errno, "creating temp file");
    if (unlink(name))
      error(1, errno, "unlinking temp file");
    if (write(fd, "01234567", 8) != 8)
      error(1, errno, "writing to temp file");
    cb0.aio_fildes = fd;
    cb0.aio_offset = 0;
    cb0.aio_buf = buff;
    cb0.aio_nbytes = 8;
    cb0.aio_reqprio = 0;
    cb0.aio_sigevent.sigev_notify = SIGEV_NONE;
    r = aio_read(&cb0);
    if (r != 0)
      error(1, errno, "reading from file");
    while (aio_error(&(cb0)) == EINPROGRESS)
      usleep(10);
    for (i = 0; i < 8; i++)
      printf("%c ", buff[i]);
    printf("\n");
    cb1.aio_fildes = piped[0];
    cb1.aio_offset = 0;
    cb1.aio_buf = buff;
    cb1.aio_nbytes = 8;
    cb1.aio_reqprio = 0;
    cb1.aio_sigevent.sigev_notify = SIGEV_NONE;
    r = aio_read(&cb1);
    if (r != 0)
      error(1, errno, "reading from file");
    list[0] = &cb0;
    list[1] = &cb1;
    timeout.tv_sec = 3;
    timeout.tv_nsec = 0;
    r = aio_suspend((const struct aiocb *const *)list, ELEMS, &timeout);
    if (r == -1 && errno == EAGAIN) {
      puts("aio_suspend([done,blocked],2,3) suspended thread");
      ++result;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
call   1080 <pipe@plt>
cmp    $0x0,%rax
jge    121d <do_test+0x3d>
lea    0xdf4(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    16be <do_test+0x4de>
movl   $0xffffffff,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x40(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x30(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2da8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2d62(%rip),%rax
movq   $0x0,(%rax)
mov    -0x44(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   1070 <aio_cancel@plt>
cmp    $0xffffffff,%eax
jne    1294 <do_test+0xb4>
mov    0x2d3f(%rip),%rax
mov    (%rax),%rax
mov    0x2d2d(%rip),%rcx
cmp    (%rcx),%rax
je     12db <do_test+0xfb>
mov    0x2d25(%rip),%rax
mov    (%rax),%rax
mov    0x2d2b(%rip),%rcx
cmp    (%rcx),%rax
jne    12c6 <do_test+0xe6>
lea    0xd50(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    16be <do_test+0x4de>
lea    0xd5d(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0xfffffffe,-0x40(%rbp)
mov    0x2cd7(%rip),%rax
movq   $0x0,(%rax)
mov    -0x44(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   1070 <aio_cancel@plt>
cmp    $0xffffffff,%eax
jne    131f <do_test+0x13f>
mov    0x2cb4(%rip),%rax
mov    (%rax),%rax
mov    0x2ca2(%rip),%rcx
cmp    (%rcx),%rax
je     132b <do_test+0x14b>
lea    0xd41(%rip),%rdi
call   1040 <puts@plt>
movl   $0xffffffff,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,-0x78(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x70(%rbp)
movl   $0x0,-0x68(%rbp)
movq   $0x0,-0x58(%rbp)
mov    0x2c9a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
mov    0x2c54(%rip),%rax
movq   $0x0,(%rax)
mov    0x2c66(%rip),%rax
mov    (%rax),%edi
lea    -0x78(%rbp),%rsi
call   10d0 <aio_fsync@plt>
cmp    $0xffffffff,%eax
jne    13a8 <do_test+0x1c8>
mov    0x2c2b(%rip),%rax
mov    (%rax),%rax
mov    0x2c19(%rip),%rcx
cmp    (%rcx),%rax
je     13bd <do_test+0x1dd>
lea    0xcf5(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x2,-0x80(%rbp)
movaps 0xda5(%rip),%xmm0
movaps %xmm0,-0xa0(%rbp)
movb   $0x0,-0x90(%rbp)
mov    %rsp,%rax
mov    %rax,-0xb8(%rbp)
mov    %rsp,%rax
add    $0xfffffffffffffff0,%rax
mov    %rax,-0xc0(%rbp)
mov    %rax,%rsp
lea    -0xa0(%rbp),%rdi
call   10c0 <mkstemp@plt>
mov    %eax,-0x8c(%rbp)
cmpl   $0x0,-0x8c(%rbp)
jge    142e <do_test+0x24e>
mov    0x2ba6(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xcb7(%rip),%rdx
call   10e0 <error@plt>
lea    -0xa0(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     145f <do_test+0x27f>
mov    0x2b75(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc99(%rip),%rdx
call   10e0 <error@plt>
mov    -0x8c(%rbp),%edi
lea    0xc9b(%rip),%rsi
mov    $0x8,%edx
call   1050 <write@plt>
cmp    $0x8,%eax
je     149a <do_test+0x2ba>
mov    0x2b3a(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc7b(%rip),%rdx
call   10e0 <error@plt>
mov    -0x8c(%rbp),%eax
mov    %eax,0x2c22(%rip)
movq   $0x0,0x2c3f(%rip)
lea    0x2c04(%rip),%rax
mov    %rax,0x2c11(%rip)
movl   $0x8,0x2c0f(%rip)
movq   $0x0,0x2c14(%rip)
mov    0x2b1d(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x2bfb(%rip)
lea    0x2bdc(%rip),%rdi
call   1090 <aio_read@plt>
mov    %eax,-0x88(%rbp)
cmpl   $0x0,-0x88(%rbp)
je     151f <do_test+0x33f>
mov    0x2ab5(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc0b(%rip),%rdx
call   10e0 <error@plt>
jmp    1524 <do_test+0x344>
lea    0x2b9d(%rip),%rdi
call   10a0 <aio_error@plt>
mov    0x2aa1(%rip),%rcx
cmp    (%rcx),%rax
jne    154f <do_test+0x36f>
mov    $0xa,%edi
call   1100 <usleep@plt>
jmp    1524 <do_test+0x344>
movl   $0x0,-0x84(%rbp)
cmpl   $0x8,-0x84(%rbp)
jge    159a <do_test+0x3ba>
movslq -0x84(%rbp),%rcx
lea    0x2b48(%rip),%rax
movsbl (%rax,%rcx,1),%esi
lea    0xbb8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1559 <do_test+0x379>
lea    0xb9a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,0x2b47(%rip)
movq   $0x0,0x2b64(%rip)
lea    0x2af9(%rip),%rax
mov    %rax,0x2b36(%rip)
movl   $0x8,0x2b34(%rip)
movq   $0x0,0x2b39(%rip)
mov    0x2a12(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x2b20(%rip)
lea    0x2b01(%rip),%rdi
call   1090 <aio_read@plt>
mov    %eax,-0x88(%rbp)
cmpl   $0x0,-0x88(%rbp)
je     162a <do_test+0x44a>
mov    0x29aa(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xb00(%rip),%rdx
call   10e0 <error@plt>
mov    -0xc0(%rbp),%rdi
lea    0x2a90(%rip),%rax
mov    %rax,(%rdi)
lea    0x2ab6(%rip),%rax
mov    %rax,0x8(%rdi)
movl   $0x3,-0xb0(%rbp)
movq   $0x0,-0xa8(%rbp)
mov    $0x2,%esi
lea    -0xb0(%rbp),%rdx
call   10b0 <aio_suspend@plt>
mov    %eax,-0x88(%rbp)
cmpl   $0xffffffff,-0x88(%rbp)
jne    16ae <do_test+0x4ce>
mov    0x293a(%rip),%rax
mov    (%rax),%rax
mov    0x2918(%rip),%rcx
cmp    (%rcx),%rax
jne    16ae <do_test+0x4ce>
lea    0xa9d(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xb8(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    -0x70(%rbp),%rdi
call   1090 <pipe@plt>
test   %rax,%rax
js     15bf <do_test+0x3cf>
movl   $0xffffffff,-0x60(%rbp)
movq   $0x0,-0x58(%rbp)
movl   $0x0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movups %xmm0,-0x40(%rbp)
mov    0x2dc1(%rip),%r15
mov    (%r15),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d7b(%rip),%r13
movq   $0x0,0x0(%r13)
lea    -0x60(%rbp),%rsi
mov    $0xffffffff,%edi
call   1080 <aio_cancel@plt>
mov    0x0(%r13),%rcx
mov    0x2d52(%rip),%rbx
cmp    $0xffffffff,%eax
jne    1273 <do_test+0x83>
xor    %r14d,%r14d
cmp    (%rbx),%rcx
je     12a5 <do_test+0xb5>
mov    0x2d56(%rip),%rax
cmp    (%rax),%rcx
jne    1293 <do_test+0xa3>
lea    0xd7f(%rip),%rdi
call   1050 <puts@plt>
xor    %r14d,%r14d
jmp    15ad <do_test+0x3bd>
lea    0xd90(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%r14d
movl   $0xfffffffe,-0x60(%rbp)
movq   $0x0,0x0(%r13)
lea    -0x60(%rbp),%rsi
mov    $0xffffffff,%edi
call   1080 <aio_cancel@plt>
cmp    $0xffffffff,%eax
jne    12d0 <do_test+0xe0>
mov    0x0(%r13),%rax
cmp    (%rbx),%rax
je     12dc <do_test+0xec>
lea    0xd90(%rip),%rdi
call   1050 <puts@plt>
movl   $0xffffffff,-0x60(%rbp)
movq   $0x0,-0x58(%rbp)
movl   $0x0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movups %xmm0,-0x40(%rbp)
mov    (%r15),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,0x0(%r13)
mov    0x2cd1(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
call   10e0 <aio_fsync@plt>
cmp    $0xffffffff,%eax
jne    1328 <do_test+0x138>
mov    0x0(%r13),%rax
cmp    (%rbx),%rax
je     1338 <do_test+0x148>
lea    0xd75(%rip),%rdi
call   1050 <puts@plt>
add    $0x1,%r14d
mov    %rsp,-0x68(%rbp)
movaps 0xe2d(%rip),%xmm0
movaps %xmm0,-0x60(%rbp)
movb   $0x0,-0x50(%rbp)
mov    %rsp,%r12
add    $0xfffffffffffffff0,%r12
mov    %r12,%rsp
lea    -0x60(%rbp),%rdi
call   10d0 <mkstemp@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1379 <do_test+0x189>
mov    0x0(%r13),%rsi
lea    0xd71(%rip),%rdx
mov    $0x1,%edi
call   10f0 <error@plt>
lea    -0x60(%rbp),%rdi
call   1040 <unlink@plt>
test   %rax,%rax
je     139c <do_test+0x1ac>
mov    0x0(%r13),%rsi
lea    0xd61(%rip),%rdx
mov    $0x1,%edi
call   10f0 <error@plt>
lea    0xd64(%rip),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   1060 <write@plt>
cmp    $0x8,%eax
je     13c9 <do_test+0x1d9>
mov    0x0(%r13),%rsi
lea    0xd51(%rip),%rdx
mov    $0x1,%edi
call   10f0 <error@plt>
mov    %ebx,0x2d01(%rip)
lea    0x2cfa(%rip),%rdi
lea    0x2ce7(%rip),%rax
mov    %rax,0x2cf4(%rip)
movl   $0x8,0x2cf2(%rip)
xorps  %xmm0,%xmm0
movups %xmm0,0x2cf8(%rip)
mov    (%r15),%rax
mov    %rax,0x2ce6(%rip)
call   10a0 <aio_read@plt>
test   %eax,%eax
je     1420 <do_test+0x230>
mov    0x0(%r13),%rsi
lea    0xd0f(%rip),%rdx
mov    $0x1,%edi
call   10f0 <error@plt>
lea    0x2ca9(%rip),%rdi
call   10b0 <aio_error@plt>
mov    0x2ba5(%rip),%r15
cmp    (%r15),%rax
jne    1457 <do_test+0x267>
lea    0x2c91(%rip),%rbx
nop
mov    $0xa,%edi
call   1110 <usleep@plt>
mov    %rbx,%rdi
call   10b0 <aio_error@plt>
cmp    (%r15),%rax
je     1440 <do_test+0x250>
movsbl 0x2c66(%rip),%esi
lea    0xcd2(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2c4f(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2c3f(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2c2f(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2c1f(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2c0f(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2bff(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2bef(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x70(%rbp),%eax
mov    %eax,0x2c07(%rip)
lea    0x2c00(%rip),%rbx
lea    0x2bbd(%rip),%rax
mov    %rax,0x2bfa(%rip)
movl   $0x8,0x2bf8(%rip)
xorps  %xmm0,%xmm0
movups %xmm0,0x2bfe(%rip)
mov    0x2acf(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x2be5(%rip)
mov    %rbx,%rdi
call   10a0 <aio_read@plt>
test   %eax,%eax
je     1554 <do_test+0x364>
mov    0x0(%r13),%rsi
lea    0xbdb(%rip),%rdx
mov    $0x1,%edi
call   10f0 <error@plt>
lea    0x2b75(%rip),%rax
mov    %rax,(%r12)
mov    %rbx,0x8(%r12)
movl   $0x3,-0x80(%rbp)
movq   $0x0,-0x78(%rbp)
lea    -0x80(%rbp),%rdx
mov    %r12,%rdi
mov    $0x2,%esi
call   10c0 <aio_suspend@plt>
cmp    $0xffffffff,%eax
jne    15a9 <do_test+0x3b9>
mov    0x0(%r13),%rax
mov    0x2a14(%rip),%rcx
cmp    (%rcx),%rax
jne    15a9 <do_test+0x3b9>
lea    0xb9b(%rip),%rdi
call   1050 <puts@plt>
add    $0x1,%r14d
mov    -0x68(%rbp),%rsp
mov    %r14d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xa3a(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%r14d
jmp    15ad <do_test+0x3bd>

LLVM IR (-O0):
%struct.aiocb = type { i32, i8*, i32, %struct.TYPE_2__, i64, i64 }
%struct.TYPE_2__ = type { i8* }
%struct.timespec = type { i32, i64 }
@.str = [5 x i8] c"pipe\00"
@SIGEV_NONE = global i8* null
@errno = global i64 0
@EBADF = global i64 0
@ENOSYS = global i64 0
@.str.1 = [37 x i8] c"no aio support in this configuration\00"
@.str.2 = [61 x i8] c"aio_cancel( -1, {-1..} ) did not return -1 or errno != EBADF\00"
@.str.3 = [61 x i8] c"aio_cancel( -1, {-2..} ) did not return -1 or errno != EBADF\00"
@O_SYNC = global i32 0
@.str.4 = [60 x i8] c"aio_fsync( op, {-1..} ) did not return -1 or errno != EBADF\00"
@do_test.buff = internal global [8 x i8] zeroinitializer
@__const.do_test.name = [17 x i8] c"/tmp/aio7.XXXXXX\00"
@do_test.cb0 = internal global %struct.aiocb zeroinitializer
@do_test.cb1 = internal global %struct.aiocb zeroinitializer
@.str.5 = [19 x i8] c"creating temp file\00"
@.str.6 = [20 x i8] c"unlinking temp file\00"
@.str.7 = [9 x i8] c"01234567\00"
@.str.8 = [21 x i8] c"writing to temp file\00"
@.str.9 = [18 x i8] c"reading from file\00"
@EINPROGRESS = global i64 0
@.str.10 = [4 x i8] c"%c \00"
@.str.11 = [2 x i8] c"\0A\00"
@EAGAIN = global i64 0
@.str.12 = [49 x i8] c"aio_suspend([done,blocked],2,3) suspended thread\00"
define i32 @do_test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [2 x i32]
%4 = alloca %struct.aiocb
%5 = alloca i32
%6 = alloca %struct.aiocb
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [17 x i8]
%13 = alloca %struct.timespec
%14 = alloca i8*
store i32 0, i32* %2
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%16 = call i64 @pipe(i32* %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %0
%19 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %164
20: ; preds = %0
store i32 -1, i32* %5
%21 = load i32, i32* %5
%22 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %4, i32 0, i32 0
store i32 %21, i32* %22
%23 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %4, i32 0, i32 5
store i64 0, i64* %23
%24 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %4, i32 0, i32 1
store i8* null, i8** %24
%25 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %4, i32 0, i32 2
store i32 0, i32* %25
%26 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %4, i32 0, i32 4
store i64 0, i64* %26
%27 = load i8*, i8** @SIGEV_NONE
%28 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %4, i32 0, i32 3
%29 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %28, i32 0, i32 0
store i8* %27, i8** %29
store i64 0, i64* @errno
%30 = load i32, i32* %5
%31 = call i32 @aio_cancel(i32 %30, %struct.aiocb* %4)
%32 = icmp ne i32 %31, -1
br i1 %32, label %37, label %33
33: ; preds = %20
%34 = load i64, i64* @errno
%35 = load i64, i64* @EBADF
%36 = icmp ne i64 %34, %35
br i1 %36, label %37, label %47
37: ; preds = %33, %20
%38 = load i64, i64* @errno
%39 = load i64, i64* @ENOSYS
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 @puts(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %164
43: ; preds = %37
%44 = call i32 @puts(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%45 = load i32, i32* %2
%46 = add nsw i32 %45, 1
store i32 %46, i32* %2
br label %47
47: ; preds = %43, %33
%48 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %4, i32 0, i32 0
store i32 -2, i32* %48
store i64 0, i64* @errno
%49 = load i32, i32* %5
%50 = call i32 @aio_cancel(i32 %49, %struct.aiocb* %4)
%51 = icmp ne i32 %50, -1
br i1 %51, label %56, label %52
52: ; preds = %47
%53 = load i64, i64* @errno
%54 = load i64, i64* @EBADF
%55 = icmp ne i64 %53, %54
br i1 %55, label %56, label %58
56: ; preds = %52, %47
%57 = call i32 @puts(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.3, i64 0, i64 0))
br label %58
58: ; preds = %56, %52
store i32 -1, i32* %7
%59 = load i32, i32* %7
%60 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %6, i32 0, i32 0
store i32 %59, i32* %60
%61 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %6, i32 0, i32 5
store i64 0, i64* %61
%62 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %6, i32 0, i32 1
store i8* null, i8** %62
%63 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %6, i32 0, i32 2
store i32 0, i32* %63
%64 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %6, i32 0, i32 4
store i64 0, i64* %64
%65 = load i8*, i8** @SIGEV_NONE
%66 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %6, i32 0, i32 3
%67 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %66, i32 0, i32 0
store i8* %65, i8** %67
store i64 0, i64* @errno
%68 = load i32, i32* @O_SYNC
%69 = call i32 @aio_fsync(i32 %68, %struct.aiocb* %6)
%70 = icmp ne i32 %69, -1
br i1 %70, label %75, label %71
71: ; preds = %58
%72 = load i64, i64* @errno
%73 = load i64, i64* @EBADF
%74 = icmp ne i64 %72, %73
br i1 %74, label %75, label %79
75: ; preds = %71, %58
%76 = call i32 @puts(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0))
%77 = load i32, i32* %2
%78 = add nsw i32 %77, 1
store i32 %78, i32* %2
br label %79
79: ; preds = %75, %71
store i32 2, i32* %8
%80 = bitcast [17 x i8]* %12 to i8*
%81 = call i8* @llvm.stacksave()
store i8* %81, i8** %14
%82 = alloca %struct.aiocb*, i64 2
%83 = getelementptr inbounds [17 x i8], [17 x i8]* %12, i64 0, i64 0
%84 = call i32 @mkstemp(i8* %83)
store i32 %84, i32* %11
%85 = load i32, i32* %11
%86 = icmp slt i32 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %79
%88 = load i64, i64* @errno
%89 = call i32 @error(i32 1, i64 %88, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %90
90: ; preds = %87, %79
%91 = getelementptr inbounds [17 x i8], [17 x i8]* %12, i64 0, i64 0
%92 = call i64 @unlink(i8* %91)
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %97
94: ; preds = %90
%95 = load i64, i64* @errno
%96 = call i32 @error(i32 1, i64 %95, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %97
97: ; preds = %94, %90
%98 = load i32, i32* %11
%99 = call i32 @write(i32 %98, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 8)
%100 = icmp ne i32 %99, 8
br i1 %100, label %101, label %104
101: ; preds = %97
%102 = load i64, i64* @errno
%103 = call i32 @error(i32 1, i64 %102, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
br label %104
104: ; preds = %101, %97
%105 = load i32, i32* %11
store i32 %105, i32* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb0, i32 0, i32 0)
store i64 0, i64* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb0, i32 0, i32 5)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 0), i8** getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb0, i32 0, i32 1)
store i32 8, i32* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb0, i32 0, i32 2)
store i64 0, i64* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb0, i32 0, i32 4)
%106 = load i8*, i8** @SIGEV_NONE
store i8* %106, i8** getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb0, i32 0, i32 3, i32 0)
%107 = call i32 @aio_read(%struct.aiocb* @do_test.cb0)
store i32 %107, i32* %10
%108 = load i32, i32* %10
%109 = icmp ne i32 %108, 0
br i1 %109, label %110, label %113
110: ; preds = %104
%111 = load i64, i64* @errno
%112 = call i32 @error(i32 1, i64 %111, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %113
113: ; preds = %110, %104
br label %114
114: ; preds = %118, %113
%115 = call i64 @aio_error(%struct.aiocb* @do_test.cb0)
%116 = load i64, i64* @EINPROGRESS
%117 = icmp eq i64 %115, %116
br i1 %117, label %118, label %120
118: ; preds = %114
%119 = call i32 @usleep(i32 10)
br label %114
120: ; preds = %114
store i32 0, i32* %9
br label %121
121: ; preds = %131, %120
%122 = load i32, i32* %9
%123 = icmp slt i32 %122, 8
br i1 %123, label %124, label %134
124: ; preds = %121
%125 = load i32, i32* %9
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 %126
%128 = load i8, i8* %127
%129 = sext i8 %128 to i32
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %129)
br label %131
131: ; preds = %124
%132 = load i32, i32* %9
%133 = add nsw i32 %132, 1
store i32 %133, i32* %9
br label %121
134: ; preds = %121
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%136 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%137 = load i32, i32* %136
store i32 %137, i32* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb1, i32 0, i32 0)
store i64 0, i64* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb1, i32 0, i32 5)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 0), i8** getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb1, i32 0, i32 1)
store i32 8, i32* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb1, i32 0, i32 2)
store i64 0, i64* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb1, i32 0, i32 4)
%138 = load i8*, i8** @SIGEV_NONE
store i8* %138, i8** getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb1, i32 0, i32 3, i32 0)
%139 = call i32 @aio_read(%struct.aiocb* @do_test.cb1)
store i32 %139, i32* %10
%140 = load i32, i32* %10
%141 = icmp ne i32 %140, 0
br i1 %141, label %142, label %145
142: ; preds = %134
%143 = load i64, i64* @errno
%144 = call i32 @error(i32 1, i64 %143, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %145
145: ; preds = %142, %134
%146 = getelementptr inbounds %struct.aiocb*, %struct.aiocb** %82, i64 0
store %struct.aiocb* @do_test.cb0, %struct.aiocb** %146
%147 = getelementptr inbounds %struct.aiocb*, %struct.aiocb** %82, i64 1
store %struct.aiocb* @do_test.cb1, %struct.aiocb** %147
%148 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 0
store i32 3, i32* %148
%149 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 1
store i64 0, i64* %149
%150 = call i32 @aio_suspend(%struct.aiocb** %82, i32 2, %struct.timespec* %13)
store i32 %150, i32* %10
%151 = load i32, i32* %10
%152 = icmp eq i32 %151, -1
br i1 %152, label %153, label %161
153: ; preds = %145
%154 = load i64, i64* @errno
%155 = load i64, i64* @EAGAIN
%156 = icmp eq i64 %154, %155
br i1 %156, label %157, label %161
157: ; preds = %153
%158 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.12, i64 0, i64 0))
%159 = load i32, i32* %2
%160 = add nsw i32 %159, 1
store i32 %160, i32* %2
br label %161
161: ; preds = %157, %153, %145
%162 = load i8*, i8** %14
%163 = load i32, i32* %2
store i32 %163, i32* %1
br label %164
164: ; preds = %161, %41, %18
%165 = load i32, i32* %1
ret i32 %165
}

LLVM IR (-O2):
%struct.aiocb = type { i32, i8*, i32, %struct.TYPE_2__, i64, i64 }
%struct.TYPE_2__ = type { i8* }
%struct.timespec = type { i32, i64 }
@.str = [5 x i8] c"pipe\00"
@SIGEV_NONE = global i8* null
@errno = global i64 0
@EBADF = global i64 0
@ENOSYS = global i64 0
@.str.1 = [37 x i8] c"no aio support in this configuration\00"
@.str.2 = [61 x i8] c"aio_cancel( -1, {-1..} ) did not return -1 or errno != EBADF\00"
@.str.3 = [61 x i8] c"aio_cancel( -1, {-2..} ) did not return -1 or errno != EBADF\00"
@O_SYNC = global i32 0
@.str.4 = [60 x i8] c"aio_fsync( op, {-1..} ) did not return -1 or errno != EBADF\00"
@do_test.buff = internal global [8 x i8] zeroinitializer
@__const.do_test.name = [17 x i8] c"/tmp/aio7.XXXXXX\00"
@do_test.cb0 = internal global %struct.aiocb zeroinitializer
@do_test.cb1 = internal global %struct.aiocb zeroinitializer
@.str.5 = [19 x i8] c"creating temp file\00"
@.str.6 = [20 x i8] c"unlinking temp file\00"
@.str.7 = [9 x i8] c"01234567\00"
@.str.8 = [21 x i8] c"writing to temp file\00"
@.str.9 = [18 x i8] c"reading from file\00"
@EINPROGRESS = global i64 0
@.str.10 = [4 x i8] c"%c \00"
@EAGAIN = global i64 0
@.str.12 = [49 x i8] c"aio_suspend([done,blocked],2,3) suspended thread\00"
define i32 @do_test() {
%1 = alloca [2 x i32]
%2 = alloca %struct.aiocb
%3 = alloca %struct.aiocb
%4 = alloca [17 x i8]
%5 = alloca %struct.timespec
%6 = bitcast [2 x i32]* %1 to i8*
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%8 = call i64 @pipe(i32* %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %151
12: ; preds = %0
%13 = bitcast %struct.aiocb* %2 to i8*
%14 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %2, i64 0, i32 0
store i32 -1, i32* %14
%15 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %2, i64 0, i32 1
store i8* null, i8** %15
%16 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %2, i64 0, i32 2
store i32 0, i32* %16
%17 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %2, i64 0, i32 4
%18 = bitcast i64* %17 to i8*
%19 = load i8*, i8** @SIGEV_NONE
%20 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %2, i64 0, i32 3, i32 0
store i8* %19, i8** %20
store i64 0, i64* @errno
%21 = call i32 @aio_cancel(i32 -1, %struct.aiocb* %2)
%22 = icmp eq i32 %21, -1
%23 = load i64, i64* @errno
%24 = load i64, i64* @EBADF
%25 = icmp eq i64 %23, %24
%26 = select i1 %22, i1 %25, i1 false
br i1 %26, label %32, label %27
27: ; preds = %12
%28 = load i64, i64* @ENOSYS
%29 = icmp eq i64 %23, %28
br i1 %29, label %42, label %30
30: ; preds = %27
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %12, %30
%33 = phi i32 [ 1, %30 ], [ 0, %12 ]
store i32 -2, i32* %14
store i64 0, i64* @errno
%34 = call i32 @aio_cancel(i32 -1, %struct.aiocb* %2)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i64, i64* @errno
%38 = load i64, i64* @EBADF
%39 = icmp eq i64 %37, %38
br i1 %39, label %44, label %40
40: ; preds = %36, %32
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.3, i64 0, i64 0))
br label %44
42: ; preds = %27
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %151
44: ; preds = %40, %36
%45 = bitcast %struct.aiocb* %3 to i8*
%46 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %3, i64 0, i32 0
store i32 -1, i32* %46
%47 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %3, i64 0, i32 1
store i8* null, i8** %47
%48 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %3, i64 0, i32 2
store i32 0, i32* %48
%49 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %3, i64 0, i32 4
%50 = bitcast i64* %49 to i8*
%51 = load i8*, i8** @SIGEV_NONE
%52 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %3, i64 0, i32 3, i32 0
store i8* %51, i8** %52
store i64 0, i64* @errno
%53 = load i32, i32* @O_SYNC
%54 = call i32 @aio_fsync(i32 %53, %struct.aiocb* %3)
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %60
56: ; preds = %44
%57 = load i64, i64* @errno
%58 = load i64, i64* @EBADF
%59 = icmp eq i64 %57, %58
br i1 %59, label %63, label %60
60: ; preds = %56, %44
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0))
%62 = add nuw nsw i32 %33, 1
br label %63
63: ; preds = %60, %56
%64 = phi i32 [ %62, %60 ], [ %33, %56 ]
%65 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%66 = bitcast %struct.timespec* %5 to i8*
%67 = call i8* @llvm.stacksave()
%68 = alloca [2 x %struct.aiocb*]
%69 = getelementptr inbounds [2 x %struct.aiocb*], [2 x %struct.aiocb*]* %68, i64 0, i64 0
%70 = call i32 @mkstemp(i8* %65)
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %63
%73 = load i64, i64* @errno
%74 = call i32 @error(i32 1, i64 %73, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %75
75: ; preds = %72, %63
%76 = call i64 @unlink(i8* %65)
%77 = icmp eq i64 %76, 0
br i1 %77, label %81, label %78
78: ; preds = %75
%79 = load i64, i64* @errno
%80 = call i32 @error(i32 1, i64 %79, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %81
81: ; preds = %78, %75
%82 = call i32 @write(i32 %70, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 8)
%83 = icmp eq i32 %82, 8
br i1 %83, label %87, label %84
84: ; preds = %81
%85 = load i64, i64* @errno
%86 = call i32 @error(i32 1, i64 %85, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
br label %87
87: ; preds = %84, %81
store i32 %70, i32* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb0, i64 0, i32 0)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 0), i8** getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb0, i64 0, i32 1)
store i32 8, i32* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb0, i64 0, i32 2)
store <2 x i64> zeroinitializer, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb0, i64 0, i32 4) to <2 x i64>*)
%88 = load i8*, i8** @SIGEV_NONE
store i8* %88, i8** getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb0, i64 0, i32 3, i32 0)
%89 = call i32 @aio_read(%struct.aiocb* @do_test.cb0)
%90 = icmp eq i32 %89, 0
br i1 %90, label %94, label %91
91: ; preds = %87
%92 = load i64, i64* @errno
%93 = call i32 @error(i32 1, i64 %92, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %94
94: ; preds = %91, %87
%95 = call i64 @aio_error(%struct.aiocb* @do_test.cb0)
%96 = load i64, i64* @EINPROGRESS
%97 = icmp eq i64 %95, %96
br i1 %97, label %128, label %98
98: ; preds = %128, %94
%99 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 0)
%100 = sext i8 %99 to i32
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %100)
%102 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 1)
%103 = sext i8 %102 to i32
%104 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %103)
%105 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 2)
%106 = sext i8 %105 to i32
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %106)
%108 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 3)
%109 = sext i8 %108 to i32
%110 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %109)
%111 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 4)
%112 = sext i8 %111 to i32
%113 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %112)
%114 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 5)
%115 = sext i8 %114 to i32
%116 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %115)
%117 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 6)
%118 = sext i8 %117 to i32
%119 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %118)
%120 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 7)
%121 = sext i8 %120 to i32
%122 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %121)
%123 = call i32 @putchar(i32 10)
%124 = load i32, i32* %7
store i32 %124, i32* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb1, i64 0, i32 0)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 0), i8** getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb1, i64 0, i32 1)
store i32 8, i32* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb1, i64 0, i32 2)
store <2 x i64> zeroinitializer, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb1, i64 0, i32 4) to <2 x i64>*)
%125 = load i8*, i8** @SIGEV_NONE
store i8* %125, i8** getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb1, i64 0, i32 3, i32 0)
%126 = call i32 @aio_read(%struct.aiocb* @do_test.cb1)
%127 = icmp eq i32 %126, 0
br i1 %127, label %136, label %133
128: ; preds = %94, %128
%129 = call i32 @usleep(i32 10)
%130 = call i64 @aio_error(%struct.aiocb* @do_test.cb0)
%131 = load i64, i64* @EINPROGRESS
%132 = icmp eq i64 %130, %131
br i1 %132, label %128, label %98
133: ; preds = %98
%134 = load i64, i64* @errno
%135 = call i32 @error(i32 1, i64 %134, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %136
136: ; preds = %133, %98
store %struct.aiocb* @do_test.cb0, %struct.aiocb** %69
%137 = getelementptr inbounds [2 x %struct.aiocb*], [2 x %struct.aiocb*]* %68, i64 0, i64 1
store %struct.aiocb* @do_test.cb1, %struct.aiocb** %137
%138 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
store i32 3, i32* %138
%139 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
store i64 0, i64* %139
%140 = call i32 @aio_suspend(%struct.aiocb** %69, i32 2, %struct.timespec* %5)
%141 = icmp eq i32 %140, -1
br i1 %141, label %142, label %149
142: ; preds = %136
%143 = load i64, i64* @errno
%144 = load i64, i64* @EAGAIN
%145 = icmp eq i64 %143, %144
br i1 %145, label %146, label %149
146: ; preds = %142
%147 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.12, i64 0, i64 0))
%148 = add nsw i32 %64, 1
br label %149
149: ; preds = %146, %142, %136
%150 = phi i32 [ %148, %146 ], [ %64, %142 ], [ %64, %136 ]
br label %151
151: ; preds = %42, %149, %10
%152 = phi i32 [ 1, %10 ], [ %150, %149 ], [ 0, %42 ]
ret i32 %152
}