#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 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*/ perror(char *);
int ptrace(int /*<<< orphan*/, int, int /*<<< orphan*/, int);
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)
    perror("ptrace(PTRACE_SETOPTIONS)");
}


x86 assembly (clang, -O0):
<ptrace_prepare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%esi
mov    0x2e9a(%rip),%rax
mov    (%rax),%ecx
mov    0x2e71(%rip),%rax
or     (%rax),%ecx
mov    0x2ea8(%rip),%rax
or     (%rax),%ecx
mov    0x2e4f(%rip),%rax
or     (%rax),%ecx
mov    0x2e66(%rip),%rax
or     (%rax),%ecx
mov    0x2e75(%rip),%rax
or     (%rax),%ecx
xor    %edx,%edx
call   1030 <ptrace@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     118d <ptrace_prepare+0x6d>
lea    0xe78(%rip),%rdi
call   1040 <perror@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptrace_prepare>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    0x2e89(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2ebe(%rip),%rax
or     (%rax),%ecx
mov    %edi,%esi
mov    0x2e63(%rip),%rax
or     (%rax),%ecx
mov    0x2e82(%rip),%rax
mov    0x2e73(%rip),%rdx
or     (%rdx),%ecx
mov    (%rax),%edi
mov    0x2e80(%rip),%rax
or     (%rax),%ecx
xor    %edx,%edx
call   1030 <ptrace@plt>
test   %eax,%eax
jne    116f <ptrace_prepare+0x4f>
pop    %rax
ret
lea    0xe8a(%rip),%rdi
pop    %rax
jmp    1040 <perror@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
@.str = [26 x i8] c"ptrace(PTRACE_SETOPTIONS)\00"
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 %22
20: ; preds = %1
%21 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %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
@.str = [26 x i8] c"ptrace(PTRACE_SETOPTIONS)\00"
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 %18, label %16
16: ; preds = %1
%17 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %1
ret void
}