#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*/ EXIT_FAILURE;
int PTRACE_O_TRACECLONE;
int PTRACE_O_TRACEEXEC;
int PTRACE_O_TRACEEXIT;
int PTRACE_O_TRACEFORK;
int PTRACE_O_TRACESYSGOOD;
int PTRACE_O_TRACEVFORK;
int /*<<< orphan*/ PTRACE_SETOPTIONS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int ptrace(int /*<<< orphan*/, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
void ptrace_prepare(int pid) {
  int r =
      ptrace(PTRACE_SETOPTIONS, pid, 0,
             PTRACE_O_TRACESYSGOOD | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK |
                 PTRACE_O_TRACECLONE | PTRACE_O_TRACEEXEC | PTRACE_O_TRACEEXIT);
  if (r != 0)
    do {
      fprintf(stderr, "ptrace(PTRACE_SETOPTIONS)");
      fprintf(stderr, "\n");
      perror("");
      exit(EXIT_FAILURE);
    } while (0);
}


x86 assembly (clang, -O0):
<ptrace_prepare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%esi
mov    0x2e7a(%rip),%rax
mov    (%rax),%ecx
mov    0x2e41(%rip),%rax
or     (%rax),%ecx
mov    0x2e88(%rip),%rax
or     (%rax),%ecx
mov    0x2e1f(%rip),%rax
or     (%rax),%ecx
mov    0x2e46(%rip),%rax
or     (%rax),%ecx
mov    0x2e55(%rip),%rax
or     (%rax),%ecx
xor    %edx,%edx
call   1040 <ptrace@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11ea <ptrace_prepare+0xaa>
jmp    11a6 <ptrace_prepare+0x66>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xe44(%rip),%rdi
call   1050 <perror@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptrace_prepare>:
push   %rbx
mov    0x2e90(%rip),%rax
mov    0x2e59(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e9e(%rip),%rax
or     (%rax),%ecx
mov    %edi,%esi
mov    0x2e33(%rip),%rax
or     (%rax),%ecx
mov    0x2e62(%rip),%rax
mov    0x2e53(%rip),%rdx
or     (%rdx),%ecx
mov    (%rax),%edi
mov    0x2e60(%rip),%rax
or     (%rax),%ecx
xor    %edx,%edx
call   1040 <ptrace@plt>
test   %eax,%eax
jne    118f <ptrace_prepare+0x4f>
pop    %rbx
ret
mov    0x2e22(%rip),%rbx
mov    (%rbx),%edi
lea    0xe61(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe6d(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xe62(%rip),%rdi
call   1050 <perror@plt>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@PTRACE_SETOPTIONS = global i32 0
@PTRACE_O_TRACESYSGOOD = global i32 0
@PTRACE_O_TRACEFORK = global i32 0
@PTRACE_O_TRACEVFORK = global i32 0
@PTRACE_O_TRACECLONE = global i32 0
@PTRACE_O_TRACEEXEC = global i32 0
@PTRACE_O_TRACEEXIT = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"ptrace(PTRACE_SETOPTIONS)\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@EXIT_FAILURE = global i32 0
define void @ptrace_prepare(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* @PTRACE_SETOPTIONS
%5 = load i32, i32* %2
%6 = load i32, i32* @PTRACE_O_TRACESYSGOOD
%7 = load i32, i32* @PTRACE_O_TRACEFORK
%8 = or i32 %6, %7
%9 = load i32, i32* @PTRACE_O_TRACEVFORK
%10 = or i32 %8, %9
%11 = load i32, i32* @PTRACE_O_TRACECLONE
%12 = or i32 %10, %11
%13 = load i32, i32* @PTRACE_O_TRACEEXEC
%14 = or i32 %12, %13
%15 = load i32, i32* @PTRACE_O_TRACEEXIT
%16 = or i32 %14, %15
%17 = call i32 @ptrace(i32 %4, i32 %5, i32 0, i32 %16)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %1
br label %21
21: ; preds = %20
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; No predecessors!
br label %30
30: ; preds = %29, %1
ret void
}

LLVM IR (-O2):
@PTRACE_SETOPTIONS = global i32 0
@PTRACE_O_TRACESYSGOOD = global i32 0
@PTRACE_O_TRACEFORK = global i32 0
@PTRACE_O_TRACEVFORK = global i32 0
@PTRACE_O_TRACECLONE = global i32 0
@PTRACE_O_TRACEEXEC = global i32 0
@PTRACE_O_TRACEEXIT = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"ptrace(PTRACE_SETOPTIONS)\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@EXIT_FAILURE = global i32 0
define void @ptrace_prepare(i32 %0) {
%2 = load i32, i32* @PTRACE_SETOPTIONS
%3 = load i32, i32* @PTRACE_O_TRACESYSGOOD
%4 = load i32, i32* @PTRACE_O_TRACEFORK
%5 = or i32 %4, %3
%6 = load i32, i32* @PTRACE_O_TRACEVFORK
%7 = or i32 %5, %6
%8 = load i32, i32* @PTRACE_O_TRACECLONE
%9 = or i32 %7, %8
%10 = load i32, i32* @PTRACE_O_TRACEEXEC
%11 = or i32 %9, %10
%12 = load i32, i32* @PTRACE_O_TRACEEXIT
%13 = or i32 %11, %12
%14 = tail call i32 @ptrace(i32 %2, i32 %0, i32 0, i32 %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %1
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %1
ret void
}