#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_RDONLY;
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 *);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ error(int, scalar_t__, char *);
int mkstemp(char *);
int open(char *, int /*<<< orphan*/);
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;
    }
    if ((fd = open("/dev/null", O_RDONLY)) < 0)
      error(1, errno, "opening /dev/null");
    cb.aio_fildes = fd;
    errno = 0;
    if (aio_fsync(O_SYNC, &cb) != -1 || errno != EBADF) {
      puts("aio_fsync( op, {RO..} ) did not return -1 or errno != EBADF");
      ++result;
    }
    close(fd);
  }
  {
    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   1090 <pipe@plt>
cmp    $0x0,%rax
jge    123d <do_test+0x3d>
lea    0xdd4(%rip),%rdi
call   1110 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1780 <do_test+0x580>
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    0x2d88(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2d3a(%rip),%rax
movq   $0x0,(%rax)
mov    -0x44(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   1070 <aio_cancel@plt>
cmp    $0xffffffff,%eax
jne    12b4 <do_test+0xb4>
mov    0x2d17(%rip),%rax
mov    (%rax),%rax
mov    0x2d05(%rip),%rcx
cmp    (%rcx),%rax
je     12fb <do_test+0xfb>
mov    0x2cfd(%rip),%rax
mov    (%rax),%rax
mov    0x2d03(%rip),%rcx
cmp    (%rcx),%rax
jne    12e6 <do_test+0xe6>
lea    0xd30(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1780 <do_test+0x580>
lea    0xd3d(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0xfffffffe,-0x40(%rbp)
mov    0x2caf(%rip),%rax
movq   $0x0,(%rax)
mov    -0x44(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   1070 <aio_cancel@plt>
cmp    $0xffffffff,%eax
jne    133f <do_test+0x13f>
mov    0x2c8c(%rip),%rax
mov    (%rax),%rax
mov    0x2c7a(%rip),%rcx
cmp    (%rcx),%rax
je     134b <do_test+0x14b>
lea    0xd21(%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    0x2c7a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
mov    0x2c2c(%rip),%rax
movq   $0x0,(%rax)
mov    0x2c46(%rip),%rax
mov    (%rax),%edi
lea    -0x78(%rbp),%rsi
call   10e0 <aio_fsync@plt>
cmp    $0xffffffff,%eax
jne    13c8 <do_test+0x1c8>
mov    0x2c03(%rip),%rax
mov    (%rax),%rax
mov    0x2bf1(%rip),%rcx
cmp    (%rcx),%rax
je     13dd <do_test+0x1dd>
lea    0xcd5(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    0x2bec(%rip),%rax
mov    (%rax),%esi
lea    0xcfb(%rip),%rdi
call   1100 <open@plt>
mov    %eax,-0x7c(%rbp)
cmp    $0x0,%eax
jge    1419 <do_test+0x219>
mov    0x2bb3(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xccc(%rip),%rdx
call   10f0 <error@plt>
mov    -0x7c(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    0x2b92(%rip),%rax
movq   $0x0,(%rax)
mov    0x2bac(%rip),%rax
mov    (%rax),%edi
lea    -0x78(%rbp),%rsi
call   10e0 <aio_fsync@plt>
cmp    $0xffffffff,%eax
jne    1462 <do_test+0x262>
mov    0x2b69(%rip),%rax
mov    (%rax),%rax
mov    0x2b57(%rip),%rcx
cmp    (%rcx),%rax
je     1477 <do_test+0x277>
lea    0xc89(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x7c(%rbp),%edi
call   1080 <close@plt>
movl   $0x2,-0x80(%rbp)
movaps 0xd33(%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   10d0 <mkstemp@plt>
mov    %eax,-0x8c(%rbp)
cmpl   $0x0,-0x8c(%rbp)
jge    14f0 <do_test+0x2f0>
mov    0x2adc(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc43(%rip),%rdx
call   10f0 <error@plt>
lea    -0xa0(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     1521 <do_test+0x321>
mov    0x2aab(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc25(%rip),%rdx
call   10f0 <error@plt>
mov    -0x8c(%rbp),%edi
lea    0xc27(%rip),%rsi
mov    $0x8,%edx
call   1050 <write@plt>
cmp    $0x8,%eax
je     155c <do_test+0x35c>
mov    0x2a70(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc07(%rip),%rdx
call   10f0 <error@plt>
mov    -0x8c(%rbp),%eax
mov    %eax,0x2b70(%rip)
movq   $0x0,0x2b8d(%rip)
lea    0x2b56(%rip),%rax
mov    %rax,0x2b5f(%rip)
movl   $0x8,0x2b5d(%rip)
movq   $0x0,0x2b62(%rip)
mov    0x2a5b(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x2b49(%rip)
lea    0x2b2a(%rip),%rdi
call   10a0 <aio_read@plt>
mov    %eax,-0x88(%rbp)
cmpl   $0x0,-0x88(%rbp)
je     15e1 <do_test+0x3e1>
mov    0x29eb(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xb97(%rip),%rdx
call   10f0 <error@plt>
jmp    15e6 <do_test+0x3e6>
lea    0x2aeb(%rip),%rdi
call   10b0 <aio_error@plt>
mov    0x29df(%rip),%rcx
cmp    (%rcx),%rax
jne    1611 <do_test+0x411>
mov    $0xa,%edi
call   1120 <usleep@plt>
jmp    15e6 <do_test+0x3e6>
movl   $0x0,-0x84(%rbp)
cmpl   $0x8,-0x84(%rbp)
jge    165c <do_test+0x45c>
movslq -0x84(%rbp),%rcx
lea    0x2a9a(%rip),%rax
movsbl (%rax,%rcx,1),%esi
lea    0xb44(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    161b <do_test+0x41b>
lea    0xb26(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,0x2a95(%rip)
movq   $0x0,0x2ab2(%rip)
lea    0x2a4b(%rip),%rax
mov    %rax,0x2a84(%rip)
movl   $0x8,0x2a82(%rip)
movq   $0x0,0x2a87(%rip)
mov    0x2950(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x2a6e(%rip)
lea    0x2a4f(%rip),%rdi
call   10a0 <aio_read@plt>
mov    %eax,-0x88(%rbp)
cmpl   $0x0,-0x88(%rbp)
je     16ec <do_test+0x4ec>
mov    0x28e0(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xa8c(%rip),%rdx
call   10f0 <error@plt>
mov    -0xc0(%rbp),%rdi
lea    0x29de(%rip),%rax
mov    %rax,(%rdi)
lea    0x2a04(%rip),%rax
mov    %rax,0x8(%rdi)
movl   $0x3,-0xb0(%rbp)
movq   $0x0,-0xa8(%rbp)
mov    $0x2,%esi
lea    -0xb0(%rbp),%rdx
call   10c0 <aio_suspend@plt>
mov    %eax,-0x88(%rbp)
cmpl   $0xffffffff,-0x88(%rbp)
jne    1770 <do_test+0x570>
mov    0x2870(%rip),%rax
mov    (%rax),%rax
mov    0x284e(%rip),%rcx
cmp    (%rcx),%rax
jne    1770 <do_test+0x570>
lea    0xa29(%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   10a0 <pipe@plt>
test   %rax,%rax
js     165f <do_test+0x44f>
movl   $0xffffffff,-0x60(%rbp)
movq   $0x0,-0x58(%rbp)
movl   $0x0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movups %xmm0,-0x40(%rbp)
mov    0x2da1(%rip),%rbx
mov    (%rbx),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d53(%rip),%r13
movq   $0x0,0x0(%r13)
lea    -0x60(%rbp),%rsi
mov    $0xffffffff,%edi
call   1080 <aio_cancel@plt>
mov    0x0(%r13),%rcx
mov    0x2d2a(%rip),%r15
cmp    $0xffffffff,%eax
jne    1293 <do_test+0x83>
xor    %r14d,%r14d
cmp    (%r15),%rcx
je     12c5 <do_test+0xb5>
mov    0x2d2e(%rip),%rax
cmp    (%rax),%rcx
jne    12b3 <do_test+0xa3>
lea    0xd5f(%rip),%rdi
call   1050 <puts@plt>
xor    %r14d,%r14d
jmp    164d <do_test+0x43d>
lea    0xd70(%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    12f0 <do_test+0xe0>
mov    0x0(%r13),%rax
cmp    (%r15),%rax
je     12fc <do_test+0xec>
lea    0xd70(%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    (%rbx),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,0x0(%r13)
mov    0x2cb1(%rip),%r12
mov    (%r12),%edi
lea    -0x60(%rbp),%rsi
call   10f0 <aio_fsync@plt>
cmp    $0xffffffff,%eax
jne    134a <do_test+0x13a>
mov    0x0(%r13),%rax
cmp    (%r15),%rax
je     135a <do_test+0x14a>
lea    0xd53(%rip),%rdi
call   1050 <puts@plt>
add    $0x1,%r14d
mov    0x2c6f(%rip),%rax
mov    (%rax),%esi
lea    0xd7e(%rip),%rdi
call   1110 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    138a <do_test+0x17a>
mov    0x0(%r13),%rsi
lea    0xd60(%rip),%rdx
mov    $0x1,%edi
call   1100 <error@plt>
mov    %ebx,-0x60(%rbp)
movq   $0x0,0x0(%r13)
mov    (%r12),%edi
lea    -0x60(%rbp),%rsi
call   10f0 <aio_fsync@plt>
cmp    $0xffffffff,%eax
jne    13b0 <do_test+0x1a0>
mov    0x0(%r13),%rax
cmp    (%r15),%rax
je     13c0 <do_test+0x1b0>
lea    0xd3b(%rip),%rdi
call   1050 <puts@plt>
add    $0x1,%r14d
mov    %ebx,%edi
call   1090 <close@plt>
mov    %rsp,-0x68(%rbp)
movaps 0xdee(%rip),%xmm0
movaps %xmm0,-0x60(%rbp)
movb   $0x0,-0x50(%rbp)
mov    %rsp,%r12
add    $0xfffffffffffffff0,%r12
mov    %r12,%rsp
lea    -0x60(%rbp),%rdi
call   10e0 <mkstemp@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1408 <do_test+0x1f8>
mov    0x0(%r13),%rsi
lea    0xd30(%rip),%rdx
mov    $0x1,%edi
call   1100 <error@plt>
lea    -0x60(%rbp),%rdi
call   1040 <unlink@plt>
test   %rax,%rax
je     142b <do_test+0x21b>
mov    0x0(%r13),%rsi
lea    0xd20(%rip),%rdx
mov    $0x1,%edi
call   1100 <error@plt>
lea    0xd23(%rip),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   1060 <write@plt>
cmp    $0x8,%eax
je     1458 <do_test+0x248>
mov    0x0(%r13),%rsi
lea    0xd10(%rip),%rdx
mov    $0x1,%edi
call   1100 <error@plt>
mov    %ebx,0x2c82(%rip)
lea    0x2c7b(%rip),%rdi
lea    0x2c6c(%rip),%rax
mov    %rax,0x2c75(%rip)
movl   $0x8,0x2c73(%rip)
xorps  %xmm0,%xmm0
movups %xmm0,0x2c79(%rip)
mov    0x2b6a(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x2c60(%rip)
call   10b0 <aio_read@plt>
test   %eax,%eax
je     14b6 <do_test+0x2a6>
mov    0x0(%r13),%rsi
lea    0xcc7(%rip),%rdx
mov    $0x1,%edi
call   1100 <error@plt>
lea    0x2c23(%rip),%rdi
call   10c0 <aio_error@plt>
mov    0x2b0f(%rip),%r15
cmp    (%r15),%rax
jne    14f7 <do_test+0x2e7>
lea    0x2c0b(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1130 <usleep@plt>
mov    %rbx,%rdi
call   10c0 <aio_error@plt>
cmp    (%r15),%rax
je     14e0 <do_test+0x2d0>
movsbl 0x2bda(%rip),%esi
lea    0xc80(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2bc3(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2bb3(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2ba3(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2b93(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2b83(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2b73(%rip),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x2b63(%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,0x2b77(%rip)
lea    0x2b70(%rip),%rbx
lea    0x2b31(%rip),%rax
mov    %rax,0x2b6a(%rip)
movl   $0x8,0x2b68(%rip)
xorps  %xmm0,%xmm0
movups %xmm0,0x2b6e(%rip)
mov    0x2a2f(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x2b55(%rip)
mov    %rbx,%rdi
call   10b0 <aio_read@plt>
test   %eax,%eax
je     15f4 <do_test+0x3e4>
mov    0x0(%r13),%rsi
lea    0xb89(%rip),%rdx
mov    $0x1,%edi
call   1100 <error@plt>
lea    0x2ae5(%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   10d0 <aio_suspend@plt>
cmp    $0xffffffff,%eax
jne    1649 <do_test+0x439>
mov    0x0(%r13),%rax
mov    0x296c(%rip),%rcx
cmp    (%rcx),%rax
jne    1649 <do_test+0x439>
lea    0xb49(%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    0x99a(%rip),%rdi
call   1120 <perror@plt>
mov    $0x1,%r14d
jmp    164d <do_test+0x43d>

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"
@.str.5 = [10 x i8] c"/dev/null\00"
@O_RDONLY = global i32 0
@.str.6 = [18 x i8] c"opening /dev/null\00"
@.str.7 = [60 x i8] c"aio_fsync( op, {RO..} ) 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.8 = [19 x i8] c"creating temp file\00"
@.str.9 = [20 x i8] c"unlinking temp file\00"
@.str.10 = [9 x i8] c"01234567\00"
@.str.11 = [21 x i8] c"writing to temp file\00"
@.str.12 = [18 x i8] c"reading from file\00"
@EINPROGRESS = global i64 0
@.str.13 = [4 x i8] c"%c \00"
@.str.14 = [2 x i8] c"\0A\00"
@EAGAIN = global i64 0
@.str.15 = [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 %187
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 %187
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
%80 = load i32, i32* @O_RDONLY
%81 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %80)
store i32 %81, i32* %7
%82 = icmp slt i32 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %79
%84 = load i64, i64* @errno
%85 = call i32 @error(i32 1, i64 %84, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %86
86: ; preds = %83, %79
%87 = load i32, i32* %7
%88 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %6, i32 0, i32 0
store i32 %87, i32* %88
store i64 0, i64* @errno
%89 = load i32, i32* @O_SYNC
%90 = call i32 @aio_fsync(i32 %89, %struct.aiocb* %6)
%91 = icmp ne i32 %90, -1
br i1 %91, label %96, label %92
92: ; preds = %86
%93 = load i64, i64* @errno
%94 = load i64, i64* @EBADF
%95 = icmp ne i64 %93, %94
br i1 %95, label %96, label %100
96: ; preds = %92, %86
%97 = call i32 @puts(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.7, i64 0, i64 0))
%98 = load i32, i32* %2
%99 = add nsw i32 %98, 1
store i32 %99, i32* %2
br label %100
100: ; preds = %96, %92
%101 = load i32, i32* %7
%102 = call i32 @close(i32 %101)
store i32 2, i32* %8
%103 = bitcast [17 x i8]* %12 to i8*
%104 = call i8* @llvm.stacksave()
store i8* %104, i8** %14
%105 = alloca %struct.aiocb*, i64 2
%106 = getelementptr inbounds [17 x i8], [17 x i8]* %12, i64 0, i64 0
%107 = call i32 @mkstemp(i8* %106)
store i32 %107, i32* %11
%108 = load i32, i32* %11
%109 = icmp slt i32 %108, 0
br i1 %109, label %110, label %113
110: ; preds = %100
%111 = load i64, i64* @errno
%112 = call i32 @error(i32 1, i64 %111, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %113
113: ; preds = %110, %100
%114 = getelementptr inbounds [17 x i8], [17 x i8]* %12, i64 0, i64 0
%115 = call i64 @unlink(i8* %114)
%116 = icmp ne i64 %115, 0
br i1 %116, label %117, label %120
117: ; preds = %113
%118 = load i64, i64* @errno
%119 = call i32 @error(i32 1, i64 %118, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %120
120: ; preds = %117, %113
%121 = load i32, i32* %11
%122 = call i32 @write(i32 %121, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 8)
%123 = icmp ne i32 %122, 8
br i1 %123, label %124, label %127
124: ; preds = %120
%125 = load i64, i64* @errno
%126 = call i32 @error(i32 1, i64 %125, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
br label %127
127: ; preds = %124, %120
%128 = load i32, i32* %11
store i32 %128, 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)
%129 = load i8*, i8** @SIGEV_NONE
store i8* %129, i8** getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb0, i32 0, i32 3, i32 0)
%130 = call i32 @aio_read(%struct.aiocb* @do_test.cb0)
store i32 %130, i32* %10
%131 = load i32, i32* %10
%132 = icmp ne i32 %131, 0
br i1 %132, label %133, label %136
133: ; preds = %127
%134 = load i64, i64* @errno
%135 = call i32 @error(i32 1, i64 %134, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
br label %136
136: ; preds = %133, %127
br label %137
137: ; preds = %141, %136
%138 = call i64 @aio_error(%struct.aiocb* @do_test.cb0)
%139 = load i64, i64* @EINPROGRESS
%140 = icmp eq i64 %138, %139
br i1 %140, label %141, label %143
141: ; preds = %137
%142 = call i32 @usleep(i32 10)
br label %137
143: ; preds = %137
store i32 0, i32* %9
br label %144
144: ; preds = %154, %143
%145 = load i32, i32* %9
%146 = icmp slt i32 %145, 8
br i1 %146, label %147, label %157
147: ; preds = %144
%148 = load i32, i32* %9
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds [8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 %149
%151 = load i8, i8* %150
%152 = sext i8 %151 to i32
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %152)
br label %154
154: ; preds = %147
%155 = load i32, i32* %9
%156 = add nsw i32 %155, 1
store i32 %156, i32* %9
br label %144
157: ; preds = %144
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%159 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%160 = load i32, i32* %159
store i32 %160, 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)
%161 = load i8*, i8** @SIGEV_NONE
store i8* %161, i8** getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb1, i32 0, i32 3, i32 0)
%162 = call i32 @aio_read(%struct.aiocb* @do_test.cb1)
store i32 %162, i32* %10
%163 = load i32, i32* %10
%164 = icmp ne i32 %163, 0
br i1 %164, label %165, label %168
165: ; preds = %157
%166 = load i64, i64* @errno
%167 = call i32 @error(i32 1, i64 %166, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
br label %168
168: ; preds = %165, %157
%169 = getelementptr inbounds %struct.aiocb*, %struct.aiocb** %105, i64 0
store %struct.aiocb* @do_test.cb0, %struct.aiocb** %169
%170 = getelementptr inbounds %struct.aiocb*, %struct.aiocb** %105, i64 1
store %struct.aiocb* @do_test.cb1, %struct.aiocb** %170
%171 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 0
store i32 3, i32* %171
%172 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 1
store i64 0, i64* %172
%173 = call i32 @aio_suspend(%struct.aiocb** %105, i32 2, %struct.timespec* %13)
store i32 %173, i32* %10
%174 = load i32, i32* %10
%175 = icmp eq i32 %174, -1
br i1 %175, label %176, label %184
176: ; preds = %168
%177 = load i64, i64* @errno
%178 = load i64, i64* @EAGAIN
%179 = icmp eq i64 %177, %178
br i1 %179, label %180, label %184
180: ; preds = %176
%181 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.15, i64 0, i64 0))
%182 = load i32, i32* %2
%183 = add nsw i32 %182, 1
store i32 %183, i32* %2
br label %184
184: ; preds = %180, %176, %168
%185 = load i8*, i8** %14
%186 = load i32, i32* %2
store i32 %186, i32* %1
br label %187
187: ; preds = %184, %41, %18
%188 = load i32, i32* %1
ret i32 %188
}

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"
@.str.5 = [10 x i8] c"/dev/null\00"
@O_RDONLY = global i32 0
@.str.6 = [18 x i8] c"opening /dev/null\00"
@.str.7 = [60 x i8] c"aio_fsync( op, {RO..} ) 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.8 = [19 x i8] c"creating temp file\00"
@.str.9 = [20 x i8] c"unlinking temp file\00"
@.str.10 = [9 x i8] c"01234567\00"
@.str.11 = [21 x i8] c"writing to temp file\00"
@.str.12 = [18 x i8] c"reading from file\00"
@EINPROGRESS = global i64 0
@.str.13 = [4 x i8] c"%c \00"
@EAGAIN = global i64 0
@.str.15 = [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 %171
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 %171
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 = load i32, i32* @O_RDONLY
%66 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %65)
%67 = icmp slt i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %63
%69 = load i64, i64* @errno
%70 = call i32 @error(i32 1, i64 %69, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %71
71: ; preds = %68, %63
store i32 %66, i32* %46
store i64 0, i64* @errno
%72 = load i32, i32* @O_SYNC
%73 = call i32 @aio_fsync(i32 %72, %struct.aiocb* %3)
%74 = icmp eq i32 %73, -1
br i1 %74, label %75, label %79
75: ; preds = %71
%76 = load i64, i64* @errno
%77 = load i64, i64* @EBADF
%78 = icmp eq i64 %76, %77
br i1 %78, label %82, label %79
79: ; preds = %75, %71
%80 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.7, i64 0, i64 0))
%81 = add nuw nsw i32 %64, 1
br label %82
82: ; preds = %79, %75
%83 = phi i32 [ %81, %79 ], [ %64, %75 ]
%84 = call i32 @close(i32 %66)
%85 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%86 = bitcast %struct.timespec* %5 to i8*
%87 = call i8* @llvm.stacksave()
%88 = alloca [2 x %struct.aiocb*]
%89 = getelementptr inbounds [2 x %struct.aiocb*], [2 x %struct.aiocb*]* %88, i64 0, i64 0
%90 = call i32 @mkstemp(i8* %85)
%91 = icmp slt i32 %90, 0
br i1 %91, label %92, label %95
92: ; preds = %82
%93 = load i64, i64* @errno
%94 = call i32 @error(i32 1, i64 %93, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %95
95: ; preds = %92, %82
%96 = call i64 @unlink(i8* %85)
%97 = icmp eq i64 %96, 0
br i1 %97, label %101, label %98
98: ; preds = %95
%99 = load i64, i64* @errno
%100 = call i32 @error(i32 1, i64 %99, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %101
101: ; preds = %98, %95
%102 = call i32 @write(i32 %90, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 8)
%103 = icmp eq i32 %102, 8
br i1 %103, label %107, label %104
104: ; preds = %101
%105 = load i64, i64* @errno
%106 = call i32 @error(i32 1, i64 %105, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
br label %107
107: ; preds = %104, %101
store i32 %90, 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>*)
%108 = load i8*, i8** @SIGEV_NONE
store i8* %108, i8** getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb0, i64 0, i32 3, i32 0)
%109 = call i32 @aio_read(%struct.aiocb* @do_test.cb0)
%110 = icmp eq i32 %109, 0
br i1 %110, label %114, label %111
111: ; preds = %107
%112 = load i64, i64* @errno
%113 = call i32 @error(i32 1, i64 %112, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
br label %114
114: ; preds = %111, %107
%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 %148, label %118
118: ; preds = %148, %114
%119 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 0)
%120 = sext i8 %119 to i32
%121 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %120)
%122 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 1)
%123 = sext i8 %122 to i32
%124 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %123)
%125 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 2)
%126 = sext i8 %125 to i32
%127 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %126)
%128 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 3)
%129 = sext i8 %128 to i32
%130 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %129)
%131 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 4)
%132 = sext i8 %131 to i32
%133 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %132)
%134 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 5)
%135 = sext i8 %134 to i32
%136 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %135)
%137 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 6)
%138 = sext i8 %137 to i32
%139 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %138)
%140 = load i8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @do_test.buff, i64 0, i64 7)
%141 = sext i8 %140 to i32
%142 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %141)
%143 = call i32 @putchar(i32 10)
%144 = load i32, i32* %7
store i32 %144, 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>*)
%145 = load i8*, i8** @SIGEV_NONE
store i8* %145, i8** getelementptr inbounds (%struct.aiocb, %struct.aiocb* @do_test.cb1, i64 0, i32 3, i32 0)
%146 = call i32 @aio_read(%struct.aiocb* @do_test.cb1)
%147 = icmp eq i32 %146, 0
br i1 %147, label %156, label %153
148: ; preds = %114, %148
%149 = call i32 @usleep(i32 10)
%150 = call i64 @aio_error(%struct.aiocb* @do_test.cb0)
%151 = load i64, i64* @EINPROGRESS
%152 = icmp eq i64 %150, %151
br i1 %152, label %148, label %118
153: ; preds = %118
%154 = load i64, i64* @errno
%155 = call i32 @error(i32 1, i64 %154, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
br label %156
156: ; preds = %153, %118
store %struct.aiocb* @do_test.cb0, %struct.aiocb** %89
%157 = getelementptr inbounds [2 x %struct.aiocb*], [2 x %struct.aiocb*]* %88, i64 0, i64 1
store %struct.aiocb* @do_test.cb1, %struct.aiocb** %157
%158 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
store i32 3, i32* %158
%159 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
store i64 0, i64* %159
%160 = call i32 @aio_suspend(%struct.aiocb** %89, i32 2, %struct.timespec* %5)
%161 = icmp eq i32 %160, -1
br i1 %161, label %162, label %169
162: ; preds = %156
%163 = load i64, i64* @errno
%164 = load i64, i64* @EAGAIN
%165 = icmp eq i64 %163, %164
br i1 %165, label %166, label %169
166: ; preds = %162
%167 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.15, i64 0, i64 0))
%168 = add nsw i32 %83, 1
br label %169
169: ; preds = %166, %162, %156
%170 = phi i32 [ %168, %166 ], [ %83, %162 ], [ %83, %156 ]
br label %171
171: ; preds = %42, %169, %10
%172 = phi i32 [ 1, %10 ], [ %170, %169 ], [ 0, %42 ]
ret i32 %172
}