#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 */
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ WEXITSTATUS(int);
int /*<<< orphan*/ WIFEXITED(int);
int /*<<< orphan*/ ctap_assert(int, int, char *, int, char *);
int /*<<< orphan*/ ctap_bail(char *);
int /*<<< orphan*/ ctap_eq_i64(int /*<<< orphan*/, int, char *, int, char *);
int /*<<< orphan*/ done_testing();
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ no_plan();
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
void ctap_tests(void) {
  no_plan();
  int rc;
  pid_t pid;
  ctap_assert(
      1, 0,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/filefrog/ctap/refs/heads/master/t/fork.aux.c",
      31, "in parent");
  pid = fork();
  switch (pid) {
  case -1:
    ctap_bail("fork failed!");
  case 0:
    exit(4);
  default:
    waitpid(pid, &rc, 0);
    ctap_assert(!!(WIFEXITED(rc)), 1,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/filefrog/ctap/refs/heads/"
                "master/t/fork.aux.c",
                42, "child process exited normally");
    ctap_eq_i64((WEXITSTATUS(rc)), (4),
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/filefrog/ctap/refs/heads/"
                "master/t/fork.aux.c",
                43, "child process exit code");
  }
  done_testing();
}


x86 assembly (clang, -O0):
<ctap_tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %eax,-0x14(%rbp)
mov    %al,-0xd(%rbp)
call   1070 <no_plan@plt>
mov    -0x14(%rbp),%esi
lea    0xe41(%rip),%rdx
lea    0xec1(%rip),%r8
mov    $0x1,%edi
mov    $0x1f,%ecx
call   1030 <ctap_assert@plt>
mov    -0xd(%rbp),%al
call   10c0 <fork@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0xffffffff,%eax
je     1204 <ctap_tests+0x64>
jmp    11f4 <ctap_tests+0x54>
mov    -0xc(%rbp),%eax
test   %eax,%eax
je     1210 <ctap_tests+0x70>
jmp    121a <ctap_tests+0x7a>
lea    0xe86(%rip),%rdi
call   1050 <ctap_bail@plt>
mov    $0x4,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0x4(%rbp),%rsi
xor    %edx,%edx
call   1090 <waitpid@plt>
mov    -0x4(%rbp),%edi
call   10a0 <WIFEXITED@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x1,%esi
lea    0xdb5(%rip),%rdx
mov    $0x2a,%ecx
lea    0xe47(%rip),%r8
call   1030 <ctap_assert@plt>
mov    -0x4(%rbp),%edi
call   1080 <WEXITSTATUS@plt>
mov    %eax,%edi
mov    $0x4,%esi
lea    0xd8e(%rip),%rdx
mov    $0x2b,%ecx
lea    0xe3e(%rip),%r8
call   1040 <ctap_eq_i64@plt>
mov    $0x0,%al
call   1060 <done_testing@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ctap_tests>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1070 <no_plan@plt>
lea    0xe4d(%rip),%rdx
lea    0xecd(%rip),%r8
mov    $0x1,%edi
xor    %esi,%esi
mov    $0x1f,%ecx
call   1030 <ctap_assert@plt>
xor    %eax,%eax
call   10c0 <fork@plt>
test   %eax,%eax
je     125b <ctap_tests+0xbb>
cmp    $0xffffffff,%eax
je     124f <ctap_tests+0xaf>
lea    0xc(%rsp),%rsi
mov    %eax,%edi
xor    %edx,%edx
call   1090 <waitpid@plt>
mov    0xc(%rsp),%edi
call   10a0 <WIFEXITED@plt>
xor    %edi,%edi
test   %eax,%eax
setne  %dil
lea    0xdfb(%rip),%rbx
lea    0xe92(%rip),%r8
mov    $0x1,%esi
mov    %rbx,%rdx
mov    $0x2a,%ecx
call   1030 <ctap_assert@plt>
mov    0xc(%rsp),%edi
call   1080 <WEXITSTATUS@plt>
lea    0xe8e(%rip),%r8
mov    %eax,%edi
mov    $0x4,%esi
mov    %rbx,%rdx
mov    $0x2b,%ecx
call   1040 <ctap_eq_i64@plt>
xor    %eax,%eax
call   1060 <done_testing@plt>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe3b(%rip),%rdi
call   1050 <ctap_bail@plt>
mov    $0x4,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/filefrog/ctap/refs/heads/master/t/fork.aux.c\00"
@.str.1 = [10 x i8] c"in parent\00"
@.str.2 = [13 x i8] c"fork failed!\00"
@.str.3 = [30 x i8] c"child process exited normally\00"
@.str.4 = [24 x i8] c"child process exit code\00"
define void @ctap_tests() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @no_plan()
%4 = call i32 @ctap_assert(i32 1, i32 0, i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0), i32 31, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (...) @fork()
store i32 %5, i32* %2
%6 = load i32, i32* %2
switch i32 %6, label %11 [
i32 -1, label %7
i32 0, label %9
]
7: ; preds = %0
%8 = call i32 @ctap_bail(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %0, %7
%10 = call i32 @exit(i32 4)
unreachable
11: ; preds = %0
%12 = load i32, i32* %2
%13 = call i32 @waitpid(i32 %12, i32* %1, i32 0)
%14 = load i32, i32* %1
%15 = call i32 @WIFEXITED(i32 %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
%18 = xor i1 %17, true
%19 = zext i1 %18 to i32
%20 = call i32 @ctap_assert(i32 %19, i32 1, i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0), i32 42, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%21 = load i32, i32* %1
%22 = call i32 @WEXITSTATUS(i32 %21)
%23 = call i32 @ctap_eq_i64(i32 %22, i32 4, i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0), i32 43, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %24
24: ; preds = %11
%25 = call i32 (...) @done_testing()
ret void
}

LLVM IR (-O2):
@.str = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/filefrog/ctap/refs/heads/master/t/fork.aux.c\00"
@.str.1 = [10 x i8] c"in parent\00"
@.str.2 = [13 x i8] c"fork failed!\00"
@.str.3 = [30 x i8] c"child process exited normally\00"
@.str.4 = [24 x i8] c"child process exit code\00"
define void @ctap_tests() {
%1 = alloca i32
%2 = tail call i32 (...) @no_plan()
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @ctap_assert(i32 1, i32 0, i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0), i32 31, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 (...) @fork()
switch i32 %5, label %10 [
i32 -1, label %6
i32 0, label %8
]
6: ; preds = %0
%7 = tail call i32 @ctap_bail(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %0, %6
%9 = tail call i32 @exit(i32 4)
unreachable
10: ; preds = %0
%11 = call i32 @waitpid(i32 %5, i32* %1, i32 0)
%12 = load i32, i32* %1
%13 = call i32 @WIFEXITED(i32 %12)
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @ctap_assert(i32 %15, i32 1, i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0), i32 42, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* %1
%18 = call i32 @WEXITSTATUS(i32 %17)
%19 = call i32 @ctap_eq_i64(i32 %18, i32 4, i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0), i32 43, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 (...) @done_testing()
ret void
}