#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 execvp(char *, char **);
char *getenv(char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
void setdumpable() {
  int s;
  int u;
  char *args[2];
  args[0] = "/bin/sh";
  args[1] = NULL;
  if (strcmp(getenv("USER"), "root") == 0) {
    u = execvp(args[0], args);
  } else {
    printf("My user is: %s\n", getenv("USER"));
  }
}


x86 assembly (clang, -O0):
<setdumpable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xea6(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
lea    0xe9c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1195 <setdumpable+0x55>
mov    -0x20(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <execvp@plt>
mov    %eax,-0x8(%rbp)
jmp    11b0 <setdumpable+0x70>
lea    0xe6c(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rsi
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setdumpable>:
sub    $0x18,%rsp
lea    0xeb5(%rip),%rax
mov    %rax,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xea9(%rip),%rdi
call   1030 <getenv@plt>
lea    0xea2(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1197 <setdumpable+0x57>
lea    0xe89(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe87(%rip),%rdi
mov    %rax,%rsi
add    $0x18,%rsp
jmp    1040 <printf@plt>
lea    0xe62(%rip),%rdi
mov    %rsp,%rsi
call   1060 <execvp@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"/bin/sh\00"
@.str.1 = [5 x i8] c"USER\00"
@.str.2 = [5 x i8] c"root\00"
@.str.3 = [16 x i8] c"My user is: %s\0A\00"
define void @setdumpable() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [2 x i8*]
%4 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 1
store i8* null, i8** %5
%6 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
%11 = load i8*, i8** %10
%12 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
%13 = call i32 @execvp(i8* %11, i8** %12)
store i32 %13, i32* %2
br label %17
14: ; preds = %0
%15 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14, %9
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"/bin/sh\00"
@.str.1 = [5 x i8] c"USER\00"
@.str.2 = [5 x i8] c"root\00"
@.str.3 = [16 x i8] c"My user is: %s\0A\00"
define void @setdumpable() {
%1 = alloca [2 x i8*]
%2 = bitcast [2 x i8*]* %1 to i8*
%3 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 1
store i8* null, i8** %4
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @execvp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %3)
br label %13
10: ; preds = %0
%11 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10, %8
ret void
}