#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 WEXITSTATUS(int);
int /*<<< orphan*/ WIFEXITED(int);
int __chk_error(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ error1(char *, int, char *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
void test_fork(void) {
  int pid, status;
  pid = __chk_error(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/OXT-112/Codes/"
      "xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c",
      217, (fork()));
  if (pid == 0) {
    exit(2);
  }
  __chk_error("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/"
              "OXT-112/Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c",
              222, (waitpid(pid, &status, 0)));
  if (!WIFEXITED(status) || WEXITSTATUS(status) != 2)
    error1("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/OXT-112/"
           "Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c",
           224, "waitpid status=0x%x", status);
}


x86 assembly (clang, -O0):
<test_fork>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,%edx
lea    0xe78(%rip),%rdi
mov    $0xd9,%esi
call   1030 <__chk_error@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11a9 <test_fork+0x39>
mov    $0x2,%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1050 <waitpid@plt>
mov    %eax,%edx
lea    0xe40(%rip),%rdi
mov    $0xde,%esi
call   1030 <__chk_error@plt>
mov    -0x8(%rbp),%edi
call   1060 <WIFEXITED@plt>
cmp    $0x0,%eax
je     11ec <test_fork+0x7c>
mov    -0x8(%rbp),%edi
call   1040 <WEXITSTATUS@plt>
cmp    $0x2,%eax
je     1207 <test_fork+0x97>
mov    -0x8(%rbp),%ecx
lea    0xe0a(%rip),%rdi
mov    $0xe0,%esi
lea    0xeb5(%rip),%rdx
call   1080 <error1@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_fork>:
push   %rax
xor    %eax,%eax
call   1090 <fork@plt>
lea    0xe81(%rip),%rdi
mov    $0xd9,%esi
mov    %eax,%edx
call   1030 <__chk_error@plt>
test   %eax,%eax
je     11e9 <test_fork+0x79>
lea    0x4(%rsp),%rsi
mov    %eax,%edi
xor    %edx,%edx
call   1050 <waitpid@plt>
lea    0xe5c(%rip),%rdi
mov    $0xde,%esi
mov    %eax,%edx
call   1030 <__chk_error@plt>
mov    0x4(%rsp),%edi
call   1060 <WIFEXITED@plt>
test   %eax,%eax
je     11cb <test_fork+0x5b>
mov    0x4(%rsp),%edi
call   1040 <WEXITSTATUS@plt>
cmp    $0x2,%eax
je     11e7 <test_fork+0x77>
mov    0x4(%rsp),%ecx
lea    0xe2a(%rip),%rdi
lea    0xeda(%rip),%rdx
mov    $0xe0,%esi
call   1080 <error1@plt>
pop    %rax
ret
mov    $0x2,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [183 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/OXT-112/Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c\00"
@.str.1 = [20 x i8] c"waitpid status=0x%x\00"
define void @test_fork() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @fork()
%4 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 217, i32 %3)
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @exit(i32 2)
unreachable
9: ; preds = %0
%10 = load i32, i32* %1
%11 = call i32 @waitpid(i32 %10, i32* %2, i32 0)
%12 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 222, i32 %11)
%13 = load i32, i32* %2
%14 = call i32 @WIFEXITED(i32 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %9
%17 = load i32, i32* %2
%18 = call i32 @WEXITSTATUS(i32 %17)
%19 = icmp ne i32 %18, 2
br i1 %19, label %20, label %23
20: ; preds = %16, %9
%21 = load i32, i32* %2
%22 = call i32 @error1(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 224, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %16
ret void
}

LLVM IR (-O2):
@.str = [183 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Jin-Yang/QEMU-1.4.2/refs/heads/OXT-112/Codes/xen-4.3.1/tools/qemu-xen/tests/tcg/linux-test.c\00"
@.str.1 = [20 x i8] c"waitpid status=0x%x\00"
define void @test_fork() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @fork()
%4 = tail call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 217, i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 @exit(i32 2)
unreachable
8: ; preds = %0
%9 = call i32 @waitpid(i32 %4, i32* %1, i32 0)
%10 = call i32 @__chk_error(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 222, i32 %9)
%11 = load i32, i32* %1
%12 = call i32 @WIFEXITED(i32 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %8
%15 = load i32, i32* %1
%16 = call i32 @WEXITSTATUS(i32 %15)
%17 = icmp eq i32 %16, 2
br i1 %17, label %21, label %18
18: ; preds = %14, %8
%19 = load i32, i32* %1
%20 = call i32 @error1(i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 224, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %14
ret void
}