#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*/ die(char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ execl(char *, char *, char *, int /*<<< orphan*/ *);
scalar_t__ getuid();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putenv(char *);
void exit_code() {
  if (getuid() != 0)
    die("wtf", 0);
  printf("[+] root\n");
  putenv("HISTFILE=/dev/null");
  execl("/bin/bash", "bash", "-i", NULL);
  die("/bin/bash", errno);
}


x86 assembly (clang, -O0):
<exit_code>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <getuid@plt>
cmp    $0x0,%rax
je     1173 <exit_code+0x23>
lea    0xe94(%rip),%rdi
xor    %esi,%esi
call   1060 <die@plt>
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
call   1050 <putenv@plt>
lea    0xe8f(%rip),%rdi
lea    0xe8d(%rip),%rsi
lea    0xe8b(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1070 <execl@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%esi
lea    0xe68(%rip),%rdi
call   1060 <die@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<exit_code>:
push   %rbx
xor    %eax,%eax
call   1040 <getuid@plt>
test   %rax,%rax
je     116b <exit_code+0x1b>
lea    0xe9c(%rip),%rdi
xor    %esi,%esi
call   1060 <die@plt>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe86(%rip),%rdi
call   1050 <putenv@plt>
lea    0xe8d(%rip),%rbx
lea    0xe8b(%rip),%rsi
lea    0xe89(%rip),%rdx
mov    %rbx,%rdi
xor    %ecx,%ecx
call   1070 <execl@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
pop    %rbx
jmp    1060 <die@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"wtf\00"
@.str.1 = [10 x i8] c"[+] root\0A\00"
@.str.2 = [19 x i8] c"HISTFILE=/dev/null\00"
@.str.3 = [10 x i8] c"/bin/bash\00"
@.str.4 = [5 x i8] c"bash\00"
@.str.5 = [3 x i8] c"-i\00"
@errno = global i32 0
define void @exit_code() {
%1 = call i64 (...) @getuid()
%2 = icmp ne i64 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = call i32 @die(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
br label %5
5: ; preds = %3, %0
%6 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @putenv(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* null)
%9 = load i32, i32* @errno
%10 = call i32 @die(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %9)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"wtf\00"
@.str.2 = [19 x i8] c"HISTFILE=/dev/null\00"
@.str.3 = [10 x i8] c"/bin/bash\00"
@.str.4 = [5 x i8] c"bash\00"
@.str.5 = [3 x i8] c"-i\00"
@errno = global i32 0
@str = [9 x i8] c"[+] root\00"
define void @exit_code() {
%1 = tail call i64 (...) @getuid()
%2 = icmp eq i64 %1, 0
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @die(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
br label %5
5: ; preds = %3, %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @putenv(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* null)
%9 = load i32, i32* @errno
%10 = tail call i32 @die(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %9)
ret void
}