#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*/ SIGTERM;
scalar_t__ WEXITSTATUS(int);
int /*<<< orphan*/ WIFEXITED(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
scalar_t__ getpgid(int /*<<< orphan*/);
scalar_t__ getpid();
scalar_t__ getppid();
scalar_t__ getsid(int /*<<< orphan*/);
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ read(int, int *, int);
int /*<<< orphan*/ setpgid(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ setsid();
int /*<<< orphan*/ test_daemon();
int test_fork_id(int);
int /*<<< orphan*/ test_init(int, char **);
int /*<<< orphan*/ test_msg(char *, ...);
int /*<<< orphan*/ test_waitsig();
int /*<<< orphan*/ wait(int *);
int main(int argc, char **argv) {
  int tmp_pipe[2];
  int pids[2], syncfd[2], stat, fail = 0;
  test_init(argc, argv);
  pipe(tmp_pipe);
  pids[0] = test_fork_id(-1);
  if (pids[0] == 0) {
    close(tmp_pipe[0]);
    setsid();
    close(tmp_pipe[1]);
    test_waitsig();
    if (getpid() != getsid(0))
      exit(1);
    if (getpid() != getpgid(0))
      exit(2);
    test_msg("P1 OK\n");
    exit(0);
  }
  close(tmp_pipe[1]);
  syncfd[0] = tmp_pipe[0];
  pipe(tmp_pipe);
  pids[1] = test_fork_id(-1);
  if (pids[1] == 0) {
    int tmp_pipe_sub[2], pid;
    close(tmp_pipe[0]);
    setsid();
    pipe(tmp_pipe_sub);
    pid = test_fork_id(-1);
    if (pid == 0) {
      close(tmp_pipe[1]);
      close(tmp_pipe_sub[0]);
      setpgid(0, 0);
      close(tmp_pipe_sub[1]);
      test_waitsig();
      if (getsid(0) != getppid())
        exit(1);
      if (getpgid(0) != getpid())
        exit(1);
      exit(0);
    }
    close(tmp_pipe_sub[1]);
    read(tmp_pipe_sub[0], &stat, 1);
    close(tmp_pipe_sub[0]);
    close(tmp_pipe[1]);
    test_waitsig();
    if (getpid() != getsid(0))
      exit(1);
    if (getpid() != getpgid(0))
      exit(2);
    kill(pid, SIGTERM);
    wait(&stat);
    if (!WIFEXITED(stat) || WEXITSTATUS(stat))
      exit(3);
    exit(0);
  }
  close(tmp_pipe[1]);
  syncfd[1] = tmp_pipe[0];
  read(syncfd[0], &stat, 1);
  close(syncfd[0]);
  read(syncfd[1], &stat, 1);
  close(syncfd[1]);
  test_daemon();
  test_waitsig();
  kill(pids[0], SIGTERM);
  wait(&stat);
  if (!WIFEXITED(stat) || WEXITSTATUS(stat)) {
    test_msg("P1 stat %d/%d\n", WIFEXITED(stat), WEXITSTATUS(stat));
    fail = 1;
  }
  kill(pids[1], SIGTERM);
  wait(&stat);
  if (!WIFEXITED(stat) || WEXITSTATUS(stat)) {
    test_msg("P1 stat %d/%d\n", WIFEXITED(stat), WEXITSTATUS(stat));
    fail = 1;
  }
  if (fail)
    test_msg("FAIL: %s:%d: "
             "Something failed"
             " (errno = %d)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/"
             "zdtm/live/static/xids00.c",
             117, errno);
  else
    test_msg("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <test_init@plt>
lea    -0x18(%rbp),%rdi
call   1080 <pipe@plt>
mov    $0xffffffff,%edi
call   10f0 <test_fork_id@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    1307 <main+0xd7>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
mov    $0x0,%al
call   1090 <setsid@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    $0x0,%al
call   10c0 <test_waitsig@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,-0x48(%rbp)
xor    %edi,%edi
call   1060 <getsid@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
je     12c6 <main+0x96>
mov    $0x1,%edi
call   1140 <exit@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,-0x50(%rbp)
xor    %edi,%edi
call   1100 <getpgid@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cmp    %rcx,%rax
je     12f2 <main+0xc2>
mov    $0x2,%edi
call   1140 <exit@plt>
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   10a0 <test_msg@plt>
xor    %edi,%edi
call   1140 <exit@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0x18(%rbp),%rdi
call   1080 <pipe@plt>
mov    $0xffffffff,%edi
call   10f0 <test_fork_id@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    14c1 <main+0x291>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
mov    $0x0,%al
call   1090 <setsid@plt>
lea    -0x38(%rbp),%rdi
call   1080 <pipe@plt>
mov    $0xffffffff,%edi
call   10f0 <test_fork_id@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    13eb <main+0x1bb>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x38(%rbp),%edi
call   1070 <close@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1110 <setpgid@plt>
mov    -0x34(%rbp),%edi
call   1070 <close@plt>
mov    $0x0,%al
call   10c0 <test_waitsig@plt>
xor    %edi,%edi
call   1060 <getsid@plt>
mov    %rax,-0x58(%rbp)
mov    $0x0,%al
call   1130 <getppid@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
cmp    %rcx,%rax
je     13b8 <main+0x188>
mov    $0x1,%edi
call   1140 <exit@plt>
xor    %edi,%edi
call   1100 <getpgid@plt>
mov    %rax,-0x60(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
cmp    %rcx,%rax
je     13e4 <main+0x1b4>
mov    $0x1,%edi
call   1140 <exit@plt>
xor    %edi,%edi
call   1140 <exit@plt>
mov    -0x34(%rbp),%edi
call   1070 <close@plt>
mov    -0x38(%rbp),%edi
lea    -0x2c(%rbp),%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
mov    -0x38(%rbp),%edi
call   1070 <close@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    $0x0,%al
call   10c0 <test_waitsig@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,-0x68(%rbp)
xor    %edi,%edi
call   1060 <getsid@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
cmp    %rcx,%rax
je     1447 <main+0x217>
mov    $0x1,%edi
call   1140 <exit@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,-0x70(%rbp)
xor    %edi,%edi
call   1100 <getpgid@plt>
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
cmp    %rcx,%rax
je     1473 <main+0x243>
mov    $0x2,%edi
call   1140 <exit@plt>
mov    -0x3c(%rbp),%edi
mov    0x2b6b(%rip),%rax
mov    (%rax),%esi
call   10d0 <kill@plt>
lea    -0x2c(%rbp),%rdi
call   1150 <wait@plt>
mov    -0x2c(%rbp),%edi
call   1120 <WIFEXITED@plt>
cmp    $0x0,%eax
je     14b0 <main+0x280>
mov    -0x2c(%rbp),%edi
call   10e0 <WEXITSTATUS@plt>
cmp    $0x0,%rax
je     14ba <main+0x28a>
mov    $0x3,%edi
call   1140 <exit@plt>
xor    %edi,%edi
call   1140 <exit@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x2c(%rbp),%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
mov    -0x28(%rbp),%edi
call   1070 <close@plt>
mov    -0x24(%rbp),%edi
lea    -0x2c(%rbp),%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
mov    -0x24(%rbp),%edi
call   1070 <close@plt>
mov    $0x0,%al
call   1050 <test_daemon@plt>
mov    $0x0,%al
call   10c0 <test_waitsig@plt>
mov    -0x20(%rbp),%edi
mov    0x2acf(%rip),%rax
mov    (%rax),%esi
call   10d0 <kill@plt>
lea    -0x2c(%rbp),%rdi
call   1150 <wait@plt>
mov    -0x2c(%rbp),%edi
call   1120 <WIFEXITED@plt>
cmp    $0x0,%eax
je     154c <main+0x31c>
mov    -0x2c(%rbp),%edi
call   10e0 <WEXITSTATUS@plt>
cmp    $0x0,%rax
je     157a <main+0x34a>
mov    -0x2c(%rbp),%edi
call   1120 <WIFEXITED@plt>
mov    %eax,-0x74(%rbp)
mov    -0x2c(%rbp),%edi
call   10e0 <WEXITSTATUS@plt>
mov    -0x74(%rbp),%esi
mov    %rax,%rdx
lea    0xa9b(%rip),%rdi
mov    $0x0,%al
call   10a0 <test_msg@plt>
movl   $0x1,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2a64(%rip),%rax
mov    (%rax),%esi
call   10d0 <kill@plt>
lea    -0x2c(%rbp),%rdi
call   1150 <wait@plt>
mov    -0x2c(%rbp),%edi
call   1120 <WIFEXITED@plt>
cmp    $0x0,%eax
je     15b7 <main+0x387>
mov    -0x2c(%rbp),%edi
call   10e0 <WEXITSTATUS@plt>
cmp    $0x0,%rax
je     15e5 <main+0x3b5>
mov    -0x2c(%rbp),%edi
call   1120 <WIFEXITED@plt>
mov    %eax,-0x78(%rbp)
mov    -0x2c(%rbp),%edi
call   10e0 <WEXITSTATUS@plt>
mov    -0x78(%rbp),%esi
mov    %rax,%rdx
lea    0xa30(%rip),%rdi
mov    $0x0,%al
call   10a0 <test_msg@plt>
movl   $0x1,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     1617 <main+0x3e7>
mov    0x29e2(%rip),%rax
mov    (%rax),%ecx
lea    0xa17(%rip),%rdi
lea    0xa3c(%rip),%rsi
mov    $0x75,%edx
mov    $0x0,%al
call   10a0 <test_msg@plt>
jmp    1625 <main+0x3f5>
lea    0xabb(%rip),%rdi
mov    $0x0,%al
call   10a0 <test_msg@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
call   1030 <test_init@plt>
lea    0x10(%rsp),%rdi
call   1080 <pipe@plt>
mov    $0xffffffff,%edi
call   10f0 <test_fork_id@plt>
test   %eax,%eax
je     13da <main+0x1aa>
mov    %eax,%r12d
mov    0x14(%rsp),%edi
call   1070 <close@plt>
mov    0x10(%rsp),%ebx
lea    0x10(%rsp),%rdi
call   1080 <pipe@plt>
mov    $0xffffffff,%edi
call   10f0 <test_fork_id@plt>
test   %eax,%eax
je     1443 <main+0x213>
mov    %eax,%r14d
mov    0x14(%rsp),%edi
call   1070 <close@plt>
mov    0x10(%rsp),%ebp
lea    0xc(%rsp),%r15
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
mov    %ebp,%edi
call   1070 <close@plt>
xor    %eax,%eax
call   1050 <test_daemon@plt>
xor    %eax,%eax
call   10c0 <test_waitsig@plt>
mov    0x2d09(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %r12d,%edi
call   10d0 <kill@plt>
mov    %r15,%rdi
call   1150 <wait@plt>
mov    0xc(%rsp),%edi
call   1120 <WIFEXITED@plt>
test   %eax,%eax
je     130d <main+0xdd>
mov    0xc(%rsp),%edi
call   10e0 <WEXITSTATUS@plt>
test   %rax,%rax
je     1339 <main+0x109>
mov    0xc(%rsp),%edi
call   1120 <WIFEXITED@plt>
mov    %eax,%ebx
mov    0xc(%rsp),%edi
call   10e0 <WEXITSTATUS@plt>
lea    0xcdf(%rip),%rdi
xor    %r15d,%r15d
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <test_msg@plt>
jmp    133c <main+0x10c>
mov    $0x1,%r15b
mov    0x0(%rbp),%esi
mov    %r14d,%edi
call   10d0 <kill@plt>
lea    0xc(%rsp),%rdi
call   1150 <wait@plt>
mov    0xc(%rsp),%edi
call   1120 <WIFEXITED@plt>
test   %eax,%eax
je     136c <main+0x13c>
mov    0xc(%rsp),%edi
call   10e0 <WEXITSTATUS@plt>
test   %rax,%rax
je     13c5 <main+0x195>
mov    0xc(%rsp),%edi
call   1120 <WIFEXITED@plt>
mov    %eax,%ebx
mov    0xc(%rsp),%edi
call   10e0 <WEXITSTATUS@plt>
lea    0xc80(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <test_msg@plt>
mov    0x2c3e(%rip),%rax
mov    (%rax),%ecx
lea    0xc73(%rip),%rdi
lea    0xc98(%rip),%rsi
mov    $0x75,%edx
xor    %eax,%eax
call   10a0 <test_msg@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
test   %r15b,%r15b
je     1393 <main+0x163>
lea    0xd08(%rip),%rdi
xor    %eax,%eax
call   10a0 <test_msg@plt>
jmp    13b6 <main+0x186>
mov    0x10(%rsp),%edi
call   1070 <close@plt>
xor    %eax,%eax
call   1090 <setsid@plt>
mov    0x14(%rsp),%edi
call   1070 <close@plt>
xor    %eax,%eax
call   10c0 <test_waitsig@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1060 <getsid@plt>
cmp    %rax,%rbx
jne    156e <main+0x33e>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1100 <getpgid@plt>
cmp    %rax,%rbx
jne    1578 <main+0x348>
lea    0xbcb(%rip),%rdi
xor    %eax,%eax
call   10a0 <test_msg@plt>
xor    %edi,%edi
call   1140 <exit@plt>
mov    0x10(%rsp),%edi
call   1070 <close@plt>
xor    %eax,%eax
call   1090 <setsid@plt>
lea    0x18(%rsp),%rdi
call   1080 <pipe@plt>
mov    $0xffffffff,%edi
call   10f0 <test_fork_id@plt>
test   %eax,%eax
jne    14cf <main+0x29f>
mov    0x14(%rsp),%edi
call   1070 <close@plt>
mov    0x18(%rsp),%edi
call   1070 <close@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1110 <setpgid@plt>
mov    0x1c(%rsp),%edi
call   1070 <close@plt>
xor    %eax,%eax
call   10c0 <test_waitsig@plt>
xor    %edi,%edi
call   1060 <getsid@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1130 <getppid@plt>
cmp    %rax,%rbx
jne    156e <main+0x33e>
xor    %edi,%edi
call   1100 <getpgid@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <getpid@plt>
cmp    %rax,%rbx
je     1567 <main+0x337>
jmp    156e <main+0x33e>
mov    %eax,%ebx
mov    0x1c(%rsp),%edi
call   1070 <close@plt>
mov    0x18(%rsp),%edi
lea    0xc(%rsp),%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
mov    0x18(%rsp),%edi
call   1070 <close@plt>
mov    0x14(%rsp),%edi
call   1070 <close@plt>
xor    %eax,%eax
call   10c0 <test_waitsig@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %rax,%rbp
xor    %edi,%edi
call   1060 <getsid@plt>
cmp    %rax,%rbp
jne    156e <main+0x33e>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %rax,%rbp
xor    %edi,%edi
call   1100 <getpgid@plt>
cmp    %rax,%rbp
jne    1578 <main+0x348>
mov    0x2aaf(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   10d0 <kill@plt>
lea    0xc(%rsp),%rdi
call   1150 <wait@plt>
mov    0xc(%rsp),%edi
call   1120 <WIFEXITED@plt>
test   %eax,%eax
je     1582 <main+0x352>
mov    0xc(%rsp),%edi
call   10e0 <WEXITSTATUS@plt>
test   %rax,%rax
jne    1582 <main+0x352>
xor    %edi,%edi
call   1140 <exit@plt>
mov    $0x1,%edi
call   1140 <exit@plt>
mov    $0x2,%edi
call   1140 <exit@plt>
mov    $0x3,%edi
call   1140 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"P1 OK\0A\00"
@SIGTERM = global i32 0
@.str.1 = [15 x i8] c"P1 stat %d/%d\0A\00"
@.str.2 = [44 x i8] c"FAIL: %s:%d: Something failed (errno = %d)\0A\00"
@.str.3 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/zdtm/live/static/xids00.c\00"
@errno = global i32 0
@.str.4 = [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 [2 x i32]
%7 = alloca [2 x i32]
%8 = alloca [2 x i32]
%9 = alloca i32
%10 = alloca i32
%11 = alloca [2 x i32]
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @test_init(i32 %13, i8** %14)
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%17 = call i32 @pipe(i32* %16)
%18 = call i32 @test_fork_id(i32 -1)
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
store i32 %18, i32* %19
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %46
23: ; preds = %2
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%25 = load i32, i32* %24
%26 = call i32 @close(i32 %25)
%27 = call i32 (...) @setsid()
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%29 = load i32, i32* %28
%30 = call i32 @close(i32 %29)
%31 = call i32 (...) @test_waitsig()
%32 = call i64 (...) @getpid()
%33 = call i64 @getsid(i32 0)
%34 = icmp ne i64 %32, %33
br i1 %34, label %35, label %37
35: ; preds = %23
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %23
%38 = call i64 (...) @getpid()
%39 = call i64 @getpgid(i32 0)
%40 = icmp ne i64 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 @exit(i32 2)
unreachable
43: ; preds = %37
%44 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%45 = call i32 @exit(i32 0)
unreachable
46: ; preds = %2
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%48 = load i32, i32* %47
%49 = call i32 @close(i32 %48)
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%51 = load i32, i32* %50
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
store i32 %51, i32* %52
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%54 = call i32 @pipe(i32* %53)
%55 = call i32 @test_fork_id(i32 -1)
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
store i32 %55, i32* %56
%57 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%58 = load i32, i32* %57
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %136
60: ; preds = %46
%61 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%62 = load i32, i32* %61
%63 = call i32 @close(i32 %62)
%64 = call i32 (...) @setsid()
%65 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%66 = call i32 @pipe(i32* %65)
%67 = call i32 @test_fork_id(i32 -1)
store i32 %67, i32* %12
%68 = load i32, i32* %12
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %95
70: ; preds = %60
%71 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%72 = load i32, i32* %71
%73 = call i32 @close(i32 %72)
%74 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%75 = load i32, i32* %74
%76 = call i32 @close(i32 %75)
%77 = call i32 @setpgid(i32 0, i32 0)
%78 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%79 = load i32, i32* %78
%80 = call i32 @close(i32 %79)
%81 = call i32 (...) @test_waitsig()
%82 = call i64 @getsid(i32 0)
%83 = call i64 (...) @getppid()
%84 = icmp ne i64 %82, %83
br i1 %84, label %85, label %87
85: ; preds = %70
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %70
%88 = call i64 @getpgid(i32 0)
%89 = call i64 (...) @getpid()
%90 = icmp ne i64 %88, %89
br i1 %90, label %91, label %93
91: ; preds = %87
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %87
%94 = call i32 @exit(i32 0)
unreachable
95: ; preds = %60
%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]* %11, i64 0, i64 0
%100 = load i32, i32* %99
%101 = call i32 @read(i32 %100, i32* %9, i32 1)
%102 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%103 = load i32, i32* %102
%104 = call i32 @close(i32 %103)
%105 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%106 = load i32, i32* %105
%107 = call i32 @close(i32 %106)
%108 = call i32 (...) @test_waitsig()
%109 = call i64 (...) @getpid()
%110 = call i64 @getsid(i32 0)
%111 = icmp ne i64 %109, %110
br i1 %111, label %112, label %114
112: ; preds = %95
%113 = call i32 @exit(i32 1)
unreachable
114: ; preds = %95
%115 = call i64 (...) @getpid()
%116 = call i64 @getpgid(i32 0)
%117 = icmp ne i64 %115, %116
br i1 %117, label %118, label %120
118: ; preds = %114
%119 = call i32 @exit(i32 2)
unreachable
120: ; preds = %114
%121 = load i32, i32* %12
%122 = load i32, i32* @SIGTERM
%123 = call i32 @kill(i32 %121, i32 %122)
%124 = call i32 @wait(i32* %9)
%125 = load i32, i32* %9
%126 = call i32 @WIFEXITED(i32 %125)
%127 = icmp ne i32 %126, 0
br i1 %127, label %128, label %132
128: ; preds = %120
%129 = load i32, i32* %9
%130 = call i64 @WEXITSTATUS(i32 %129)
%131 = icmp ne i64 %130, 0
br i1 %131, label %132, label %134
132: ; preds = %128, %120
%133 = call i32 @exit(i32 3)
unreachable
134: ; preds = %128
%135 = call i32 @exit(i32 0)
unreachable
136: ; preds = %46
%137 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%138 = load i32, i32* %137
%139 = call i32 @close(i32 %138)
%140 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%141 = load i32, i32* %140
%142 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
store i32 %141, i32* %142
%143 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%144 = load i32, i32* %143
%145 = call i32 @read(i32 %144, i32* %9, i32 1)
%146 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%147 = load i32, i32* %146
%148 = call i32 @close(i32 %147)
%149 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%150 = load i32, i32* %149
%151 = call i32 @read(i32 %150, i32* %9, i32 1)
%152 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%153 = load i32, i32* %152
%154 = call i32 @close(i32 %153)
%155 = call i32 (...) @test_daemon()
%156 = call i32 (...) @test_waitsig()
%157 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%158 = load i32, i32* %157
%159 = load i32, i32* @SIGTERM
%160 = call i32 @kill(i32 %158, i32 %159)
%161 = call i32 @wait(i32* %9)
%162 = load i32, i32* %9
%163 = call i32 @WIFEXITED(i32 %162)
%164 = icmp ne i32 %163, 0
br i1 %164, label %165, label %169
165: ; preds = %136
%166 = load i32, i32* %9
%167 = call i64 @WEXITSTATUS(i32 %166)
%168 = icmp ne i64 %167, 0
br i1 %168, label %169, label %175
169: ; preds = %165, %136
%170 = load i32, i32* %9
%171 = call i32 @WIFEXITED(i32 %170)
%172 = load i32, i32* %9
%173 = call i64 @WEXITSTATUS(i32 %172)
%174 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %171, i64 %173)
store i32 1, i32* %10
br label %175
175: ; preds = %169, %165
%176 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%177 = load i32, i32* %176
%178 = load i32, i32* @SIGTERM
%179 = call i32 @kill(i32 %177, i32 %178)
%180 = call i32 @wait(i32* %9)
%181 = load i32, i32* %9
%182 = call i32 @WIFEXITED(i32 %181)
%183 = icmp ne i32 %182, 0
br i1 %183, label %184, label %188
184: ; preds = %175
%185 = load i32, i32* %9
%186 = call i64 @WEXITSTATUS(i32 %185)
%187 = icmp ne i64 %186, 0
br i1 %187, label %188, label %194
188: ; preds = %184, %175
%189 = load i32, i32* %9
%190 = call i32 @WIFEXITED(i32 %189)
%191 = load i32, i32* %9
%192 = call i64 @WEXITSTATUS(i32 %191)
%193 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %190, i64 %192)
store i32 1, i32* %10
br label %194
194: ; preds = %188, %184
%195 = load i32, i32* %10
%196 = icmp ne i32 %195, 0
br i1 %196, label %197, label %200
197: ; preds = %194
%198 = load i32, i32* @errno
%199 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0), i32 117, i32 %198)
br label %202
200: ; preds = %194
%201 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %202
202: ; preds = %200, %197
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"P1 OK\0A\00"
@SIGTERM = global i32 0
@.str.1 = [15 x i8] c"P1 stat %d/%d\0A\00"
@.str.2 = [44 x i8] c"FAIL: %s:%d: Something failed (errno = %d)\0A\00"
@.str.3 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/zdtm/live/static/xids00.c\00"
@errno = global i32 0
@.str.4 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = alloca [2 x i32]
%6 = bitcast [2 x i32]* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = tail call i32 @test_init(i32 %0, i8** %1)
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%10 = call i32 @pipe(i32* %9)
%11 = call i32 @test_fork_id(i32 -1)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %35
13: ; preds = %2
%14 = load i32, i32* %9
%15 = call i32 @close(i32 %14)
%16 = call i32 (...) @setsid()
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%18 = load i32, i32* %17
%19 = call i32 @close(i32 %18)
%20 = call i32 (...) @test_waitsig()
%21 = call i64 (...) @getpid()
%22 = call i64 @getsid(i32 0)
%23 = icmp eq i64 %21, %22
br i1 %23, label %26, label %24
24: ; preds = %13
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %13
%27 = call i64 (...) @getpid()
%28 = call i64 @getpgid(i32 0)
%29 = icmp eq i64 %27, %28
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = call i32 @exit(i32 2)
unreachable
32: ; preds = %26
%33 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%34 = call i32 @exit(i32 0)
unreachable
35: ; preds = %2
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%37 = load i32, i32* %36
%38 = call i32 @close(i32 %37)
%39 = load i32, i32* %9
%40 = call i32 @pipe(i32* %9)
%41 = call i32 @test_fork_id(i32 -1)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %112
43: ; preds = %35
%44 = bitcast [2 x i32]* %5 to i8*
%45 = load i32, i32* %9
%46 = call i32 @close(i32 %45)
%47 = call i32 (...) @setsid()
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%49 = call i32 @pipe(i32* %48)
%50 = call i32 @test_fork_id(i32 -1)
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %75
52: ; preds = %43
%53 = load i32, i32* %36
%54 = call i32 @close(i32 %53)
%55 = load i32, i32* %48
%56 = call i32 @close(i32 %55)
%57 = call i32 @setpgid(i32 0, i32 0)
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%59 = load i32, i32* %58
%60 = call i32 @close(i32 %59)
%61 = call i32 (...) @test_waitsig()
%62 = call i64 @getsid(i32 0)
%63 = call i64 (...) @getppid()
%64 = icmp eq i64 %62, %63
br i1 %64, label %67, label %65
65: ; preds = %52
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %52
%68 = call i64 @getpgid(i32 0)
%69 = call i64 (...) @getpid()
%70 = icmp eq i64 %68, %69
br i1 %70, label %73, label %71
71: ; preds = %67
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %67
%74 = call i32 @exit(i32 0)
unreachable
75: ; preds = %43
%76 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%77 = load i32, i32* %76
%78 = call i32 @close(i32 %77)
%79 = load i32, i32* %48
%80 = call i32 @read(i32 %79, i32* %4, i32 1)
%81 = load i32, i32* %48
%82 = call i32 @close(i32 %81)
%83 = load i32, i32* %36
%84 = call i32 @close(i32 %83)
%85 = call i32 (...) @test_waitsig()
%86 = call i64 (...) @getpid()
%87 = call i64 @getsid(i32 0)
%88 = icmp eq i64 %86, %87
br i1 %88, label %91, label %89
89: ; preds = %75
%90 = call i32 @exit(i32 1)
unreachable
91: ; preds = %75
%92 = call i64 (...) @getpid()
%93 = call i64 @getpgid(i32 0)
%94 = icmp eq i64 %92, %93
br i1 %94, label %97, label %95
95: ; preds = %91
%96 = call i32 @exit(i32 2)
unreachable
97: ; preds = %91
%98 = load i32, i32* @SIGTERM
%99 = call i32 @kill(i32 %50, i32 %98)
%100 = call i32 @wait(i32* %4)
%101 = load i32, i32* %4
%102 = call i32 @WIFEXITED(i32 %101)
%103 = icmp eq i32 %102, 0
br i1 %103, label %108, label %104
104: ; preds = %97
%105 = load i32, i32* %4
%106 = call i64 @WEXITSTATUS(i32 %105)
%107 = icmp eq i64 %106, 0
br i1 %107, label %110, label %108
108: ; preds = %104, %97
%109 = call i32 @exit(i32 3)
unreachable
110: ; preds = %104
%111 = call i32 @exit(i32 0)
unreachable
112: ; preds = %35
%113 = load i32, i32* %36
%114 = call i32 @close(i32 %113)
%115 = load i32, i32* %9
%116 = call i32 @read(i32 %39, i32* %4, i32 1)
%117 = call i32 @close(i32 %39)
%118 = call i32 @read(i32 %115, i32* %4, i32 1)
%119 = call i32 @close(i32 %115)
%120 = call i32 (...) @test_daemon()
%121 = call i32 (...) @test_waitsig()
%122 = load i32, i32* @SIGTERM
%123 = call i32 @kill(i32 %11, i32 %122)
%124 = call i32 @wait(i32* %4)
%125 = load i32, i32* %4
%126 = call i32 @WIFEXITED(i32 %125)
%127 = icmp eq i32 %126, 0
br i1 %127, label %132, label %128
128: ; preds = %112
%129 = load i32, i32* %4
%130 = call i64 @WEXITSTATUS(i32 %129)
%131 = icmp eq i64 %130, 0
br i1 %131, label %138, label %132
132: ; preds = %128, %112
%133 = load i32, i32* %4
%134 = call i32 @WIFEXITED(i32 %133)
%135 = load i32, i32* %4
%136 = call i64 @WEXITSTATUS(i32 %135)
%137 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %134, i64 %136)
br label %138
138: ; preds = %132, %128
%139 = phi i1 [ false, %132 ], [ true, %128 ]
%140 = load i32, i32* @SIGTERM
%141 = call i32 @kill(i32 %41, i32 %140)
%142 = call i32 @wait(i32* %4)
%143 = load i32, i32* %4
%144 = call i32 @WIFEXITED(i32 %143)
%145 = icmp eq i32 %144, 0
br i1 %145, label %150, label %146
146: ; preds = %138
%147 = load i32, i32* %4
%148 = call i64 @WEXITSTATUS(i32 %147)
%149 = icmp eq i64 %148, 0
br i1 %149, label %156, label %150
150: ; preds = %138, %146
%151 = load i32, i32* %4
%152 = call i32 @WIFEXITED(i32 %151)
%153 = load i32, i32* %4
%154 = call i64 @WEXITSTATUS(i32 %153)
%155 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %152, i64 %154)
br label %157
156: ; preds = %146
br i1 %139, label %160, label %157
157: ; preds = %150, %156
%158 = load i32, i32* @errno
%159 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0), i32 117, i32 %158)
br label %162
160: ; preds = %156
%161 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %162
162: ; preds = %160, %157
ret i32 0
}