#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(int);
char *getenv(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
void isSudo() {
  char *foo = getenv("USER");
  if (strcmp(foo, "root") == 0) {
    printf("isSudo: foo = %s\n   You may continue.\n", foo);
  } else {
    printf("isSudo: user = %s\n   You must run as root.\n", foo);
    printf("isSudo: usage: sudo ./test\n");
    _exit(1);
  }
}


x86 assembly (clang, -O0):
<isSudo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1189 <isSudo+0x49>
mov    -0x8(%rbp),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11b3 <isSudo+0x73>
mov    -0x8(%rbp),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1040 <_exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isSudo>:
push   %rbx
lea    0xea8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0xe9e(%rip),%rsi
mov    %rax,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1186 <isSudo+0x36>
lea    0xe8f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
pop    %rbx
jmp    1060 <printf@plt>
lea    0xea4(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xebf(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1040 <_exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"USER\00"
@.str.1 = [5 x i8] c"root\00"
@.str.2 = [39 x i8] c"isSudo: foo = %s\0A You may continue.\0A\00"
@.str.3 = [44 x i8] c"isSudo: user = %s\0A You must run as root.\0A\00"
@.str.4 = [28 x i8] c"isSudo: usage: sudo ./test\0A\00"
define void @isSudo() {
%1 = alloca i8*
%2 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %2, i8** %1
%3 = load i8*, i8** %1
%4 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i8*, i8** %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %14
9: ; preds = %0
%10 = load i8*, i8** %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @_exit(i32 1)
unreachable
14: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"USER\00"
@.str.1 = [5 x i8] c"root\00"
@.str.2 = [39 x i8] c"isSudo: foo = %s\0A You may continue.\0A\00"
@.str.3 = [44 x i8] c"isSudo: user = %s\0A You must run as root.\0A\00"
@str = [27 x i8] c"isSudo: usage: sudo ./test\00"
define void @isSudo() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %1)
ret void
6: ; preds = %0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @_exit(i32 1)
unreachable
}