#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 scalar_t__ pid_t;

/* Variables and functions */
scalar_t__ fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ run_target(char *);
int /*<<< orphan*/ test1_debugger(scalar_t__);
int test1() {
  pid_t child_pid;
  child_pid = fork();
  if (child_pid == 0)
    run_target("traced_c_loop");
  else if (child_pid > 0)
    test1_debugger(child_pid);
  else {
    perror("fork");
    return -1;
  }
  printf("TEST1 PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117f <test1+0x2f>
lea    0xe8b(%rip),%rdi
call   1040 <run_target@plt>
jmp    11b5 <test1+0x65>
cmpq   $0x0,-0x10(%rbp)
jle    1198 <test1+0x48>
mov    -0x10(%rbp),%rdi
call   1050 <test1_debugger@plt>
jmp    11b0 <test1+0x60>
lea    0xe6f(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c8 <test1+0x78>
jmp    11b5 <test1+0x65>
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test1>:
push   %rax
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     1169 <test1+0x19>
jle    1185 <test1+0x35>
mov    %rax,%rdi
call   1050 <test1_debugger@plt>
jmp    1175 <test1+0x25>
lea    0xe90(%rip),%rdi
call   1040 <run_target@plt>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe82(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"traced_c_loop\00"
@.str.1 = [5 x i8] c"fork\00"
@.str.2 = [12 x i8] c"TEST1 PASS\0A\00"
define i32 @test1() {
%1 = alloca i32
%2 = alloca i64
%3 = call i64 (...) @fork()
store i64 %3, i64* %2
%4 = load i64, i64* %2
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @run_target(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %17
8: ; preds = %0
%9 = load i64, i64* %2
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i64, i64* %2
%13 = call i32 @test1_debugger(i64 %12)
br label %16
14: ; preds = %8
%15 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %19
16: ; preds = %11
br label %17
17: ; preds = %16, %6
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %19
19: ; preds = %17, %14
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [14 x i8] c"traced_c_loop\00"
@.str.1 = [5 x i8] c"fork\00"
@str = [11 x i8] c"TEST1 PASS\00"
define i32 @test1() {
%1 = tail call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @run_target(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %11
5: ; preds = %0
%6 = icmp sgt i64 %1, 0
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 @test1_debugger(i64 %1)
br label %11
9: ; preds = %5
%10 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %13
11: ; preds = %7, %3
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
%14 = phi i32 [ 0, %11 ], [ -1, %9 ]
ret i32 %14
}