#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct aiocb {
  int aio_fildes;
  char *aio_buf;
  int aio_nbytes;
  scalar_t__ aio_offset;
};

/* Variables and functions */
int EINPROGRESS;
int EINTR;
int aio_error(struct aiocb *);
int aio_read(struct aiocb *);
int aio_return(struct aiocb *);
int aio_suspend(struct aiocb const **, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ memset(struct aiocb *, int /*<<< orphan*/, int);
int mkstemp(char *);
int /*<<< orphan*/ strerror(int);
int /*<<< orphan*/ test_daemon();
scalar_t__ test_go();
int /*<<< orphan*/ test_init(int, char **);
int /*<<< orphan*/ test_msg(char *, ...);
int /*<<< orphan*/ unlink(char *);
int write(int, char *, int);
int main(int argc, char **argv) {
  test_init(argc, argv);
  char buf[1024];
  int fd;
  struct aiocb aiocb;
  const struct aiocb *aioary[1];
  char tmpfname[256] = "/tmp/file_aio.XXXXXX";
  int ret;
  fd = mkstemp(tmpfname);
  if (fd == -1) {
    test_msg("ERR: %s:%d: "
             "Error at open(): %s"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/test/zdtm/"
             "live/streaming/file_aio.c",
             30, strerror(errno), errno, strerror(errno));
    exit(1);
  }
  unlink(tmpfname);
  if (write(fd, buf, 1024) != 1024) {
    test_msg("ERR: %s:%d: "
             "Error at write(): %s"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/test/zdtm/"
             "live/streaming/file_aio.c",
             37, strerror(errno), errno, strerror(errno));
    exit(1);
  }
  test_daemon();
  while (test_go()) {
    memset(&aiocb, 0, sizeof(struct aiocb));
    aiocb.aio_offset = 0;
    aiocb.aio_fildes = fd;
    aiocb.aio_buf = buf;
    aiocb.aio_nbytes = 1024;
    ret = aio_read(&aiocb);
    if (ret < 0) {
      if ((errno == EINTR) && (!test_go()))
        break;
      test_msg("ERR: %s:%d: "
               "aio_read failed %m"
               " (errno = %d (%s))\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/"
               "test/zdtm/live/streaming/file_aio.c",
               55, errno, strerror(errno));
      return 1;
    }
    if (ret < 0) {
      test_msg("ERR: %s:%d: "
               "aio_read failed %s\n"
               " (errno = %d (%s))\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/"
               "test/zdtm/live/streaming/file_aio.c",
               60, strerror(errno), errno, strerror(errno));
      exit(1);
    }
    aioary[0] = &aiocb;
  again:
    ret = aio_suspend(aioary, 1, NULL);
    if (ret < 0) {
      if ((errno == EINTR) && (!test_go()))
        break;
      if (errno != EINTR) {
        test_msg("ERR: %s:%d: "
                 "aio_suspend failed %m"
                 " (errno = %d (%s))\n",
                 "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/"
                 "master/test/zdtm/live/streaming/file_aio.c",
                 71, errno, strerror(errno));
        return 1;
      }
    }
    ret = aio_error(&aiocb);
    if (ret == EINPROGRESS) {
      goto again;
    }
    if (ret != 0) {
      test_msg("ERR: %s:%d: "
               "Error at aio_error() %s"
               " (errno = %d (%s))\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/"
               "test/zdtm/live/streaming/file_aio.c",
               84, strerror(ret), errno, strerror(errno));
      return 1;
    }
    ret = aio_return(&aiocb);
    if (ret < 0) {
      if ((errno == EINTR) && (!test_go()))
        break;
      test_msg("ERR: %s:%d: "
               "aio_return failed %m"
               " (errno = %d (%s))\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/"
               "test/zdtm/live/streaming/file_aio.c",
               92, errno, strerror(errno));
      return 1;
    }
    if (ret != 1024) {
      test_msg("ERR: %s:%d: "
               "Error at aio_return()\n"
               " (errno = %d (%s))\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/"
               "test/zdtm/live/streaming/file_aio.c",
               96, errno, strerror(errno));
      exit(1);
    }
  }
  close(fd);
  test_msg("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x580,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <test_init@plt>
lea    -0x540(%rbp),%rdi
lea    0xdcd(%rip),%rsi
mov    $0x100,%edx
call   10b0 <memcpy@plt>
lea    -0x540(%rbp),%rdi
call   10f0 <mkstemp@plt>
mov    %eax,-0x414(%rbp)
cmpl   $0xffffffff,-0x414(%rbp)
jne    12c1 <main+0xc1>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    %eax,-0x54c(%rbp)
mov    0x2d61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x548(%rbp)
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x54c(%rbp),%ecx
mov    -0x548(%rbp),%r8d
mov    %eax,%r9d
lea    0xe5c(%rip),%rdi
lea    0xe88(%rip),%rsi
mov    $0x1e,%edx
mov    $0x0,%al
call   1090 <test_msg@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x540(%rbp),%rdi
call   1030 <unlink@plt>
mov    -0x414(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1050 <write@plt>
cmp    $0x400,%eax
je     1354 <main+0x154>
mov    0x2ce2(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    %eax,-0x554(%rbp)
mov    0x2cce(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x550(%rbp)
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x554(%rbp),%ecx
mov    -0x550(%rbp),%r8d
mov    %eax,%r9d
lea    0xe97(%rip),%rdi
lea    0xdf5(%rip),%rsi
mov    $0x25,%edx
mov    $0x0,%al
call   1090 <test_msg@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    $0x0,%al
call   1060 <test_daemon@plt>
mov    $0x0,%al
call   1100 <test_go@plt>
cmp    $0x0,%rax
je     171b <main+0x51b>
lea    -0x438(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
movq   $0x0,-0x420(%rbp)
mov    -0x414(%rbp),%eax
mov    %eax,-0x438(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x430(%rbp)
movl   $0x400,-0x428(%rbp)
lea    -0x438(%rbp),%rdi
call   10a0 <aio_read@plt>
mov    %eax,-0x544(%rbp)
cmpl   $0x0,-0x544(%rbp)
jge    1447 <main+0x247>
mov    0x2c04(%rip),%rax
mov    (%rax),%eax
mov    0x2bf3(%rip),%rcx
cmp    (%rcx),%eax
jne    13fb <main+0x1fb>
mov    $0x0,%al
call   1100 <test_go@plt>
cmp    $0x0,%rax
jne    13fb <main+0x1fb>
jmp    171b <main+0x51b>
mov    0x2bd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x558(%rbp)
mov    0x2bc7(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x558(%rbp),%ecx
mov    %eax,%r8d
lea    0xdda(%rip),%rdi
lea    0xd04(%rip),%rsi
mov    $0x37,%edx
mov    $0x0,%al
call   1090 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    173b <main+0x53b>
cmpl   $0x0,-0x544(%rbp)
jge    14b9 <main+0x2b9>
mov    0x2b7d(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    %eax,-0x560(%rbp)
mov    0x2b69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x55c(%rbp)
mov    0x2b5a(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x560(%rbp),%ecx
mov    -0x55c(%rbp),%r8d
mov    %eax,%r9d
lea    0xd98(%rip),%rdi
lea    0xc90(%rip),%rsi
mov    $0x3c,%edx
mov    $0x0,%al
call   1090 <test_msg@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x438(%rbp),%rax
mov    %rax,-0x440(%rbp)
lea    -0x440(%rbp),%rdi
mov    $0x1,%esi
xor    %eax,%eax
mov    %eax,%edx
call   10e0 <aio_suspend@plt>
mov    %eax,-0x544(%rbp)
cmpl   $0x0,-0x544(%rbp)
jge    1586 <main+0x386>
mov    0x2ae2(%rip),%rax
mov    (%rax),%eax
mov    0x2ad1(%rip),%rcx
cmp    (%rcx),%eax
jne    151d <main+0x31d>
mov    $0x0,%al
call   1100 <test_go@plt>
cmp    $0x0,%rax
jne    151d <main+0x31d>
jmp    171b <main+0x51b>
mov    0x2ab4(%rip),%rax
mov    (%rax),%eax
mov    0x2aa3(%rip),%rcx
cmp    (%rcx),%eax
je     1581 <main+0x381>
mov    0x2a9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x564(%rbp)
mov    0x2a8d(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x564(%rbp),%ecx
mov    %eax,%r8d
lea    0xd05(%rip),%rdi
lea    0xbca(%rip),%rsi
mov    $0x47,%edx
mov    $0x0,%al
call   1090 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    173b <main+0x53b>
jmp    1586 <main+0x386>
lea    -0x438(%rbp),%rdi
call   10c0 <aio_error@plt>
mov    %eax,-0x544(%rbp)
mov    -0x544(%rbp),%eax
mov    0x2a43(%rip),%rcx
cmp    (%rcx),%eax
jne    15b2 <main+0x3b2>
jmp    14c7 <main+0x2c7>
cmpl   $0x0,-0x544(%rbp)
je     1623 <main+0x423>
mov    -0x544(%rbp),%edi
call   1120 <strerror@plt>
mov    %eax,-0x56c(%rbp)
mov    0x2a01(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x568(%rbp)
mov    0x29f2(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x56c(%rbp),%ecx
mov    -0x568(%rbp),%r8d
mov    %eax,%r9d
lea    0xc98(%rip),%rdi
lea    0xb28(%rip),%rsi
mov    $0x54,%edx
mov    $0x0,%al
call   1090 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    173b <main+0x53b>
lea    -0x438(%rbp),%rdi
call   10d0 <aio_return@plt>
mov    %eax,-0x544(%rbp)
cmpl   $0x0,-0x544(%rbp)
jge    16bc <main+0x4bc>
mov    0x298f(%rip),%rax
mov    (%rax),%eax
mov    0x297e(%rip),%rcx
cmp    (%rcx),%eax
jne    1670 <main+0x470>
mov    $0x0,%al
call   1100 <test_go@plt>
cmp    $0x0,%rax
jne    1670 <main+0x470>
jmp    171b <main+0x51b>
mov    0x2961(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x570(%rbp)
mov    0x2952(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x570(%rbp),%ecx
mov    %eax,%r8d
lea    0xc36(%rip),%rdi
lea    0xa8f(%rip),%rsi
mov    $0x5c,%edx
mov    $0x0,%al
call   1090 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    173b <main+0x53b>
cmpl   $0x400,-0x544(%rbp)
je     1716 <main+0x516>
mov    0x2905(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x574(%rbp)
mov    0x28f6(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x574(%rbp),%ecx
mov    %eax,%r8d
lea    0xc0e(%rip),%rdi
lea    0xa33(%rip),%rsi
mov    $0x60,%edx
mov    $0x0,%al
call   1090 <test_msg@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    135b <main+0x15b>
mov    -0x414(%rbp),%edi
call   1080 <close@plt>
lea    0xc10(%rip),%rdi
mov    $0x0,%al
call   1090 <test_msg@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x580,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x538,%rsp
call   1040 <test_init@plt>
lea    0xde3(%rip),%rsi
lea    0x30(%rsp),%rbx
mov    $0x100,%edx
mov    %rbx,%rdi
call   10b0 <memcpy@plt>
mov    %rbx,%rdi
call   10f0 <mkstemp@plt>
cmp    $0xffffffff,%eax
je     14a4 <main+0x2a4>
mov    %eax,%ebx
lea    0x30(%rsp),%rdi
call   1030 <unlink@plt>
lea    0x130(%rsp),%rsi
mov    %ebx,0x4(%rsp)
mov    %ebx,%edi
mov    $0x400,%edx
call   1050 <write@plt>
cmp    $0x400,%eax
jne    14d4 <main+0x2d4>
xor    %eax,%eax
call   1060 <test_daemon@plt>
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r12
mov    0x2d51(%rip),%r13
mov    0x2d42(%rip),%r14
mov    0x2d53(%rip),%r15
xor    %eax,%eax
call   1100 <test_go@plt>
test   %rax,%rax
je     1477 <main+0x277>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
movq   $0x0,0x28(%rsp)
mov    0x4(%rsp),%eax
mov    %eax,0x10(%rsp)
lea    0x130(%rsp),%rax
mov    %rax,0x18(%rsp)
movl   $0x400,0x20(%rsp)
mov    %rbx,%rdi
call   10a0 <aio_read@plt>
test   %eax,%eax
js     13c7 <main+0x1c7>
mov    %rbx,0x8(%rsp)
jmp    130d <main+0x10d>
mov    0x0(%r13),%ebp
mov    (%r14),%eax
cmp    %eax,%ebp
jne    1397 <main+0x197>
mov    %rbx,%rdi
call   10c0 <aio_error@plt>
cmp    (%r15),%eax
jne    1340 <main+0x140>
mov    %r12,%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   10e0 <aio_suspend@plt>
test   %eax,%eax
jns    1300 <main+0x100>
mov    0x0(%r13),%ebp
mov    (%r14),%eax
cmp    %eax,%ebp
jne    12f8 <main+0xf8>
xor    %eax,%eax
call   1100 <test_go@plt>
test   %rax,%rax
jne    12f1 <main+0xf1>
jmp    1477 <main+0x277>
nopl   0x0(%rax)
test   %eax,%eax
jne    1400 <main+0x200>
mov    %rbx,%rdi
call   10d0 <aio_return@plt>
test   %eax,%eax
js     143d <main+0x23d>
cmp    $0x400,%eax
je     1295 <main+0x95>
mov    0x0(%r13),%ebx
mov    %ebx,%edi
call   1120 <strerror@plt>
lea    0xf5f(%rip),%rdi
lea    0xdb7(%rip),%rsi
mov    $0x60,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1090 <test_msg@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    %ebp,%edi
call   1120 <strerror@plt>
lea    0xe8f(%rip),%rdi
lea    0xd87(%rip),%rsi
mov    $0x47,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1090 <test_msg@plt>
mov    $0x1,%ebx
jmp    1490 <main+0x290>
mov    0x0(%r13),%ebx
cmp    (%r14),%ebx
jne    13e4 <main+0x1e4>
xor    %eax,%eax
call   1100 <test_go@plt>
test   %rax,%rax
je     1477 <main+0x277>
mov    0x0(%r13),%ebx
mov    %ebx,%edi
call   1120 <strerror@plt>
lea    0xe10(%rip),%rdi
lea    0xd3a(%rip),%rsi
mov    $0x37,%edx
jmp    1470 <main+0x270>
mov    %eax,%edi
call   1120 <strerror@plt>
mov    %eax,%ebx
mov    0x0(%r13),%ebp
mov    %ebp,%edi
call   1120 <strerror@plt>
lea    0xe4e(%rip),%rdi
lea    0xd11(%rip),%rsi
mov    $0x54,%edx
mov    %ebx,%ecx
mov    %ebp,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1090 <test_msg@plt>
mov    $0x1,%ebx
jmp    1490 <main+0x290>
mov    0x0(%r13),%ebx
cmp    (%r14),%ebx
jne    1456 <main+0x256>
xor    %eax,%eax
call   1100 <test_go@plt>
test   %rax,%rax
je     1477 <main+0x277>
mov    0x0(%r13),%ebx
mov    %ebx,%edi
call   1120 <strerror@plt>
lea    0xe3c(%rip),%rdi
lea    0xcc8(%rip),%rsi
mov    $0x5c,%edx
mov    %ebx,%ecx
jmp    13b3 <main+0x1b3>
mov    0x4(%rsp),%edi
call   1080 <close@plt>
lea    0xe83(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <test_msg@plt>
mov    %ebx,%eax
add    $0x538,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b2d(%rip),%rbp
mov    0x0(%rbp),%edi
call   1120 <strerror@plt>
mov    %eax,%ebx
mov    0x0(%rbp),%ebp
mov    %ebp,%edi
call   1120 <strerror@plt>
lea    0xc3a(%rip),%rdi
lea    0xc66(%rip),%rsi
mov    $0x1e,%edx
jmp    1502 <main+0x302>
mov    0x2afd(%rip),%rbp
mov    0x0(%rbp),%edi
call   1120 <strerror@plt>
mov    %eax,%ebx
mov    0x0(%rbp),%ebp
mov    %ebp,%edi
call   1120 <strerror@plt>
lea    0xcd8(%rip),%rdi
lea    0xc36(%rip),%rsi
mov    $0x25,%edx
mov    %ebx,%ecx
mov    %ebp,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1090 <test_msg@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.aiocb = type { i32, i8*, i32, i64 }
@__const.main.tmpfname = [256 x i8] c"/tmp/file_aio.XXXXXX\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [51 x i8] c"ERR: %s:%d: Error at open(): %s (errno = %d (%s))\0A\00"
@.str.1 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/test/zdtm/live/streaming/file_aio.c\00"
@errno = global i32 0
@.str.2 = [52 x i8] c"ERR: %s:%d: Error at write(): %s (errno = %d (%s))\0A\00"
@EINTR = global i32 0
@.str.3 = [50 x i8] c"ERR: %s:%d: aio_read failed %m (errno = %d (%s))\0A\00"
@.str.4 = [51 x i8] c"ERR: %s:%d: aio_read failed %s\0A (errno = %d (%s))\0A\00"
@.str.5 = [53 x i8] c"ERR: %s:%d: aio_suspend failed %m (errno = %d (%s))\0A\00"
@EINPROGRESS = global i32 0
@.str.6 = [55 x i8] c"ERR: %s:%d: Error at aio_error() %s (errno = %d (%s))\0A\00"
@.str.7 = [52 x i8] c"ERR: %s:%d: aio_return failed %m (errno = %d (%s))\0A\00"
@.str.8 = [54 x i8] c"ERR: %s:%d: Error at aio_return()\0A (errno = %d (%s))\0A\00"
@.str.9 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = alloca %struct.aiocb
%9 = alloca [1 x %struct.aiocb*]
%10 = alloca [256 x i8]
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call i32 @test_init(i32 %12, i8** %13)
%15 = bitcast [256 x i8]* %10 to i8*
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%17 = call i32 @mkstemp(i8* %16)
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %28
20: ; preds = %2
%21 = load i32, i32* @errno
%22 = call i32 @strerror(i32 %21)
%23 = load i32, i32* @errno
%24 = load i32, i32* @errno
%25 = call i32 @strerror(i32 %24)
%26 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 30, i32 %22, i32 %23, i32 %25)
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %2
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%30 = call i32 @unlink(i8* %29)
%31 = load i32, i32* %7
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%33 = call i32 @write(i32 %31, i8* %32, i32 1024)
%34 = icmp ne i32 %33, 1024
br i1 %34, label %35, label %43
35: ; preds = %28
%36 = load i32, i32* @errno
%37 = call i32 @strerror(i32 %36)
%38 = load i32, i32* @errno
%39 = load i32, i32* @errno
%40 = call i32 @strerror(i32 %39)
%41 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 37, i32 %37, i32 %38, i32 %40)
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %28
%44 = call i32 (...) @test_daemon()
br label %45
45: ; preds = %150, %43
%46 = call i64 (...) @test_go()
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %151
48: ; preds = %45
%49 = call i32 @memset(%struct.aiocb* %8, i32 0, i32 32)
%50 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %8, i32 0, i32 3
store i64 0, i64* %50
%51 = load i32, i32* %7
%52 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %8, i32 0, i32 0
store i32 %51, i32* %52
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%54 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %8, i32 0, i32 1
store i8* %53, i8** %54
%55 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %8, i32 0, i32 2
store i32 1024, i32* %55
%56 = call i32 @aio_read(%struct.aiocb* %8)
store i32 %56, i32* %11
%57 = load i32, i32* %11
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %72
59: ; preds = %48
%60 = load i32, i32* @errno
%61 = load i32, i32* @EINTR
%62 = icmp eq i32 %60, %61
br i1 %62, label %63, label %67
63: ; preds = %59
%64 = call i64 (...) @test_go()
%65 = icmp ne i64 %64, 0
br i1 %65, label %67, label %66
66: ; preds = %63
br label %151
67: ; preds = %63, %59
%68 = load i32, i32* @errno
%69 = load i32, i32* @errno
%70 = call i32 @strerror(i32 %69)
%71 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 55, i32 %68, i32 %70)
store i32 1, i32* %3
br label %155
72: ; preds = %48
%73 = load i32, i32* %11
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %83
75: ; preds = %72
%76 = load i32, i32* @errno
%77 = call i32 @strerror(i32 %76)
%78 = load i32, i32* @errno
%79 = load i32, i32* @errno
%80 = call i32 @strerror(i32 %79)
%81 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 60, i32 %77, i32 %78, i32 %80)
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %72
%84 = getelementptr inbounds [1 x %struct.aiocb*], [1 x %struct.aiocb*]* %9, i64 0, i64 0
store %struct.aiocb* %8, %struct.aiocb** %84
br label %85
85: ; preds = %113, %83
%86 = getelementptr inbounds [1 x %struct.aiocb*], [1 x %struct.aiocb*]* %9, i64 0, i64 0
%87 = call i32 @aio_suspend(%struct.aiocb** %86, i32 1, i32* null)
store i32 %87, i32* %11
%88 = load i32, i32* %11
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %108
90: ; preds = %85
%91 = load i32, i32* @errno
%92 = load i32, i32* @EINTR
%93 = icmp eq i32 %91, %92
br i1 %93, label %94, label %98
94: ; preds = %90
%95 = call i64 (...) @test_go()
%96 = icmp ne i64 %95, 0
br i1 %96, label %98, label %97
97: ; preds = %94
br label %151
98: ; preds = %94, %90
%99 = load i32, i32* @errno
%100 = load i32, i32* @EINTR
%101 = icmp ne i32 %99, %100
br i1 %101, label %102, label %107
102: ; preds = %98
%103 = load i32, i32* @errno
%104 = load i32, i32* @errno
%105 = call i32 @strerror(i32 %104)
%106 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 71, i32 %103, i32 %105)
store i32 1, i32* %3
br label %155
107: ; preds = %98
br label %108
108: ; preds = %107, %85
%109 = call i32 @aio_error(%struct.aiocb* %8)
store i32 %109, i32* %11
%110 = load i32, i32* %11
%111 = load i32, i32* @EINPROGRESS
%112 = icmp eq i32 %110, %111
br i1 %112, label %113, label %114
113: ; preds = %108
br label %85
114: ; preds = %108
%115 = load i32, i32* %11
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %124
117: ; preds = %114
%118 = load i32, i32* %11
%119 = call i32 @strerror(i32 %118)
%120 = load i32, i32* @errno
%121 = load i32, i32* @errno
%122 = call i32 @strerror(i32 %121)
%123 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 84, i32 %119, i32 %120, i32 %122)
store i32 1, i32* %3
br label %155
124: ; preds = %114
%125 = call i32 @aio_return(%struct.aiocb* %8)
store i32 %125, i32* %11
%126 = load i32, i32* %11
%127 = icmp slt i32 %126, 0
br i1 %127, label %128, label %141
128: ; preds = %124
%129 = load i32, i32* @errno
%130 = load i32, i32* @EINTR
%131 = icmp eq i32 %129, %130
br i1 %131, label %132, label %136
132: ; preds = %128
%133 = call i64 (...) @test_go()
%134 = icmp ne i64 %133, 0
br i1 %134, label %136, label %135
135: ; preds = %132
br label %151
136: ; preds = %132, %128
%137 = load i32, i32* @errno
%138 = load i32, i32* @errno
%139 = call i32 @strerror(i32 %138)
%140 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 92, i32 %137, i32 %139)
store i32 1, i32* %3
br label %155
141: ; preds = %124
%142 = load i32, i32* %11
%143 = icmp ne i32 %142, 1024
br i1 %143, label %144, label %150
144: ; preds = %141
%145 = load i32, i32* @errno
%146 = load i32, i32* @errno
%147 = call i32 @strerror(i32 %146)
%148 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 96, i32 %145, i32 %147)
%149 = call i32 @exit(i32 1)
unreachable
150: ; preds = %141
br label %45
151: ; preds = %135, %97, %66, %45
%152 = load i32, i32* %7
%153 = call i32 @close(i32 %152)
%154 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %155
155: ; preds = %151, %136, %117, %102, %67
%156 = load i32, i32* %3
ret i32 %156
}

LLVM IR (-O2):
%struct.aiocb = type { i32, i8*, i32, i64 }
@__const.main.tmpfname = [256 x i8] c"/tmp/file_aio.XXXXXX\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [51 x i8] c"ERR: %s:%d: Error at open(): %s (errno = %d (%s))\0A\00"
@.str.1 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/LK4D4/criu/refs/heads/master/test/zdtm/live/streaming/file_aio.c\00"
@errno = global i32 0
@.str.2 = [52 x i8] c"ERR: %s:%d: Error at write(): %s (errno = %d (%s))\0A\00"
@EINTR = global i32 0
@.str.3 = [50 x i8] c"ERR: %s:%d: aio_read failed %m (errno = %d (%s))\0A\00"
@.str.5 = [53 x i8] c"ERR: %s:%d: aio_suspend failed %m (errno = %d (%s))\0A\00"
@EINPROGRESS = global i32 0
@.str.6 = [55 x i8] c"ERR: %s:%d: Error at aio_error() %s (errno = %d (%s))\0A\00"
@.str.7 = [52 x i8] c"ERR: %s:%d: aio_return failed %m (errno = %d (%s))\0A\00"
@.str.8 = [54 x i8] c"ERR: %s:%d: Error at aio_return()\0A (errno = %d (%s))\0A\00"
@.str.9 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [1024 x i8]
%4 = alloca %struct.aiocb
%5 = alloca [1 x %struct.aiocb*]
%6 = alloca [256 x i8]
%7 = tail call i32 @test_init(i32 %0, i8** %1)
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%9 = bitcast %struct.aiocb* %4 to i8*
%10 = bitcast [1 x %struct.aiocb*]* %5 to i8*
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%12 = call i32 @mkstemp(i8* %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i32, i32* @errno
%16 = call i32 @strerror(i32 %15)
%17 = load i32, i32* @errno
%18 = call i32 @strerror(i32 %17)
%19 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 30, i32 %16, i32 %17, i32 %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = call i32 @unlink(i8* %11)
%23 = call i32 @write(i32 %12, i8* %8, i32 1024)
%24 = icmp eq i32 %23, 1024
br i1 %24, label %32, label %25
25: ; preds = %21
%26 = load i32, i32* @errno
%27 = call i32 @strerror(i32 %26)
%28 = load i32, i32* @errno
%29 = call i32 @strerror(i32 %28)
%30 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 37, i32 %27, i32 %28, i32 %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %21
%33 = call i32 (...) @test_daemon()
%34 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %4, i64 0, i32 3
%35 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %4, i64 0, i32 0
%36 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %4, i64 0, i32 1
%37 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %4, i64 0, i32 2
%38 = getelementptr inbounds [1 x %struct.aiocb*], [1 x %struct.aiocb*]* %5, i64 0, i64 0
br label %39
39: ; preds = %107, %32
%40 = call i64 (...) @test_go()
%41 = icmp eq i64 %40, 0
br i1 %41, label %114, label %42
42: ; preds = %39
%43 = call i32 @memset(%struct.aiocb* %4, i32 0, i32 32)
store i64 0, i64* %34
store i32 %12, i32* %35
store i8* %8, i8** %36
store i32 1024, i32* %37
%44 = call i32 @aio_read(%struct.aiocb* %4)
%45 = icmp slt i32 %44, 0
br i1 %45, label %46, label %59
46: ; preds = %42
%47 = load i32, i32* @errno
%48 = load i32, i32* @EINTR
%49 = icmp eq i32 %47, %48
br i1 %49, label %50, label %55
50: ; preds = %46
%51 = call i64 (...) @test_go()
%52 = icmp eq i64 %51, 0
br i1 %52, label %114, label %53
53: ; preds = %50
%54 = load i32, i32* @errno
br label %55
55: ; preds = %53, %46
%56 = phi i32 [ %54, %53 ], [ %47, %46 ]
%57 = call i32 @strerror(i32 %56)
%58 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 55, i32 %56, i32 %57)
br label %117
59: ; preds = %42
store %struct.aiocb* %4, %struct.aiocb** %38
br label %60
60: ; preds = %80, %59
%61 = call i32 @aio_suspend(%struct.aiocb** %38, i32 1, i32* null)
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %80
63: ; preds = %60
%64 = load i32, i32* @errno
%65 = load i32, i32* @EINTR
%66 = icmp eq i32 %64, %65
br i1 %66, label %67, label %73
67: ; preds = %63
%68 = call i64 (...) @test_go()
%69 = icmp eq i64 %68, 0
br i1 %69, label %114, label %70
70: ; preds = %67
%71 = load i32, i32* @errno
%72 = load i32, i32* @EINTR
br label %73
73: ; preds = %70, %63
%74 = phi i32 [ %72, %70 ], [ %65, %63 ]
%75 = phi i32 [ %71, %70 ], [ %64, %63 ]
%76 = icmp eq i32 %75, %74
br i1 %76, label %80, label %77
77: ; preds = %73
%78 = call i32 @strerror(i32 %75)
%79 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 71, i32 %75, i32 %78)
br label %117
80: ; preds = %73, %60
%81 = call i32 @aio_error(%struct.aiocb* %4)
%82 = load i32, i32* @EINPROGRESS
%83 = icmp eq i32 %81, %82
br i1 %83, label %60, label %84
84: ; preds = %80
%85 = icmp eq i32 %81, 0
br i1 %85, label %91, label %86
86: ; preds = %84
%87 = call i32 @strerror(i32 %81)
%88 = load i32, i32* @errno
%89 = call i32 @strerror(i32 %88)
%90 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 84, i32 %87, i32 %88, i32 %89)
br label %117
91: ; preds = %84
%92 = call i32 @aio_return(%struct.aiocb* %4)
%93 = icmp slt i32 %92, 0
br i1 %93, label %94, label %107
94: ; preds = %91
%95 = load i32, i32* @errno
%96 = load i32, i32* @EINTR
%97 = icmp eq i32 %95, %96
br i1 %97, label %98, label %103
98: ; preds = %94
%99 = call i64 (...) @test_go()
%100 = icmp eq i64 %99, 0
br i1 %100, label %114, label %101
101: ; preds = %98
%102 = load i32, i32* @errno
br label %103
103: ; preds = %101, %94
%104 = phi i32 [ %102, %101 ], [ %95, %94 ]
%105 = call i32 @strerror(i32 %104)
%106 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 92, i32 %104, i32 %105)
br label %117
107: ; preds = %91
%108 = icmp eq i32 %92, 1024
br i1 %108, label %39, label %109
109: ; preds = %107
%110 = load i32, i32* @errno
%111 = call i32 @strerror(i32 %110)
%112 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 96, i32 %110, i32 %111)
%113 = call i32 @exit(i32 1)
unreachable
114: ; preds = %39, %67, %98, %50
%115 = call i32 @close(i32 %12)
%116 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %117
117: ; preds = %114, %103, %86, %77, %55
%118 = phi i32 [ 1, %55 ], [ 0, %114 ], [ 1, %77 ], [ 1, %86 ], [ 1, %103 ]
ret i32 %118
}