#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 {
  char *pw_name;
};

/* Variables and functions */
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ exit(int);
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
int strlen(char *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main(void) {
  register struct passwd *upw = getpwuid(getuid());
  if (upw) {
    write(STDOUT_FILENO, upw->pw_name, strlen(upw->pw_name));
    write(STDOUT_FILENO, "\n", 1);
    exit(0);
  }
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <getuid@plt>
mov    %eax,%edi
call   1040 <getpwuid@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11ce <main+0x7e>
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1060 <getuid@plt>
mov    %eax,%edi
call   1040 <getpwuid@plt>
test   %rax,%rax
jne    1171 <main+0x21>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2e78(%rip),%r14
mov    (%r14),%ebp
mov    (%rax),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    (%r14),%edi
lea    0xe64(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
%struct.passwd = type { i8* }
@STDOUT_FILENO = global i32 0
@.str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @getuid()
%2 = tail call %struct.passwd* @getpwuid(i32 %1)
%3 = icmp eq %struct.passwd* %2, null
br i1 %3, label %13, label %4
4: ; preds = %0
%5 = load i32, i32* @STDOUT_FILENO
%6 = getelementptr inbounds %struct.passwd, %struct.passwd* %2, i64 0, i32 0
%7 = load i8*, i8** %6
%8 = tail call i32 @strlen(i8* %7)
%9 = tail call i32 @write(i32 %5, i8* %7, i32 %8)
%10 = load i32, i32* @STDOUT_FILENO
%11 = tail call i32 @write(i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %0
%14 = tail call i32 @exit(i32 1)
unreachable
}