#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 strlen(char *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, const char *argv[]) {
  register struct passwd *pw;
  register uid_t uid;
  uid = geteuid();
  pw = getpwuid(uid);
  if (pw) {
    write(1, pw->pw_name, strlen(pw->pw_name));
    write(1, "\n", 1);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <geteuid@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11bd <main+0x7d>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xe56(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c4 <main+0x84>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <geteuid@plt>
mov    %eax,%edi
call   1040 <getpwuid@plt>
test   %rax,%rax
je     118a <main+0x4a>
mov    (%rax),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe87(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
jmp    118f <main+0x4f>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.passwd = type { i8* }
@.str = [2 x i8] c"\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 %23
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 = load %struct.passwd*, %struct.passwd** %6
%18 = getelementptr inbounds %struct.passwd, %struct.passwd* %17, i32 0, i32 0
%19 = load i8*, i8** %18
%20 = call i32 @strlen(i8* %19)
%21 = call i32 @write(i32 1, i8* %16, i32 %20)
%22 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
store i32 0, i32* %3
br label %24
23: ; preds = %2
store i32 1, i32* %3
br label %24
24: ; preds = %23, %13
%25 = load i32, i32* %3
ret i32 %25
}

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