#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 */

/* Variables and functions */
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int fork();
int getpid();
int getppid();
scalar_t__ pipe(int *);
int read(int, char *, int);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ test_daemon();
int /*<<< orphan*/ test_init(int, char **);
int /*<<< orphan*/ test_msg(char *, ...);
int /*<<< orphan*/ test_waitsig();
int write(int, char *, int);
int main(int argc, char **argv) {
  char x;
  int pid, ppid;
  int sp[2], fp[2], rp[2];
  test_init(argc, argv);
  if (pipe(sp) || pipe(fp) || pipe(rp)) {
    test_msg("ERR: %s:%d: "
             "pipe"
             " (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/static/pstree.c",
             20, errno, strerror(errno));
    return 1;
  }
  pid = fork();
  if (pid == 0) {
    close(sp[0]);
    close(fp[1]);
    close(rp[0]);
    pid = getpid();
    ppid = getppid();
    close(sp[1]);
    if (read(fp[0], &x, 1)) {
      test_msg("ERR: %s:%d: "
               "read"
               " (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/static/pstree.c",
               35, errno, strerror(errno));
      return 1;
    }
    close(fp[0]);
    if (pid != getpid())
      x = 'p';
    else if (ppid != getppid())
      x = 'P';
    else
      x = '0';
    if (write(rp[1], &x, 1) != 1) {
      test_msg("ERR: %s:%d: "
               "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/static/pstree.c",
               48, errno, strerror(errno));
      return 1;
    }
    close(rp[1]);
    _exit(0);
  }
  x = 'X';
  close(sp[1]);
  close(fp[0]);
  close(rp[1]);
  if (read(sp[0], &x, 1)) {
    test_msg("ERR: %s:%d: "
             "read"
             " (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/static/pstree.c",
             61, errno, strerror(errno));
    return 1;
  }
  test_daemon();
  test_waitsig();
  close(fp[1]);
  if (read(rp[0], &x, 1) != 1) {
    test_msg("ERR: %s:%d: "
             "read"
             " (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/static/pstree.c",
             70, errno, strerror(errno));
    return 1;
  }
  close(rp[0]);
  if (x == 'X')
    test_msg("FAIL: %s:%d: "
             "Sync 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/static/pstree.c",
             76, errno, strerror(errno));
  else if (x == 'p')
    test_msg("FAIL: %s:%d: "
             "Pid 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/static/pstree.c",
             78, errno, strerror(errno));
  else if (x == 'P')
    test_msg("FAIL: %s:%d: "
             "PPid 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/static/pstree.c",
             80, errno, strerror(errno));
  else if (x != '0')
    test_msg("FAIL: %s:%d: "
             "Shit happened"
             " (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/static/pstree.c",
             82, errno, strerror(errno));
  else
    test_msg("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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    -0x24(%rbp),%rdi
call   1090 <pipe@plt>
cmp    $0x0,%rax
jne    122b <main+0x5b>
lea    -0x2c(%rbp),%rdi
call   1090 <pipe@plt>
cmp    $0x0,%rax
jne    122b <main+0x5b>
lea    -0x34(%rbp),%rdi
call   1090 <pipe@plt>
cmp    $0x0,%rax
je     1271 <main+0xa1>
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x38(%rbp),%ecx
mov    %eax,%r8d
lea    0xdae(%rip),%rdi
lea    0xdcb(%rip),%rsi
mov    $0x14,%edx
mov    $0x0,%al
call   10a0 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    162d <main+0x45d>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    13df <main+0x20f>
mov    -0x24(%rbp),%edi
call   1080 <close@plt>
mov    -0x28(%rbp),%edi
call   1080 <close@plt>
mov    -0x34(%rbp),%edi
call   1080 <close@plt>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   10d0 <getppid@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
call   1080 <close@plt>
mov    -0x2c(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
cmp    $0x0,%eax
je     1319 <main+0x149>
mov    0x2d06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x3c(%rbp),%ecx
mov    %eax,%r8d
lea    0xdcd(%rip),%rdi
lea    0xd23(%rip),%rsi
mov    $0x23,%edx
mov    $0x0,%al
call   10a0 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    162d <main+0x45d>
mov    -0x2c(%rbp),%edi
call   1080 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
cmp    %ecx,%eax
je     1344 <main+0x174>
movb   $0x70,-0x11(%rbp)
jmp    1370 <main+0x1a0>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    $0x0,%al
call   10d0 <getppid@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
je     1367 <main+0x197>
movb   $0x50,-0x11(%rbp)
jmp    136b <main+0x19b>
movb   $0x30,-0x11(%rbp)
jmp    1370 <main+0x1a0>
mov    -0x30(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0x1,%eax
je     13d0 <main+0x200>
mov    0x2c4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2c43(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x48(%rbp),%ecx
mov    %eax,%r8d
lea    0xd3a(%rip),%rdi
lea    0xc6c(%rip),%rsi
mov    $0x30,%edx
mov    $0x0,%al
call   10a0 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    162d <main+0x45d>
mov    -0x30(%rbp),%edi
call   1080 <close@plt>
xor    %edi,%edi
call   1030 <_exit@plt>
movb   $0x58,-0x11(%rbp)
mov    -0x20(%rbp),%edi
call   1080 <close@plt>
mov    -0x2c(%rbp),%edi
call   1080 <close@plt>
mov    -0x30(%rbp),%edi
call   1080 <close@plt>
mov    -0x24(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
cmp    $0x0,%eax
je     145b <main+0x28b>
mov    0x2bc4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2bb8(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x4c(%rbp),%ecx
mov    %eax,%r8d
lea    0xc8b(%rip),%rdi
lea    0xbe1(%rip),%rsi
mov    $0x3d,%edx
mov    $0x0,%al
call   10a0 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    162d <main+0x45d>
mov    $0x0,%al
call   1070 <test_daemon@plt>
mov    $0x0,%al
call   10c0 <test_waitsig@plt>
mov    -0x28(%rbp),%edi
call   1080 <close@plt>
mov    -0x34(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
cmp    $0x1,%eax
je     14d1 <main+0x301>
mov    0x2b4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2b42(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x50(%rbp),%ecx
mov    %eax,%r8d
lea    0xc15(%rip),%rdi
lea    0xb6b(%rip),%rsi
mov    $0x46,%edx
mov    $0x0,%al
call   10a0 <test_msg@plt>
movl   $0x1,-0x4(%rbp)
jmp    162d <main+0x45d>
mov    -0x34(%rbp),%edi
call   1080 <close@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x58,%eax
jne    1525 <main+0x355>
mov    0x2af3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2ae7(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x54(%rbp),%ecx
mov    %eax,%r8d
lea    0xc03(%rip),%rdi
lea    0xb10(%rip),%rsi
mov    $0x4c,%edx
mov    $0x0,%al
call   10a0 <test_msg@plt>
jmp    1626 <main+0x456>
movsbl -0x11(%rbp),%eax
cmp    $0x70,%eax
jne    1571 <main+0x3a1>
mov    0x2aa7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    0x2a9b(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x58(%rbp),%ecx
mov    %eax,%r8d
lea    0xbe3(%rip),%rdi
lea    0xac4(%rip),%rsi
mov    $0x4e,%edx
mov    $0x0,%al
call   10a0 <test_msg@plt>
jmp    1621 <main+0x451>
movsbl -0x11(%rbp),%eax
cmp    $0x50,%eax
jne    15bd <main+0x3ed>
mov    0x2a5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    0x2a4f(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x5c(%rbp),%ecx
mov    %eax,%r8d
lea    0xbc2(%rip),%rdi
lea    0xa78(%rip),%rsi
mov    $0x50,%edx
mov    $0x0,%al
call   10a0 <test_msg@plt>
jmp    161c <main+0x44c>
movsbl -0x11(%rbp),%eax
cmp    $0x30,%eax
je     1609 <main+0x439>
mov    0x2a0f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2a03(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x60(%rbp),%ecx
mov    %eax,%r8d
lea    0xba2(%rip),%rdi
lea    0xa2c(%rip),%rsi
mov    $0x52,%edx
mov    $0x0,%al
call   10a0 <test_msg@plt>
jmp    1617 <main+0x447>
lea    0xbb1(%rip),%rdi
mov    $0x0,%al
call   10a0 <test_msg@plt>
jmp    161c <main+0x44c>
jmp    1621 <main+0x451>
jmp    1626 <main+0x456>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
call   1040 <test_init@plt>
lea    0x18(%rsp),%rdi
call   1090 <pipe@plt>
test   %rax,%rax
jne    120a <main+0x3a>
lea    0x10(%rsp),%rdi
call   1090 <pipe@plt>
test   %rax,%rax
jne    120a <main+0x3a>
lea    0x8(%rsp),%rdi
call   1090 <pipe@plt>
test   %rax,%rax
je     1249 <main+0x79>
mov    0x2dcf(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10e0 <strerror@plt>
lea    0xe03(%rip),%rdi
lea    0xe20(%rip),%rsi
mov    $0x14,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   10a0 <test_msg@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
call   10f0 <fork@plt>
test   %eax,%eax
je     12bc <main+0xec>
movb   $0x58,0x7(%rsp)
mov    0x1c(%rsp),%edi
call   1080 <close@plt>
mov    0x10(%rsp),%edi
call   1080 <close@plt>
mov    0xc(%rsp),%edi
call   1080 <close@plt>
mov    0x18(%rsp),%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%ebx
mov    $0x1,%edx
call   10b0 <read@plt>
test   %eax,%eax
je     133b <main+0x16b>
mov    0x2d45(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10e0 <strerror@plt>
lea    0xe40(%rip),%rdi
lea    0xd96(%rip),%rsi
mov    $0x3d,%edx
jmp    144d <main+0x27d>
mov    0x18(%rsp),%edi
call   1080 <close@plt>
mov    0x14(%rsp),%edi
call   1080 <close@plt>
mov    0x8(%rsp),%edi
call   1080 <close@plt>
xor    %eax,%eax
call   1060 <getpid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   10d0 <getppid@plt>
mov    %eax,%r14d
mov    0x1c(%rsp),%edi
call   1080 <close@plt>
mov    0x10(%rsp),%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%ebx
mov    $0x1,%edx
call   10b0 <read@plt>
test   %eax,%eax
je     13b1 <main+0x1e1>
mov    0x2cc6(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10e0 <strerror@plt>
lea    0xdc1(%rip),%rdi
lea    0xd17(%rip),%rsi
mov    $0x23,%edx
jmp    144d <main+0x27d>
xor    %eax,%eax
call   1070 <test_daemon@plt>
xor    %eax,%eax
call   10c0 <test_waitsig@plt>
mov    0x14(%rsp),%edi
call   1080 <close@plt>
mov    0x8(%rsp),%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%ebx
mov    $0x1,%edx
call   10b0 <read@plt>
cmp    $0x1,%eax
jne    13d8 <main+0x208>
mov    0x8(%rsp),%edi
call   1080 <close@plt>
mov    0x7(%rsp),%al
add    $0xd0,%al
rol    $0x5,%al
cmp    $0x8,%al
ja     145e <main+0x28e>
movzbl %al,%eax
lea    0xc6d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe42(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <test_msg@plt>
jmp    123e <main+0x6e>
mov    0x10(%rsp),%edi
call   1080 <close@plt>
xor    %eax,%eax
call   1060 <getpid@plt>
cmp    %eax,%ebp
jne    13fd <main+0x22d>
xor    %eax,%eax
call   10d0 <getppid@plt>
cmp    %eax,%r14d
jne    1404 <main+0x234>
movb   $0x30,0x7(%rsp)
jmp    1409 <main+0x239>
mov    0x2c01(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10e0 <strerror@plt>
lea    0xcfc(%rip),%rdi
lea    0xc52(%rip),%rsi
mov    $0x46,%edx
jmp    144d <main+0x27d>
movb   $0x70,0x7(%rsp)
jmp    1409 <main+0x239>
movb   $0x50,0x7(%rsp)
mov    0xc(%rsp),%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%ebx
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0x1,%eax
je     1500 <main+0x330>
mov    0x2baf(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10e0 <strerror@plt>
lea    0xcce(%rip),%rdi
lea    0xc00(%rip),%rsi
mov    $0x30,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   10a0 <test_msg@plt>
jmp    123e <main+0x6e>
mov    0x2b7b(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10e0 <strerror@plt>
lea    0xd42(%rip),%rdi
lea    0xbcc(%rip),%rsi
xor    %ebx,%ebx
mov    $0x52,%edx
jmp    144d <main+0x27d>
mov    0x2b54(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10e0 <strerror@plt>
lea    0xcef(%rip),%rdi
lea    0xba5(%rip),%rsi
xor    %ebx,%ebx
mov    $0x50,%edx
jmp    144d <main+0x27d>
mov    0x2b2d(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10e0 <strerror@plt>
lea    0xc71(%rip),%rdi
lea    0xb7e(%rip),%rsi
xor    %ebx,%ebx
mov    $0x4c,%edx
jmp    144d <main+0x27d>
mov    0x2b03(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10e0 <strerror@plt>
lea    0xc73(%rip),%rdi
lea    0xb54(%rip),%rsi
xor    %ebx,%ebx
mov    $0x4e,%edx
jmp    144d <main+0x27d>
mov    0xc(%rsp),%edi
call   1080 <close@plt>
xor    %edi,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"ERR: %s:%d: pipe (errno = %d (%s))\0A\00"
@.str.1 = [163 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/static/pstree.c\00"
@errno = global i32 0
@.str.2 = [36 x i8] c"ERR: %s:%d: read (errno = %d (%s))\0A\00"
@.str.3 = [37 x i8] c"ERR: %s:%d: write (errno = %d (%s))\0A\00"
@.str.4 = [44 x i8] c"FAIL: %s:%d: Sync failed (errno = %d (%s))\0A\00"
@.str.5 = [43 x i8] c"FAIL: %s:%d: Pid failed (errno = %d (%s))\0A\00"
@.str.6 = [44 x i8] c"FAIL: %s:%d: PPid failed (errno = %d (%s))\0A\00"
@.str.7 = [46 x i8] c"FAIL: %s:%d: Shit happened (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 i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca [2 x i32]
%10 = alloca [2 x i32]
%11 = alloca [2 x 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 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%16 = call i64 @pipe(i32* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %26, label %18
18: ; preds = %2
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%20 = call i64 @pipe(i32* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%24 = call i64 @pipe(i32* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %22, %18, %2
%27 = load i32, i32* @errno
%28 = load i32, i32* @errno
%29 = call i32 @strerror(i32 %28)
%30 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 20, i32 %27, i32 %29)
store i32 1, i32* %3
br label %168
31: ; preds = %22
%32 = call i32 (...) @fork()
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %89
35: ; preds = %31
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%37 = load i32, i32* %36
%38 = call i32 @close(i32 %37)
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%40 = load i32, i32* %39
%41 = call i32 @close(i32 %40)
%42 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%43 = load i32, i32* %42
%44 = call i32 @close(i32 %43)
%45 = call i32 (...) @getpid()
store i32 %45, i32* %7
%46 = call i32 (...) @getppid()
store i32 %46, i32* %8
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%48 = load i32, i32* %47
%49 = call i32 @close(i32 %48)
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%51 = load i32, i32* %50
%52 = call i32 @read(i32 %51, i8* %6, i32 1)
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %59
54: ; preds = %35
%55 = load i32, i32* @errno
%56 = load i32, i32* @errno
%57 = call i32 @strerror(i32 %56)
%58 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 35, i32 %55, i32 %57)
store i32 1, i32* %3
br label %168
59: ; preds = %35
%60 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%61 = load i32, i32* %60
%62 = call i32 @close(i32 %61)
%63 = load i32, i32* %7
%64 = call i32 (...) @getpid()
%65 = icmp ne i32 %63, %64
br i1 %65, label %66, label %67
66: ; preds = %59
store i8 112, i8* %6
br label %74
67: ; preds = %59
%68 = load i32, i32* %8
%69 = call i32 (...) @getppid()
%70 = icmp ne i32 %68, %69
br i1 %70, label %71, label %72
71: ; preds = %67
store i8 80, i8* %6
br label %73
72: ; preds = %67
store i8 48, i8* %6
br label %73
73: ; preds = %72, %71
br label %74
74: ; preds = %73, %66
%75 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%76 = load i32, i32* %75
%77 = call i32 @write(i32 %76, i8* %6, i32 1)
%78 = icmp ne i32 %77, 1
br i1 %78, label %79, label %84
79: ; preds = %74
%80 = load i32, i32* @errno
%81 = load i32, i32* @errno
%82 = call i32 @strerror(i32 %81)
%83 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 48, i32 %80, i32 %82)
store i32 1, i32* %3
br label %168
84: ; preds = %74
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%86 = load i32, i32* %85
%87 = call i32 @close(i32 %86)
%88 = call i32 @_exit(i32 0)
unreachable
89: ; preds = %31
store i8 88, i8* %6
%90 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%91 = load i32, i32* %90
%92 = call i32 @close(i32 %91)
%93 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%94 = load i32, i32* %93
%95 = call i32 @close(i32 %94)
%96 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%97 = load i32, i32* %96
%98 = call i32 @close(i32 %97)
%99 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%100 = load i32, i32* %99
%101 = call i32 @read(i32 %100, i8* %6, i32 1)
%102 = icmp ne i32 %101, 0
br i1 %102, label %103, label %108
103: ; preds = %89
%104 = load i32, i32* @errno
%105 = load i32, i32* @errno
%106 = call i32 @strerror(i32 %105)
%107 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 61, i32 %104, i32 %106)
store i32 1, i32* %3
br label %168
108: ; preds = %89
%109 = call i32 (...) @test_daemon()
%110 = call i32 (...) @test_waitsig()
%111 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%112 = load i32, i32* %111
%113 = call i32 @close(i32 %112)
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%115 = load i32, i32* %114
%116 = call i32 @read(i32 %115, i8* %6, i32 1)
%117 = icmp ne i32 %116, 1
br i1 %117, label %118, label %123
118: ; preds = %108
%119 = load i32, i32* @errno
%120 = load i32, i32* @errno
%121 = call i32 @strerror(i32 %120)
%122 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 70, i32 %119, i32 %121)
store i32 1, i32* %3
br label %168
123: ; preds = %108
%124 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%125 = load i32, i32* %124
%126 = call i32 @close(i32 %125)
%127 = load i8, i8* %6
%128 = sext i8 %127 to i32
%129 = icmp eq i32 %128, 88
br i1 %129, label %130, label %135
130: ; preds = %123
%131 = load i32, i32* @errno
%132 = load i32, i32* @errno
%133 = call i32 @strerror(i32 %132)
%134 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 76, i32 %131, i32 %133)
br label %167
135: ; preds = %123
%136 = load i8, i8* %6
%137 = sext i8 %136 to i32
%138 = icmp eq i32 %137, 112
br i1 %138, label %139, label %144
139: ; preds = %135
%140 = load i32, i32* @errno
%141 = load i32, i32* @errno
%142 = call i32 @strerror(i32 %141)
%143 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 78, i32 %140, i32 %142)
br label %166
144: ; preds = %135
%145 = load i8, i8* %6
%146 = sext i8 %145 to i32
%147 = icmp eq i32 %146, 80
br i1 %147, label %148, label %153
148: ; preds = %144
%149 = load i32, i32* @errno
%150 = load i32, i32* @errno
%151 = call i32 @strerror(i32 %150)
%152 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 80, i32 %149, i32 %151)
br label %165
153: ; preds = %144
%154 = load i8, i8* %6
%155 = sext i8 %154 to i32
%156 = icmp ne i32 %155, 48
br i1 %156, label %157, label %162
157: ; preds = %153
%158 = load i32, i32* @errno
%159 = load i32, i32* @errno
%160 = call i32 @strerror(i32 %159)
%161 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 82, i32 %158, i32 %160)
br label %164
162: ; preds = %153
%163 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %164
164: ; preds = %162, %157
br label %165
165: ; preds = %164, %148
br label %166
166: ; preds = %165, %139
br label %167
167: ; preds = %166, %130
store i32 0, i32* %3
br label %168
168: ; preds = %167, %118, %103, %79, %54, %26
%169 = load i32, i32* %3
ret i32 %169
}

LLVM IR (-O2):
@.str = [36 x i8] c"ERR: %s:%d: pipe (errno = %d (%s))\0A\00"
@.str.1 = [163 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/static/pstree.c\00"
@errno = global i32 0
@.str.2 = [36 x i8] c"ERR: %s:%d: read (errno = %d (%s))\0A\00"
@.str.3 = [37 x i8] c"ERR: %s:%d: write (errno = %d (%s))\0A\00"
@.str.4 = [44 x i8] c"FAIL: %s:%d: Sync failed (errno = %d (%s))\0A\00"
@.str.5 = [43 x i8] c"FAIL: %s:%d: Pid failed (errno = %d (%s))\0A\00"
@.str.6 = [44 x i8] c"FAIL: %s:%d: PPid failed (errno = %d (%s))\0A\00"
@.str.7 = [46 x i8] c"FAIL: %s:%d: Shit happened (errno = %d (%s))\0A\00"
@.str.8 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8
%4 = alloca [2 x i32]
%5 = alloca [2 x i32]
%6 = alloca [2 x i32]
%7 = bitcast [2 x i32]* %4 to i8*
%8 = bitcast [2 x i32]* %5 to i8*
%9 = bitcast [2 x i32]* %6 to i8*
%10 = tail call i32 @test_init(i32 %0, i8** %1)
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%12 = call i64 @pipe(i32* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%16 = call i64 @pipe(i32* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%20 = call i64 @pipe(i32* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %18, %14, %2
%23 = load i32, i32* @errno
%24 = call i32 @strerror(i32 %23)
%25 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 20, i32 %23, i32 %24)
br label %126
26: ; preds = %18
%27 = call i32 (...) @fork()
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %73
29: ; preds = %26
%30 = load i32, i32* %11
%31 = call i32 @close(i32 %30)
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%33 = load i32, i32* %32
%34 = call i32 @close(i32 %33)
%35 = load i32, i32* %19
%36 = call i32 @close(i32 %35)
%37 = call i32 (...) @getpid()
%38 = call i32 (...) @getppid()
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%40 = load i32, i32* %39
%41 = call i32 @close(i32 %40)
%42 = load i32, i32* %15
%43 = call i32 @read(i32 %42, i8* %3, i32 1)
%44 = icmp eq i32 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %29
%46 = load i32, i32* @errno
%47 = call i32 @strerror(i32 %46)
%48 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 35, i32 %46, i32 %47)
br label %126
49: ; preds = %29
%50 = load i32, i32* %15
%51 = call i32 @close(i32 %50)
%52 = call i32 (...) @getpid()
%53 = icmp eq i32 %37, %52
br i1 %53, label %55, label %54
54: ; preds = %49
store i8 112, i8* %3
br label %60
55: ; preds = %49
%56 = call i32 (...) @getppid()
%57 = icmp eq i32 %38, %56
br i1 %57, label %59, label %58
58: ; preds = %55
store i8 80, i8* %3
br label %60
59: ; preds = %55
store i8 48, i8* %3
br label %60
60: ; preds = %58, %59, %54
%61 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%62 = load i32, i32* %61
%63 = call i32 @write(i32 %62, i8* %3, i32 1)
%64 = icmp eq i32 %63, 1
br i1 %64, label %69, label %65
65: ; preds = %60
%66 = load i32, i32* @errno
%67 = call i32 @strerror(i32 %66)
%68 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 48, i32 %66, i32 %67)
br label %126
69: ; preds = %60
%70 = load i32, i32* %61
%71 = call i32 @close(i32 %70)
%72 = call i32 @_exit(i32 0)
unreachable
73: ; preds = %26
store i8 88, i8* %3
%74 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%75 = load i32, i32* %74
%76 = call i32 @close(i32 %75)
%77 = load i32, i32* %15
%78 = call i32 @close(i32 %77)
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%80 = load i32, i32* %79
%81 = call i32 @close(i32 %80)
%82 = load i32, i32* %11
%83 = call i32 @read(i32 %82, i8* %3, i32 1)
%84 = icmp eq i32 %83, 0
br i1 %84, label %89, label %85
85: ; preds = %73
%86 = load i32, i32* @errno
%87 = call i32 @strerror(i32 %86)
%88 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 61, i32 %86, i32 %87)
br label %126
89: ; preds = %73
%90 = call i32 (...) @test_daemon()
%91 = call i32 (...) @test_waitsig()
%92 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%93 = load i32, i32* %92
%94 = call i32 @close(i32 %93)
%95 = load i32, i32* %19
%96 = call i32 @read(i32 %95, i8* %3, i32 1)
%97 = icmp eq i32 %96, 1
br i1 %97, label %102, label %98
98: ; preds = %89
%99 = load i32, i32* @errno
%100 = call i32 @strerror(i32 %99)
%101 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 70, i32 %99, i32 %100)
br label %126
102: ; preds = %89
%103 = load i32, i32* %19
%104 = call i32 @close(i32 %103)
%105 = load i8, i8* %3
%106 = add i8 %105, -48
%107 = call i8 @llvm.fshl.i8(i8 %106, i8 %106, i8 5)
switch i8 %107, label %120 [
i8 5, label %108
i8 8, label %112
i8 4, label %116
i8 0, label %124
]
108: ; preds = %102
%109 = load i32, i32* @errno
%110 = call i32 @strerror(i32 %109)
%111 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 76, i32 %109, i32 %110)
br label %126
112: ; preds = %102
%113 = load i32, i32* @errno
%114 = call i32 @strerror(i32 %113)
%115 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 78, i32 %113, i32 %114)
br label %126
116: ; preds = %102
%117 = load i32, i32* @errno
%118 = call i32 @strerror(i32 %117)
%119 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 80, i32 %117, i32 %118)
br label %126
120: ; preds = %102
%121 = load i32, i32* @errno
%122 = call i32 @strerror(i32 %121)
%123 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.1, i64 0, i64 0), i32 82, i32 %121, i32 %122)
br label %126
124: ; preds = %102
%125 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %126
126: ; preds = %108, %116, %124, %120, %112, %98, %85, %65, %45, %22
%127 = phi i32 [ 1, %22 ], [ 1, %45 ], [ 1, %65 ], [ 1, %85 ], [ 1, %98 ], [ 0, %112 ], [ 0, %120 ], [ 0, %124 ], [ 0, %116 ], [ 0, %108 ]
ret i32 %127
}