#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 */
struct passwd {
  int /*<<< orphan*/ pw_name;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ geteuid();
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct passwd *pw = getpwuid(geteuid());
  assert(pw != NULL);
  if (strcmp("root", pw->pw_name) == 0) {
    printf("Hello, r00t!\n");
  } else {
    printf("Hello, user!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <geteuid@plt>
mov    %eax,%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe69(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11b7 <main+0x67>
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
jmp    11c3 <main+0x73>
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <geteuid@plt>
mov    %eax,%edi
call   1040 <getpwuid@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1070 <assert@plt>
mov    (%rbx),%esi
lea    0xe87(%rip),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
lea    0xe8a(%rip),%rax
lea    0xe76(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.passwd = type { i32 }
@.str = [5 x i8] c"root\00"
@.str.1 = [14 x i8] c"Hello, r00t!\0A\00"
@.str.2 = [14 x i8] c"Hello, user!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @geteuid()
%8 = call %struct.passwd* @getpwuid(i32 %7)
store %struct.passwd* %8, %struct.passwd** %6
%9 = load %struct.passwd*, %struct.passwd** %6
%10 = icmp ne %struct.passwd* %9, null
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load %struct.passwd*, %struct.passwd** %6
%14 = getelementptr inbounds %struct.passwd, %struct.passwd* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %22
20: ; preds = %2
%21 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
ret i32 0
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
@.str = [5 x i8] c"root\00"
@str = [13 x i8] c"Hello, user!\00"
@str.3 = [13 x i8] c"Hello, r00t!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @geteuid()
%4 = tail call %struct.passwd* @getpwuid(i32 %3)
%5 = icmp ne %struct.passwd* %4, null
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = getelementptr inbounds %struct.passwd, %struct.passwd* %4, i64 0, i32 0
%9 = load i32, i32* %8
%10 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0)
%13 = tail call i32 @puts(i8* dereferenceable(1) %12)
ret i32 0
}