#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*/ PTRACE_TRACEME;
int /*<<< orphan*/ execl(char const *, char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ procmsg(char *, char const *);
scalar_t__ ptrace(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
                  int /*<<< orphan*/);
void run_target(const char *programname) {
  procmsg("target started. will run '%s'\n", programname);
  if (ptrace(PTRACE_TRACEME, 0, 0, 0) < 0) {
    perror("ptrace");
    return;
  }
  execl(programname, programname, NULL);
}


x86 assembly (clang, -O0):
<run_target>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea9(%rip),%rdi
call   1030 <procmsg@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
xor    %ecx,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1040 <ptrace@plt>
cmp    $0x0,%rax
jge    118b <run_target+0x4b>
lea    0xe9e(%rip),%rdi
call   1050 <perror@plt>
jmp    119c <run_target+0x5c>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <execl@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_target>:
push   %rbx
mov    %rdi,%rbx
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <procmsg@plt>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <ptrace@plt>
test   %rax,%rax
js     117a <run_target+0x3a>
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
pop    %rbx
jmp    1060 <execl@plt>
lea    0xe9e(%rip),%rdi
pop    %rbx
jmp    1050 <perror@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"target started. will run '%s'\0A\00"
@PTRACE_TRACEME = global i32 0
@.str.1 = [7 x i8] c"ptrace\00"
define void @run_target(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @procmsg(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = load i32, i32* @PTRACE_TRACEME
%6 = call i64 @ptrace(i32 %5, i32 0, i32 0, i32 0)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %14
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = load i8*, i8** %2
%13 = call i32 @execl(i8* %11, i8* %12, i32* null)
br label %14
14: ; preds = %10, %8
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"target started. will run '%s'\0A\00"
@PTRACE_TRACEME = global i32 0
@.str.1 = [7 x i8] c"ptrace\00"
define void @run_target(i8* %0) {
%2 = tail call i32 @procmsg(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = load i32, i32* @PTRACE_TRACEME
%4 = tail call i64 @ptrace(i32 %3, i32 0, i32 0, i32 0)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %10
8: ; preds = %1
%9 = tail call i32 @execl(i8* %0, i8* %0, i32* null)
br label %10
10: ; preds = %8, %6
ret void
}