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

/* Variables and functions */
int /*<<< orphan*/ endspent();
struct spwd *getspnam(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  struct spwd *sp = NULL;
  sp = getspnam(argv[1] ? argv[1] : "lesliezhai");
  if (sp) {
    printf("%s\n", sp->sp_pwdp);
  } else {
    printf("ERROR: user does not exists\n");
  }
  endspent();
  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)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     116e <main+0x3e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    117e <main+0x4e>
lea    0xe8b(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    117e <main+0x4e>
mov    -0x20(%rbp),%rdi
call   1050 <getspnam@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b0 <main+0x80>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11be <main+0x8e>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <endspent@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x8(%rsi),%rax
test   %rax,%rax
lea    0xec1(%rip),%rdi
cmovne %rax,%rdi
call   1050 <getspnam@plt>
test   %rax,%rax
je     1152 <main+0x22>
mov    (%rax),%rdi
jmp    1159 <main+0x29>
lea    0xeb2(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <endspent@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.spwd = type { i8* }
@.str = [11 x i8] c"lesliezhai\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [29 x i8] c"ERROR: user does not exists\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.spwd*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.spwd* null, %struct.spwd** %6
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
br label %16
15: ; preds = %2
br label %16
16: ; preds = %15, %11
%17 = phi i8* [ %14, %11 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %15 ]
%18 = call %struct.spwd* @getspnam(i8* %17)
store %struct.spwd* %18, %struct.spwd** %6
%19 = load %struct.spwd*, %struct.spwd** %6
%20 = icmp ne %struct.spwd* %19, null
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load %struct.spwd*, %struct.spwd** %6
%23 = getelementptr inbounds %struct.spwd, %struct.spwd* %22, i32 0, i32 0
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %28
26: ; preds = %16
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %21
%29 = call i32 (...) @endspent()
ret i32 0
}

LLVM IR (-O2):
%struct.spwd = type { i8* }
@.str = [11 x i8] c"lesliezhai\00"
@str = [28 x i8] c"ERROR: user does not exists\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
%6 = select i1 %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %4
%7 = tail call %struct.spwd* @getspnam(i8* %6)
%8 = icmp eq %struct.spwd* %7, null
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = getelementptr inbounds %struct.spwd, %struct.spwd* %7, i64 0, i32 0
%11 = load i8*, i8** %10
br label %12
12: ; preds = %2, %9
%13 = phi i8* [ %11, %9 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0), %2 ]
%14 = tail call i32 @puts(i8* dereferenceable(1) %13)
%15 = tail call i32 (...) @endspent()
ret i32 0
}