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

/* Forward declarations */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct rusage {
  int dummy;
};
struct TYPE_3__ {
  scalar_t__ si_code;
  scalar_t__ si_status;
};
typedef TYPE_1__ siginfo_t;
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ c;

/* Variables and functions */
scalar_t__ CLD_EXITED;
int /*<<< orphan*/ P_PID;
int /*<<< orphan*/ SIGCONT;
scalar_t__ SIGSTOP;
scalar_t__ SIGUSR1;
int WEXITED;
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
scalar_t__ WIFSTOPPED(int);
int WNOHANG;
int WSTOPPED;
scalar_t__ WSTOPSIG(int);
scalar_t__ WTERMSIG(int);
int WUNTRACED;
int __WALL;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close(int);
scalar_t__ fork();
scalar_t__ kill(scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ raise(scalar_t__);
int read(int /*<<< orphan*/, char *, int);
int wait4(int, int *, int, struct rusage *);
scalar_t__ waitid(int /*<<< orphan*/, scalar_t__, TYPE_1__ *, int);
int write(int, char *, int);
int main(void) {
  int fds[2];
  int s;
  pid_t pid;
  struct rusage rusage = {};
  siginfo_t info = {};
  (void)close(0);
  (void)close(1);
  assert(!pipe(fds) && fds[0] == 0 && fds[1] == 1);
  pid = fork();
  assert(pid >= 0);
  if (!pid) {
    char c;
    (void)close(1);
    assert(read(0, &c, sizeof(c)) == 1);
    return 42;
  }
  (void)close(0);
  assert(wait4(pid, &s, WNOHANG | __WALL, NULL) == 0);
  assert(waitid(P_PID, pid, &info, WNOHANG | WEXITED) == 0);
  assert(write(1, "", 1) == 1);
  (void)close(1);
  assert(wait4(pid, &s, 0, &rusage) == pid);
  assert(WIFEXITED(s) && WEXITSTATUS(s) == 42);
  pid = fork();
  assert(pid >= 0);
  if (!pid) {
    (void)raise(SIGUSR1);
    return 77;
  }
  assert(wait4(pid, &s, __WALL, NULL) == pid);
  assert(WIFSIGNALED(s) && WTERMSIG(s) == SIGUSR1);
  pid = fork();
  assert(pid >= 0);
  if (!pid) {
    raise(SIGSTOP);
    return 0;
  }
  assert(wait4(pid, &s, WUNTRACED, NULL) == pid);
  assert(WIFSTOPPED(s) && WSTOPSIG(s) == SIGSTOP);
  assert(kill(pid, SIGCONT) == 0);
  assert(waitid(P_PID, pid, &info, WEXITED | WSTOPPED) == 0);
  assert(info.si_code == CLD_EXITED && info.si_status == 0);
  assert(wait4(-1, &s, WNOHANG | WUNTRACED | __WALL, &rusage) == -1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
xor    %edi,%edi
call   1060 <close@plt>
mov    $0x1,%edi
call   1060 <close@plt>
lea    -0xc(%rbp),%rdi
call   1070 <pipe@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x32(%rbp)
jne    1282 <main+0x72>
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x32(%rbp)
jne    1282 <main+0x72>
cmpl   $0x1,-0x8(%rbp)
sete   %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    $0x0,%al
call   1130 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
jne    12ed <main+0xdd>
mov    $0x1,%edi
call   1060 <close@plt>
xor    %edi,%edi
lea    -0x31(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
movl   $0x2a,-0x4(%rbp)
jmp    1622 <main+0x412>
xor    %edi,%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
mov    0x2cbf(%rip),%rax
mov    (%rax),%edx
mov    0x2c96(%rip),%rax
or     (%rax),%edx
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   10e0 <wait4@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x2ca0(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    0x2c83(%rip),%rax
mov    (%rax),%ecx
mov    0x2c82(%rip),%rax
or     (%rax),%ecx
lea    -0x30(%rbp),%rdx
call   1110 <waitid@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    $0x1,%edx
lea    0xc92(%rip),%rsi
mov    %edx,%edi
call   1040 <write@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    $0x1,%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
lea    -0x10(%rbp),%rsi
xor    %edx,%edx
lea    -0x20(%rbp),%rcx
call   10e0 <wait4@plt>
cltq
cmp    -0x18(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x10(%rbp),%edi
call   1100 <WIFEXITED@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x33(%rbp)
je     13e2 <main+0x1d2>
mov    -0x10(%rbp),%edi
call   10f0 <WEXITSTATUS@plt>
cmp    $0x2a,%eax
sete   %al
mov    %al,-0x33(%rbp)
mov    -0x33(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    $0x0,%al
call   1130 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1432 <main+0x222>
mov    0x2bc2(%rip),%rax
mov    (%rax),%rdi
call   1030 <raise@plt>
movl   $0x4d,-0x4(%rbp)
jmp    1622 <main+0x412>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
mov    0x2b61(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   10e0 <wait4@plt>
cltq
cmp    -0x18(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x10(%rbp),%edi
call   1090 <WIFSIGNALED@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x34(%rbp)
je     1493 <main+0x283>
mov    -0x10(%rbp),%edi
call   10d0 <WTERMSIG@plt>
mov    0x2b56(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x34(%rbp)
mov    -0x34(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    $0x0,%al
call   1130 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
jne    14e3 <main+0x2d3>
mov    0x2ac9(%rip),%rax
mov    (%rax),%rdi
call   1030 <raise@plt>
movl   $0x0,-0x4(%rbp)
jmp    1622 <main+0x412>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
mov    0x2ac0(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   10e0 <wait4@plt>
cltq
cmp    -0x18(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x10(%rbp),%edi
call   10c0 <WIFSTOPPED@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x35(%rbp)
je     1544 <main+0x334>
mov    -0x10(%rbp),%edi
call   1120 <WSTOPSIG@plt>
mov    0x2a5d(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    0x2a7c(%rip),%rax
mov    (%rax),%esi
call   10b0 <kill@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x2a55(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    0x2a40(%rip),%rax
mov    (%rax),%ecx
mov    0x2a5f(%rip),%rax
or     (%rax),%ecx
lea    -0x30(%rbp),%rdx
call   1110 <waitid@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
mov    0x29ee(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x36(%rbp)
jne    15d1 <main+0x3c1>
cmpq   $0x0,-0x28(%rbp)
sete   %al
mov    %al,-0x36(%rbp)
mov    -0x36(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    0x29db(%rip),%rax
mov    (%rax),%edx
mov    0x29c2(%rip),%rax
or     (%rax),%edx
mov    0x29a9(%rip),%rax
or     (%rax),%edx
mov    $0xffffffff,%edi
lea    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rcx
call   10e0 <wait4@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movl   $0x0,0x10(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
xor    %r14d,%r14d
xor    %edi,%edi
call   1050 <close@plt>
mov    $0x1,%edi
call   1050 <close@plt>
lea    0x18(%rsp),%rdi
call   1060 <pipe@plt>
or     0x18(%rsp),%eax
mov    0x1c(%rsp),%ecx
xor    $0x1,%ecx
xor    %edi,%edi
or     %eax,%ecx
sete   %dil
call   1090 <assert@plt>
xor    %eax,%eax
call   1120 <fork@plt>
mov    %rax,%rbx
mov    %rax,%rdi
shr    $0x3f,%rdi
xor    $0x1,%edi
call   1090 <assert@plt>
test   %rbx,%rbx
je     14ef <main+0x2ef>
xor    %edi,%edi
call   1050 <close@plt>
mov    0x2d3c(%rip),%r13
mov    0x2d15(%rip),%r12
mov    (%r12),%edx
or     0x0(%r13),%edx
lea    0xc(%rsp),%r15
mov    %ebx,%edi
mov    %r15,%rsi
xor    %ecx,%ecx
call   10d0 <wait4@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <assert@plt>
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
mov    0x2d07(%rip),%rbp
mov    0x0(%rbp),%ecx
or     0x0(%r13),%ecx
lea    0x20(%rsp),%rdx
mov    %rbx,%rsi
call   1100 <waitid@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
lea    0xd16(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1040 <write@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1090 <assert@plt>
mov    $0x1,%edi
call   1050 <close@plt>
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %r15,%rsi
xor    %edx,%edx
call   10d0 <wait4@plt>
cltq
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
call   1090 <assert@plt>
mov    0xc(%rsp),%edi
call   10f0 <WIFEXITED@plt>
test   %rax,%rax
je     1353 <main+0x153>
mov    0xc(%rsp),%edi
call   10e0 <WEXITSTATUS@plt>
xor    %r14d,%r14d
cmp    $0x2a,%eax
sete   %r14b
mov    %r14d,%edi
call   1090 <assert@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1120 <fork@plt>
mov    %rax,%rbx
mov    %rax,%rdi
shr    $0x3f,%rdi
xor    $0x1,%edi
call   1090 <assert@plt>
test   %rbx,%rbx
je     151f <main+0x31f>
mov    (%r12),%edx
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
xor    %ecx,%ecx
call   10d0 <wait4@plt>
cltq
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
call   1090 <assert@plt>
mov    0xc(%rsp),%edi
call   1080 <WIFSIGNALED@plt>
test   %rax,%rax
je     13ca <main+0x1ca>
mov    0xc(%rsp),%edi
call   10c0 <WTERMSIG@plt>
mov    0x2c20(%rip),%rcx
xor    %r14d,%r14d
cmp    (%rcx),%rax
sete   %r14b
mov    %r14d,%edi
call   1090 <assert@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1120 <fork@plt>
mov    %rax,%rbx
mov    %rax,%rdi
shr    $0x3f,%rdi
xor    $0x1,%edi
call   1090 <assert@plt>
test   %rbx,%rbx
je     1535 <main+0x335>
mov    %rbp,%r15
mov    0x2baf(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
xor    %ecx,%ecx
call   10d0 <wait4@plt>
cltq
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
call   1090 <assert@plt>
mov    0xc(%rsp),%edi
call   10b0 <WIFSTOPPED@plt>
test   %rax,%rax
je     144a <main+0x24a>
mov    0xc(%rsp),%edi
call   1110 <WSTOPSIG@plt>
mov    0x2b58(%rip),%rcx
xor    %r14d,%r14d
cmp    (%rcx),%rax
sete   %r14b
mov    %r14d,%edi
call   1090 <assert@plt>
mov    0x2b7f(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10a0 <kill@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    0x2b58(%rip),%rax
mov    (%rax),%edi
mov    0x2b6f(%rip),%rax
mov    (%rax),%ecx
or     (%r15),%ecx
lea    0x20(%rsp),%rdx
mov    %rbx,%rsi
call   1100 <waitid@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    0x20(%rsp),%rax
mov    0x2afb(%rip),%rcx
xor    (%rcx),%rax
xor    %edi,%edi
or     0x28(%rsp),%rax
sete   %dil
call   1090 <assert@plt>
mov    0x0(%rbp),%edx
or     0x0(%r13),%edx
or     (%r12),%edx
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rcx
mov    $0xffffffff,%edi
call   10d0 <wait4@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1090 <assert@plt>
jmp    1544 <main+0x344>
mov    $0x1,%edi
call   1050 <close@plt>
lea    0xc(%rsp),%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1070 <read@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1090 <assert@plt>
mov    $0x2a,%eax
jmp    1546 <main+0x346>
mov    0x2aba(%rip),%rax
mov    (%rax),%rdi
call   1030 <raise@plt>
mov    $0x4d,%eax
jmp    1546 <main+0x346>
mov    0x2a5c(%rip),%rax
mov    (%rax),%rdi
call   1030 <raise@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.rusage = type { i32 }
%struct.TYPE_3__ = type { i64, i64 }
@WNOHANG = global i32 0
@__WALL = global i32 0
@P_PID = global i32 0
@WEXITED = global i32 0
@.str = [1 x i8] zeroinitializer
@SIGUSR1 = global i64 0
@SIGSTOP = global i64 0
@WUNTRACED = global i32 0
@SIGCONT = global i32 0
@WSTOPPED = global i32 0
@CLD_EXITED = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca i32
%4 = alloca i64
%5 = alloca %struct.rusage
%6 = alloca %struct.TYPE_3__
%7 = alloca i8
store i32 0, i32* %1
%8 = bitcast %struct.rusage* %5 to i8*
%9 = bitcast %struct.TYPE_3__* %6 to i8*
%10 = call i32 @close(i32 0)
%11 = call i32 @close(i32 1)
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%13 = call i32 @pipe(i32* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %0
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 1
br label %23
23: ; preds = %19, %15, %0
%24 = phi i1 [ false, %15 ], [ false, %0 ], [ %22, %19 ]
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = call i64 (...) @fork()
store i64 %27, i64* %4
%28 = load i64, i64* %4
%29 = icmp sge i64 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load i64, i64* %4
%33 = icmp ne i64 %32, 0
br i1 %33, label %40, label %34
34: ; preds = %23
%35 = call i32 @close(i32 1)
%36 = call i32 @read(i32 0, i8* %7, i32 1)
%37 = icmp eq i32 %36, 1
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
store i32 42, i32* %1
br label %184
40: ; preds = %23
%41 = call i32 @close(i32 0)
%42 = load i64, i64* %4
%43 = trunc i64 %42 to i32
%44 = load i32, i32* @WNOHANG
%45 = load i32, i32* @__WALL
%46 = or i32 %44, %45
%47 = call i32 @wait4(i32 %43, i32* %3, i32 %46, %struct.rusage* null)
%48 = icmp eq i32 %47, 0
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = load i32, i32* @P_PID
%52 = load i64, i64* %4
%53 = load i32, i32* @WNOHANG
%54 = load i32, i32* @WEXITED
%55 = or i32 %53, %54
%56 = call i64 @waitid(i32 %51, i64 %52, %struct.TYPE_3__* %6, i32 %55)
%57 = icmp eq i64 %56, 0
%58 = zext i1 %57 to i32
%59 = call i32 @assert(i32 %58)
%60 = call i32 @write(i32 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i32 1)
%61 = icmp eq i32 %60, 1
%62 = zext i1 %61 to i32
%63 = call i32 @assert(i32 %62)
%64 = call i32 @close(i32 1)
%65 = load i64, i64* %4
%66 = trunc i64 %65 to i32
%67 = call i32 @wait4(i32 %66, i32* %3, i32 0, %struct.rusage* %5)
%68 = sext i32 %67 to i64
%69 = load i64, i64* %4
%70 = icmp eq i64 %68, %69
%71 = zext i1 %70 to i32
%72 = call i32 @assert(i32 %71)
%73 = load i32, i32* %3
%74 = call i64 @WIFEXITED(i32 %73)
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %40
%77 = load i32, i32* %3
%78 = call i32 @WEXITSTATUS(i32 %77)
%79 = icmp eq i32 %78, 42
br label %80
80: ; preds = %76, %40
%81 = phi i1 [ false, %40 ], [ %79, %76 ]
%82 = zext i1 %81 to i32
%83 = call i32 @assert(i32 %82)
%84 = call i64 (...) @fork()
store i64 %84, i64* %4
%85 = load i64, i64* %4
%86 = icmp sge i64 %85, 0
%87 = zext i1 %86 to i32
%88 = call i32 @assert(i32 %87)
%89 = load i64, i64* %4
%90 = icmp ne i64 %89, 0
br i1 %90, label %94, label %91
91: ; preds = %80
%92 = load i64, i64* @SIGUSR1
%93 = call i32 @raise(i64 %92)
store i32 77, i32* %1
br label %184
94: ; preds = %80
%95 = load i64, i64* %4
%96 = trunc i64 %95 to i32
%97 = load i32, i32* @__WALL
%98 = call i32 @wait4(i32 %96, i32* %3, i32 %97, %struct.rusage* null)
%99 = sext i32 %98 to i64
%100 = load i64, i64* %4
%101 = icmp eq i64 %99, %100
%102 = zext i1 %101 to i32
%103 = call i32 @assert(i32 %102)
%104 = load i32, i32* %3
%105 = call i64 @WIFSIGNALED(i32 %104)
%106 = icmp ne i64 %105, 0
br i1 %106, label %107, label %112
107: ; preds = %94
%108 = load i32, i32* %3
%109 = call i64 @WTERMSIG(i32 %108)
%110 = load i64, i64* @SIGUSR1
%111 = icmp eq i64 %109, %110
br label %112
112: ; preds = %107, %94
%113 = phi i1 [ false, %94 ], [ %111, %107 ]
%114 = zext i1 %113 to i32
%115 = call i32 @assert(i32 %114)
%116 = call i64 (...) @fork()
store i64 %116, i64* %4
%117 = load i64, i64* %4
%118 = icmp sge i64 %117, 0
%119 = zext i1 %118 to i32
%120 = call i32 @assert(i32 %119)
%121 = load i64, i64* %4
%122 = icmp ne i64 %121, 0
br i1 %122, label %126, label %123
123: ; preds = %112
%124 = load i64, i64* @SIGSTOP
%125 = call i32 @raise(i64 %124)
store i32 0, i32* %1
br label %184
126: ; preds = %112
%127 = load i64, i64* %4
%128 = trunc i64 %127 to i32
%129 = load i32, i32* @WUNTRACED
%130 = call i32 @wait4(i32 %128, i32* %3, i32 %129, %struct.rusage* null)
%131 = sext i32 %130 to i64
%132 = load i64, i64* %4
%133 = icmp eq i64 %131, %132
%134 = zext i1 %133 to i32
%135 = call i32 @assert(i32 %134)
%136 = load i32, i32* %3
%137 = call i64 @WIFSTOPPED(i32 %136)
%138 = icmp ne i64 %137, 0
br i1 %138, label %139, label %144
139: ; preds = %126
%140 = load i32, i32* %3
%141 = call i64 @WSTOPSIG(i32 %140)
%142 = load i64, i64* @SIGSTOP
%143 = icmp eq i64 %141, %142
br label %144
144: ; preds = %139, %126
%145 = phi i1 [ false, %126 ], [ %143, %139 ]
%146 = zext i1 %145 to i32
%147 = call i32 @assert(i32 %146)
%148 = load i64, i64* %4
%149 = load i32, i32* @SIGCONT
%150 = call i64 @kill(i64 %148, i32 %149)
%151 = icmp eq i64 %150, 0
%152 = zext i1 %151 to i32
%153 = call i32 @assert(i32 %152)
%154 = load i32, i32* @P_PID
%155 = load i64, i64* %4
%156 = load i32, i32* @WEXITED
%157 = load i32, i32* @WSTOPPED
%158 = or i32 %156, %157
%159 = call i64 @waitid(i32 %154, i64 %155, %struct.TYPE_3__* %6, i32 %158)
%160 = icmp eq i64 %159, 0
%161 = zext i1 %160 to i32
%162 = call i32 @assert(i32 %161)
%163 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 0
%164 = load i64, i64* %163
%165 = load i64, i64* @CLD_EXITED
%166 = icmp eq i64 %164, %165
br i1 %166, label %167, label %171
167: ; preds = %144
%168 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 1
%169 = load i64, i64* %168
%170 = icmp eq i64 %169, 0
br label %171
171: ; preds = %167, %144
%172 = phi i1 [ false, %144 ], [ %170, %167 ]
%173 = zext i1 %172 to i32
%174 = call i32 @assert(i32 %173)
%175 = load i32, i32* @WNOHANG
%176 = load i32, i32* @WUNTRACED
%177 = or i32 %175, %176
%178 = load i32, i32* @__WALL
%179 = or i32 %177, %178
%180 = call i32 @wait4(i32 -1, i32* %3, i32 %179, %struct.rusage* %5)
%181 = icmp eq i32 %180, -1
%182 = zext i1 %181 to i32
%183 = call i32 @assert(i32 %182)
store i32 0, i32* %1
br label %184
184: ; preds = %171, %123, %91, %34
%185 = load i32, i32* %1
ret i32 %185
}

LLVM IR (-O2):
%struct.rusage = type { i32 }
%struct.TYPE_3__ = type { i64, i64 }
@WNOHANG = global i32 0
@__WALL = global i32 0
@P_PID = global i32 0
@WEXITED = global i32 0
@.str = [1 x i8] zeroinitializer
@SIGUSR1 = global i64 0
@SIGSTOP = global i64 0
@WUNTRACED = global i32 0
@SIGCONT = global i32 0
@WSTOPPED = global i32 0
@CLD_EXITED = global i64 0
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca i32
%3 = alloca %struct.rusage
%4 = alloca %struct.TYPE_3__
%5 = alloca i8
%6 = bitcast [2 x i32]* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast %struct.rusage* %3 to i8*
%9 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 0
store i32 0, i32* %9
%10 = bitcast %struct.TYPE_3__* %4 to i8*
%11 = tail call i32 @close(i32 0)
%12 = tail call i32 @close(i32 1)
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%14 = call i32 @pipe(i32* %13)
%15 = icmp eq i32 %14, 0
%16 = load i32, i32* %13
%17 = icmp eq i32 %16, 0
%18 = select i1 %15, i1 %17, i1 false
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 1
%22 = select i1 %18, i1 %21, i1 false
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = call i64 (...) @fork()
%26 = lshr i64 %25, 63
%27 = trunc i64 %26 to i32
%28 = xor i32 %27, 1
%29 = call i32 @assert(i32 %28)
%30 = icmp eq i64 %25, 0
br i1 %30, label %31, label %37
31: ; preds = %0
%32 = call i32 @close(i32 1)
%33 = call i32 @read(i32 0, i8* %5, i32 1)
%34 = icmp eq i32 %33, 1
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
br label %166
37: ; preds = %0
%38 = call i32 @close(i32 0)
%39 = trunc i64 %25 to i32
%40 = load i32, i32* @WNOHANG
%41 = load i32, i32* @__WALL
%42 = or i32 %41, %40
%43 = call i32 @wait4(i32 %39, i32* %2, i32 %42, %struct.rusage* null)
%44 = icmp eq i32 %43, 0
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = load i32, i32* @P_PID
%48 = load i32, i32* @WNOHANG
%49 = load i32, i32* @WEXITED
%50 = or i32 %49, %48
%51 = call i64 @waitid(i32 %47, i64 %25, %struct.TYPE_3__* %4, i32 %50)
%52 = icmp eq i64 %51, 0
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = call i32 @write(i32 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i32 1)
%56 = icmp eq i32 %55, 1
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = call i32 @close(i32 1)
%60 = call i32 @wait4(i32 %39, i32* %2, i32 0, %struct.rusage* %3)
%61 = sext i32 %60 to i64
%62 = icmp eq i64 %25, %61
%63 = zext i1 %62 to i32
%64 = call i32 @assert(i32 %63)
%65 = load i32, i32* %2
%66 = call i64 @WIFEXITED(i32 %65)
%67 = icmp eq i64 %66, 0
br i1 %67, label %73, label %68
68: ; preds = %37
%69 = load i32, i32* %2
%70 = call i32 @WEXITSTATUS(i32 %69)
%71 = icmp eq i32 %70, 42
%72 = zext i1 %71 to i32
br label %73
73: ; preds = %68, %37
%74 = phi i32 [ 0, %37 ], [ %72, %68 ]
%75 = call i32 @assert(i32 %74)
%76 = call i64 (...) @fork()
%77 = lshr i64 %76, 63
%78 = trunc i64 %77 to i32
%79 = xor i32 %78, 1
%80 = call i32 @assert(i32 %79)
%81 = icmp eq i64 %76, 0
br i1 %81, label %82, label %85
82: ; preds = %73
%83 = load i64, i64* @SIGUSR1
%84 = call i32 @raise(i64 %83)
br label %166
85: ; preds = %73
%86 = trunc i64 %76 to i32
%87 = load i32, i32* @__WALL
%88 = call i32 @wait4(i32 %86, i32* %2, i32 %87, %struct.rusage* null)
%89 = sext i32 %88 to i64
%90 = icmp eq i64 %76, %89
%91 = zext i1 %90 to i32
%92 = call i32 @assert(i32 %91)
%93 = load i32, i32* %2
%94 = call i64 @WIFSIGNALED(i32 %93)
%95 = icmp eq i64 %94, 0
br i1 %95, label %102, label %96
96: ; preds = %85
%97 = load i32, i32* %2
%98 = call i64 @WTERMSIG(i32 %97)
%99 = load i64, i64* @SIGUSR1
%100 = icmp eq i64 %98, %99
%101 = zext i1 %100 to i32
br label %102
102: ; preds = %96, %85
%103 = phi i32 [ 0, %85 ], [ %101, %96 ]
%104 = call i32 @assert(i32 %103)
%105 = call i64 (...) @fork()
%106 = lshr i64 %105, 63
%107 = trunc i64 %106 to i32
%108 = xor i32 %107, 1
%109 = call i32 @assert(i32 %108)
%110 = icmp eq i64 %105, 0
br i1 %110, label %111, label %114
111: ; preds = %102
%112 = load i64, i64* @SIGSTOP
%113 = call i32 @raise(i64 %112)
br label %166
114: ; preds = %102
%115 = trunc i64 %105 to i32
%116 = load i32, i32* @WUNTRACED
%117 = call i32 @wait4(i32 %115, i32* %2, i32 %116, %struct.rusage* null)
%118 = sext i32 %117 to i64
%119 = icmp eq i64 %105, %118
%120 = zext i1 %119 to i32
%121 = call i32 @assert(i32 %120)
%122 = load i32, i32* %2
%123 = call i64 @WIFSTOPPED(i32 %122)
%124 = icmp eq i64 %123, 0
br i1 %124, label %131, label %125
125: ; preds = %114
%126 = load i32, i32* %2
%127 = call i64 @WSTOPSIG(i32 %126)
%128 = load i64, i64* @SIGSTOP
%129 = icmp eq i64 %127, %128
%130 = zext i1 %129 to i32
br label %131
131: ; preds = %125, %114
%132 = phi i32 [ 0, %114 ], [ %130, %125 ]
%133 = call i32 @assert(i32 %132)
%134 = load i32, i32* @SIGCONT
%135 = call i64 @kill(i64 %105, i32 %134)
%136 = icmp eq i64 %135, 0
%137 = zext i1 %136 to i32
%138 = call i32 @assert(i32 %137)
%139 = load i32, i32* @P_PID
%140 = load i32, i32* @WEXITED
%141 = load i32, i32* @WSTOPPED
%142 = or i32 %141, %140
%143 = call i64 @waitid(i32 %139, i64 %105, %struct.TYPE_3__* %4, i32 %142)
%144 = icmp eq i64 %143, 0
%145 = zext i1 %144 to i32
%146 = call i32 @assert(i32 %145)
%147 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i64 0, i32 0
%148 = load i64, i64* %147
%149 = load i64, i64* @CLD_EXITED
%150 = icmp eq i64 %148, %149
%151 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i64 0, i32 1
%152 = load i64, i64* %151
%153 = icmp eq i64 %152, 0
%154 = select i1 %150, i1 %153, i1 false
%155 = zext i1 %154 to i32
%156 = call i32 @assert(i32 %155)
%157 = load i32, i32* @WNOHANG
%158 = load i32, i32* @WUNTRACED
%159 = or i32 %158, %157
%160 = load i32, i32* @__WALL
%161 = or i32 %159, %160
%162 = call i32 @wait4(i32 -1, i32* %2, i32 %161, %struct.rusage* %3)
%163 = icmp eq i32 %162, -1
%164 = zext i1 %163 to i32
%165 = call i32 @assert(i32 %164)
br label %166
166: ; preds = %131, %111, %82, %31
%167 = phi i32 [ 0, %131 ], [ 0, %111 ], [ 77, %82 ], [ 42, %31 ]
ret i32 %167
}