#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 {
  scalar_t__ pw_uid;
};

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
struct passwd *getpwnam(char *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  char reportString[] =
      "Testing that the user root is found with a user-id of 0...";
  struct passwd *root = getpwnam("root");
  if (root == NULL) {
    printf("%sFAILED\n", reportString);
    return EXIT_FAILURE;
  }
  if (root->pw_uid == 0)
    printf("%sPASSED\n", reportString);
  else {
    printf("%sFAILED\n", reportString);
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x3b,%edx
call   1050 <memcpy@plt>
lea    0xed9(%rip),%rdi
call   1040 <getpwnam@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1197 <main+0x67>
lea    -0x50(%rbp),%rsi
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e7 <main+0xb7>
mov    -0x58(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11ba <main+0x8a>
lea    -0x50(%rbp),%rsi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
jmp    11db <main+0xab>
lea    -0x50(%rbp),%rsi
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e7 <main+0xb7>
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movups 0xeff(%rip),%xmm0
movups %xmm0,0x2b(%rsp)
movaps 0xee8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xecc(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xee0(%rip),%rdi
call   1040 <getpwnam@plt>
test   %rax,%rax
je     118c <main+0x6c>
cmpq   $0x0,(%rax)
lea    0xeda(%rip),%rax
lea    0xec9(%rip),%rdi
cmove  %rax,%rdi
mov    0x2e5e(%rip),%rbx
cmove  0x2e4e(%rip),%rbx
jmp    119a <main+0x7a>
mov    0x2e4d(%rip),%rbx
lea    0xea6(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
mov    (%rbx),%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.passwd = type { i64 }
@__const.main.reportString = [59 x i8] c"Testing that the user root is found with a user-id of 0...\00"
@.str = [5 x i8] c"root\00"
@.str.1 = [10 x i8] c"%sFAILED\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [10 x i8] c"%sPASSED\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [59 x i8]
%7 = alloca %struct.passwd*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [59 x i8]* %6 to i8*
%9 = call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store %struct.passwd* %9, %struct.passwd** %7
%10 = load %struct.passwd*, %struct.passwd** %7
%11 = icmp eq %struct.passwd* %10, null
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = getelementptr inbounds [59 x i8], [59 x i8]* %6, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %3
br label %30
16: ; preds = %2
%17 = load %struct.passwd*, %struct.passwd** %7
%18 = getelementptr inbounds %struct.passwd, %struct.passwd* %17, i32 0, i32 0
%19 = load i64, i64* %18
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = getelementptr inbounds [59 x i8], [59 x i8]* %6, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %28
24: ; preds = %16
%25 = getelementptr inbounds [59 x i8], [59 x i8]* %6, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
store i32 %27, i32* %3
br label %30
28: ; preds = %21
%29 = load i32, i32* @EXIT_SUCCESS
store i32 %29, i32* %3
br label %30
30: ; preds = %28, %24, %12
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
%struct.passwd = type { i64 }
@__const.main.reportString = [59 x i8] c"Testing that the user root is found with a user-id of 0...\00"
@.str = [5 x i8] c"root\00"
@.str.1 = [10 x i8] c"%sFAILED\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [10 x i8] c"%sPASSED\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [59 x i8]
%4 = getelementptr inbounds [59 x i8], [59 x i8]* %3, i64 0, i64 0
%5 = tail call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq %struct.passwd* %5, null
br i1 %6, label %13, label %7
7: ; preds = %2
%8 = getelementptr inbounds %struct.passwd, %struct.passwd* %5, i64 0, i32 0
%9 = load i64, i64* %8
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0)
%12 = select i1 %10, i32* @EXIT_SUCCESS, i32* @EXIT_FAILURE
br label %13
13: ; preds = %7, %2
%14 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %2 ], [ %11, %7 ]
%15 = phi i32* [ @EXIT_FAILURE, %2 ], [ %12, %7 ]
%16 = call i32 @printf(i8* %14, i8* %4)
%17 = load i32, i32* %15
ret i32 %17
}