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

/* Variables and functions */
int /*<<< orphan*/ geteuid();
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, const char *argv[]) {
  register struct passwd *pw;
  register uid_t uid;
  uid = geteuid();
  pw = getpwuid(uid);
  if (pw) {
    printf("%s\n", pw->pw_name);
    return 0;
  }
  return 1;
}


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,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1186 <main+0x56>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    118d <main+0x5d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <geteuid@plt>
mov    %eax,%edi
call   1030 <getpwuid@plt>
test   %rax,%rax
je     1157 <main+0x27>
mov    (%rax),%rsi
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
jmp    115c <main+0x2c>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.passwd = type { i8* }
@.str = [4 x i8] c"%s\0A\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 eq %struct.passwd* %4, null
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.passwd, %struct.passwd* %4, i64 0, i32 0
%8 = load i8*, i8** %7
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %2, %6
%11 = phi i32 [ 0, %6 ], [ 1, %2 ]
ret i32 %11
}