#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 */
struct passwd *getpwnam(char const *);
int /*<<< orphan*/ printf(char *, char const *, ...);
int main(int argc, const char *argv[]) {
  struct passwd *pwd;
  char *h;
  pwd = getpwnam(argv[1]);
  if (pwd == NULL)
    printf("search name: %s, pwd NULL\n", argv[1]);
  else {
    h = pwd->pw_name;
    printf("search name: %s, user name: %s\n", argv[1], h);
  }
  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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116d <main+0x4d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1192 <main+0x72>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1040 <getpwnam@plt>
test   %rax,%rax
je     1149 <main+0x29>
mov    (%rax),%rdx
mov    0x8(%rbx),%rsi
lea    0xedb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    115b <main+0x3b>
mov    0x8(%rbx),%rsi
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.passwd = type { i8* }
@.str = [27 x i8] c"search name: %s, pwd NULL\0A\00"
@.str.1 = [32 x i8] c"search name: %s, user name: %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 i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call %struct.passwd* @getpwnam(i8* %10)
store %struct.passwd* %11, %struct.passwd** %6
%12 = load %struct.passwd*, %struct.passwd** %6
%13 = icmp eq %struct.passwd* %12, null
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %28
19: ; preds = %2
%20 = load %struct.passwd*, %struct.passwd** %6
%21 = getelementptr inbounds %struct.passwd, %struct.passwd* %20, i32 0, i32 0
%22 = load i8*, i8** %21
store i8* %22, i8** %7
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = load i8*, i8** %7
%27 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %26)
br label %28
28: ; preds = %19, %14
ret i32 0
}

LLVM IR (-O2):
%struct.passwd = type { i8* }
@.str = [27 x i8] c"search name: %s, pwd NULL\0A\00"
@.str.1 = [32 x i8] c"search name: %s, user name: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call %struct.passwd* @getpwnam(i8* %4)
%6 = icmp eq %struct.passwd* %5, null
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %15
10: ; preds = %2
%11 = getelementptr inbounds %struct.passwd, %struct.passwd* %5, i64 0, i32 0
%12 = load i8*, i8** %11
%13 = load i8*, i8** %3
%14 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %12)
br label %15
15: ; preds = %10, %7
ret i32 0
}