#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: "
             "mkstemp() failed"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/streaming/file_aio.c",
             30, errno, strerror(errno));
    exit(1);
  }
  unlink(tmpfname);
  if (write(fd, buf, 1024) != 1024) {
    test_msg("ERR: %s:%d: "
             "Error at write()"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/streaming/file_aio.c",
             37, 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"
               " (errno = %d (%s))\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/"
               "heads/master/test/zdtm/live/streaming/file_aio.c",
               54, errno, strerror(errno));
      return 1;
    }
    if (ret < 0) {
      test_msg("ERR: %s:%d: "
               "aio_read failed"
               " (errno = %d (%s))\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/"
               "heads/master/test/zdtm/live/streaming/file_aio.c",
               59, 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"
                 " (errno = %d (%s))\n",
                 "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/"
                 "refs/heads/master/test/zdtm/live/streaming/file_aio.c",
                 70, 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\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/"
               "heads/master/test/zdtm/live/streaming/file_aio.c",
               83, strerror(ret));
      return 1;
    }
    ret = aio_return(&aiocb);
    if (ret < 0) {
      if ((errno == EINTR) && (!test_go()))
        break;
      test_msg("ERR: %s:%d: "
               "aio_return failed"
               " (errno = %d (%s))\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/"
               "heads/master/test/zdtm/live/streaming/file_aio.c",
               91, errno, strerror(errno));
      return 1;
    }
    if (ret != 1024) {
      test_msg("ERR: %s:%d: "
               "Error at aio_return()"
               " (errno = %d (%s))\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/"
               "heads/master/test/zdtm/live/streaming/file_aio.c",
               95, errno, strerror(errno));
      exit(1);
    }
  }
  close(fd);
  test_msg("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x560,%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    12a6 <main+0xa6>
mov    0x2d75(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x548(%rbp)
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x548(%rbp),%ecx
mov    %eax,%r8d
lea    0xe77(%rip),%rdi
lea    0xea0(%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     131e <main+0x11e>
mov    0x2cfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54c(%rbp)
mov    0x2cee(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x54c(%rbp),%ecx
mov    %eax,%r8d
lea    0xed7(%rip),%rdi
lea    0xe28(%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     1699 <main+0x499>
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    1411 <main+0x211>
mov    0x2c3a(%rip),%rax
mov    (%rax),%eax
mov    0x2c29(%rip),%rcx
cmp    (%rcx),%eax
jne    13c5 <main+0x1c5>
mov    $0x0,%al
call   1100 <test_go@plt>
cmp    $0x0,%rax
jne    13c5 <main+0x1c5>
jmp    1699 <main+0x499>
mov    0x2c0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x550(%rbp)
mov    0x2bfd(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x550(%rbp),%ecx
mov    %eax,%r8d
lea    0xe16(%rip),%rdi
lea    0xd37(%rip),%rsi
mov    $0x36,%edx
mov    $0x0,%al
call   1090 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    16b9 <main+0x4b9>
cmpl   $0x0,-0x544(%rbp)
jge    1468 <main+0x268>
mov    0x2bb3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x554(%rbp)
mov    0x2ba4(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x554(%rbp),%ecx
mov    %eax,%r8d
lea    0xdbd(%rip),%rdi
lea    0xcde(%rip),%rsi
mov    $0x3b,%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    1535 <main+0x335>
mov    0x2b33(%rip),%rax
mov    (%rax),%eax
mov    0x2b22(%rip),%rcx
cmp    (%rcx),%eax
jne    14cc <main+0x2cc>
mov    $0x0,%al
call   1100 <test_go@plt>
cmp    $0x0,%rax
jne    14cc <main+0x2cc>
jmp    1699 <main+0x499>
mov    0x2b05(%rip),%rax
mov    (%rax),%eax
mov    0x2af4(%rip),%rcx
cmp    (%rcx),%eax
je     1530 <main+0x330>
mov    0x2aed(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x558(%rbp)
mov    0x2ade(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x558(%rbp),%ecx
mov    %eax,%r8d
lea    0xd26(%rip),%rdi
lea    0xc18(%rip),%rsi
mov    $0x46,%edx
mov    $0x0,%al
call   1090 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    16b9 <main+0x4b9>
jmp    1535 <main+0x335>
lea    -0x438(%rbp),%rdi
call   10c0 <aio_error@plt>
mov    %eax,-0x544(%rbp)
mov    -0x544(%rbp),%eax
mov    0x2a94(%rip),%rcx
cmp    (%rcx),%eax
jne    1561 <main+0x361>
jmp    1476 <main+0x276>
cmpl   $0x0,-0x544(%rbp)
je     15a1 <main+0x3a1>
mov    -0x544(%rbp),%edi
call   1120 <strerror@plt>
mov    %eax,%ecx
lea    0xce7(%rip),%rdi
lea    0xba7(%rip),%rsi
mov    $0x53,%edx
mov    $0x0,%al
call   1090 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    16b9 <main+0x4b9>
lea    -0x438(%rbp),%rdi
call   10d0 <aio_return@plt>
mov    %eax,-0x544(%rbp)
cmpl   $0x0,-0x544(%rbp)
jge    163a <main+0x43a>
mov    0x2a11(%rip),%rax
mov    (%rax),%eax
mov    0x2a00(%rip),%rcx
cmp    (%rcx),%eax
jne    15ee <main+0x3ee>
mov    $0x0,%al
call   1100 <test_go@plt>
cmp    $0x0,%rax
jne    15ee <main+0x3ee>
jmp    1699 <main+0x499>
mov    0x29e3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x55c(%rbp)
mov    0x29d4(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x55c(%rbp),%ecx
mov    %eax,%r8d
lea    0xc74(%rip),%rdi
lea    0xb0e(%rip),%rsi
mov    $0x5b,%edx
mov    $0x0,%al
call   1090 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    16b9 <main+0x4b9>
cmpl   $0x400,-0x544(%rbp)
je     1694 <main+0x494>
mov    0x2987(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x560(%rbp)
mov    0x2978(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x560(%rbp),%ecx
mov    %eax,%r8d
lea    0xc49(%rip),%rdi
lea    0xab2(%rip),%rsi
mov    $0x5f,%edx
mov    $0x0,%al
call   1090 <test_msg@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    1325 <main+0x125>
mov    -0x414(%rbp),%edi
call   1080 <close@plt>
lea    0xc4a(%rip),%rdi
mov    $0x0,%al
call   1090 <test_msg@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x560,%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     1480 <main+0x280>
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    14a5 <main+0x2a5>
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     1453 <main+0x253>
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     13b6 <main+0x1b6>
mov    %rbx,0x8(%rsp)
jmp    130d <main+0x10d>
mov    0x0(%r13),%ebp
mov    (%r14),%eax
cmp    %eax,%ebp
jne    1386 <main+0x186>
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    1453 <main+0x253>
nopl   0x0(%rax)
test   %eax,%eax
jne    13ef <main+0x1ef>
mov    %rbx,%rdi
call   10d0 <aio_return@plt>
test   %eax,%eax
js     1419 <main+0x219>
cmp    $0x400,%eax
je     1295 <main+0x95>
mov    0x0(%r13),%ebx
mov    %ebx,%edi
call   1120 <strerror@plt>
lea    0xf4b(%rip),%rdi
lea    0xdb4(%rip),%rsi
mov    $0x5f,%edx
jmp    14c8 <main+0x2c8>
mov    %ebp,%edi
call   1120 <strerror@plt>
lea    0xea3(%rip),%rdi
lea    0xd95(%rip),%rsi
mov    $0x46,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1090 <test_msg@plt>
mov    $0x1,%ebx
jmp    146c <main+0x26c>
mov    0x0(%r13),%ebx
cmp    (%r14),%ebx
jne    13d3 <main+0x1d3>
xor    %eax,%eax
call   1100 <test_go@plt>
test   %rax,%rax
je     1453 <main+0x253>
mov    0x0(%r13),%ebx
mov    %ebx,%edi
call   1120 <strerror@plt>
lea    0xe27(%rip),%rdi
lea    0xd48(%rip),%rsi
mov    $0x36,%edx
jmp    144c <main+0x24c>
mov    %eax,%edi
call   1120 <strerror@plt>
lea    0xe6c(%rip),%rdi
lea    0xd2c(%rip),%rsi
mov    $0x53,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1090 <test_msg@plt>
mov    $0x1,%ebx
jmp    146c <main+0x26c>
mov    0x0(%r13),%ebx
cmp    (%r14),%ebx
jne    1432 <main+0x232>
xor    %eax,%eax
call   1100 <test_go@plt>
test   %rax,%rax
je     1453 <main+0x253>
mov    0x0(%r13),%ebx
mov    %ebx,%edi
call   1120 <strerror@plt>
lea    0xe4f(%rip),%rdi
lea    0xce9(%rip),%rsi
mov    $0x5b,%edx
mov    %ebx,%ecx
jmp    13a2 <main+0x1a2>
mov    0x4(%rsp),%edi
call   1080 <close@plt>
lea    0xe92(%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    0x2b51(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1120 <strerror@plt>
lea    0xc69(%rip),%rdi
lea    0xc92(%rip),%rsi
mov    $0x1e,%edx
jmp    14c8 <main+0x2c8>
mov    0x2b2c(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1120 <strerror@plt>
lea    0xd1c(%rip),%rdi
lea    0xc6d(%rip),%rsi
mov    $0x25,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
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 = [48 x i8] c"ERR: %s:%d: mkstemp() failed (errno = %d (%s))\0A\00"
@.str.1 = [168 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/master/test/zdtm/live/streaming/file_aio.c\00"
@errno = global i32 0
@.str.2 = [48 x i8] c"ERR: %s:%d: Error at write() (errno = %d (%s))\0A\00"
@EINTR = global i32 0
@.str.3 = [47 x i8] c"ERR: %s:%d: aio_read failed (errno = %d (%s))\0A\00"
@.str.4 = [50 x i8] c"ERR: %s:%d: aio_suspend failed (errno = %d (%s))\0A\00"
@EINPROGRESS = global i32 0
@.str.5 = [38 x i8] c"ERR: %s:%d: Error at aio_error(): %s\0A\00"
@.str.6 = [49 x i8] c"ERR: %s:%d: aio_return failed (errno = %d (%s))\0A\00"
@.str.7 = [53 x i8] c"ERR: %s:%d: Error at aio_return() (errno = %d (%s))\0A\00"
@.str.8 = [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 %26
20: ; preds = %2
%21 = load i32, i32* @errno
%22 = load i32, i32* @errno
%23 = call i32 @strerror(i32 %22)
%24 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.1, i64 0, i64 0), i32 30, i32 %21, i32 %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%28 = call i32 @unlink(i8* %27)
%29 = load i32, i32* %7
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%31 = call i32 @write(i32 %29, i8* %30, i32 1024)
%32 = icmp ne i32 %31, 1024
br i1 %32, label %33, label %39
33: ; preds = %26
%34 = load i32, i32* @errno
%35 = load i32, i32* @errno
%36 = call i32 @strerror(i32 %35)
%37 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.1, i64 0, i64 0), i32 37, i32 %34, i32 %36)
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %26
%40 = call i32 (...) @test_daemon()
br label %41
41: ; preds = %141, %39
%42 = call i64 (...) @test_go()
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %142
44: ; preds = %41
%45 = call i32 @memset(%struct.aiocb* %8, i32 0, i32 32)
%46 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %8, i32 0, i32 3
store i64 0, i64* %46
%47 = load i32, i32* %7
%48 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %8, i32 0, i32 0
store i32 %47, i32* %48
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%50 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %8, i32 0, i32 1
store i8* %49, i8** %50
%51 = getelementptr inbounds %struct.aiocb, %struct.aiocb* %8, i32 0, i32 2
store i32 1024, i32* %51
%52 = call i32 @aio_read(%struct.aiocb* %8)
store i32 %52, i32* %11
%53 = load i32, i32* %11
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %68
55: ; preds = %44
%56 = load i32, i32* @errno
%57 = load i32, i32* @EINTR
%58 = icmp eq i32 %56, %57
br i1 %58, label %59, label %63
59: ; preds = %55
%60 = call i64 (...) @test_go()
%61 = icmp ne i64 %60, 0
br i1 %61, label %63, label %62
62: ; preds = %59
br label %142
63: ; preds = %59, %55
%64 = load i32, i32* @errno
%65 = load i32, i32* @errno
%66 = call i32 @strerror(i32 %65)
%67 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.1, i64 0, i64 0), i32 54, i32 %64, i32 %66)
store i32 1, i32* %3
br label %146
68: ; preds = %44
%69 = load i32, i32* %11
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %77
71: ; preds = %68
%72 = load i32, i32* @errno
%73 = load i32, i32* @errno
%74 = call i32 @strerror(i32 %73)
%75 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.1, i64 0, i64 0), i32 59, i32 %72, i32 %74)
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %68
%78 = getelementptr inbounds [1 x %struct.aiocb*], [1 x %struct.aiocb*]* %9, i64 0, i64 0
store %struct.aiocb* %8, %struct.aiocb** %78
br label %79
79: ; preds = %107, %77
%80 = getelementptr inbounds [1 x %struct.aiocb*], [1 x %struct.aiocb*]* %9, i64 0, i64 0
%81 = call i32 @aio_suspend(%struct.aiocb** %80, i32 1, i32* null)
store i32 %81, i32* %11
%82 = load i32, i32* %11
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %102
84: ; preds = %79
%85 = load i32, i32* @errno
%86 = load i32, i32* @EINTR
%87 = icmp eq i32 %85, %86
br i1 %87, label %88, label %92
88: ; preds = %84
%89 = call i64 (...) @test_go()
%90 = icmp ne i64 %89, 0
br i1 %90, label %92, label %91
91: ; preds = %88
br label %142
92: ; preds = %88, %84
%93 = load i32, i32* @errno
%94 = load i32, i32* @EINTR
%95 = icmp ne i32 %93, %94
br i1 %95, label %96, label %101
96: ; preds = %92
%97 = load i32, i32* @errno
%98 = load i32, i32* @errno
%99 = call i32 @strerror(i32 %98)
%100 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.1, i64 0, i64 0), i32 70, i32 %97, i32 %99)
store i32 1, i32* %3
br label %146
101: ; preds = %92
br label %102
102: ; preds = %101, %79
%103 = call i32 @aio_error(%struct.aiocb* %8)
store i32 %103, i32* %11
%104 = load i32, i32* %11
%105 = load i32, i32* @EINPROGRESS
%106 = icmp eq i32 %104, %105
br i1 %106, label %107, label %108
107: ; preds = %102
br label %79
108: ; preds = %102
%109 = load i32, i32* %11
%110 = icmp ne i32 %109, 0
br i1 %110, label %111, label %115
111: ; preds = %108
%112 = load i32, i32* %11
%113 = call i32 @strerror(i32 %112)
%114 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.1, i64 0, i64 0), i32 83, i32 %113)
store i32 1, i32* %3
br label %146
115: ; preds = %108
%116 = call i32 @aio_return(%struct.aiocb* %8)
store i32 %116, i32* %11
%117 = load i32, i32* %11
%118 = icmp slt i32 %117, 0
br i1 %118, label %119, label %132
119: ; preds = %115
%120 = load i32, i32* @errno
%121 = load i32, i32* @EINTR
%122 = icmp eq i32 %120, %121
br i1 %122, label %123, label %127
123: ; preds = %119
%124 = call i64 (...) @test_go()
%125 = icmp ne i64 %124, 0
br i1 %125, label %127, label %126
126: ; preds = %123
br label %142
127: ; preds = %123, %119
%128 = load i32, i32* @errno
%129 = load i32, i32* @errno
%130 = call i32 @strerror(i32 %129)
%131 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.1, i64 0, i64 0), i32 91, i32 %128, i32 %130)
store i32 1, i32* %3
br label %146
132: ; preds = %115
%133 = load i32, i32* %11
%134 = icmp ne i32 %133, 1024
br i1 %134, label %135, label %141
135: ; preds = %132
%136 = load i32, i32* @errno
%137 = load i32, i32* @errno
%138 = call i32 @strerror(i32 %137)
%139 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.1, i64 0, i64 0), i32 95, i32 %136, i32 %138)
%140 = call i32 @exit(i32 1)
unreachable
141: ; preds = %132
br label %41
142: ; preds = %126, %91, %62, %41
%143 = load i32, i32* %7
%144 = call i32 @close(i32 %143)
%145 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %3
br label %146
146: ; preds = %142, %127, %111, %96, %63
%147 = load i32, i32* %3
ret i32 %147
}

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