#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;
  char *pw_passwd;
  int pw_uid;
  int pw_gid;
  char *pw_gecos;
  char *pw_dir;
  char *pw_shell;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
struct passwd *getpwnam(char const *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, const char *argv[]) {
  struct passwd *ptr;
  if (argc != 2) {
    printf("wrong argument\n");
    exit(-1);
  }
  if ((ptr = getpwnam(argv[1])) != NULL) {
    printf("name = %s\tpasswd = %s\tuid = %d, gid = %d\n", ptr->pw_name,
           ptr->pw_passwd, ptr->pw_uid, ptr->pw_gid);
    printf("comment = %s\tdir = %s\tshell = %s\n", ptr->pw_gecos, ptr->pw_dir,
           ptr->pw_shell);
  } else {
    printf("there is no username %s", argv[1]);
    exit(-1);
  }
  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)
cmpl   $0x2,-0x8(%rbp)
je     1168 <main+0x38>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11da <main+0xaa>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%r8d
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%rcx
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fa <main+0xca>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    119d <main+0x5d>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1050 <getpwnam@plt>
test   %rax,%rax
je     11b3 <main+0x73>
mov    %rax,%rbx
mov    (%rax),%rsi
mov    0x8(%rax),%rdx
mov    0x10(%rax),%ecx
mov    0x14(%rax),%r8d
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%rsi
mov    0x20(%rbx),%rdx
mov    0x28(%rbx),%rcx
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    0x8(%r14),%rsi
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.passwd = type { i8*, i8*, i32, i32, i8*, i8*, i8* }
@.str = [16 x i8] c"wrong argument\0A\00"
@.str.1 = [42 x i8] c"name = %s\09passwd = %s\09uid = %d, gid = %d\0A\00"
@.str.2 = [34 x i8] c"comment = %s\09dir = %s\09shell = %s\0A\00"
@.str.3 = [24 x i8] c"there is no username %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 -1)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call %struct.passwd* @getpwnam(i8* %15)
store %struct.passwd* %16, %struct.passwd** %6
%17 = icmp ne %struct.passwd* %16, null
br i1 %17, label %18, label %42
18: ; preds = %12
%19 = load %struct.passwd*, %struct.passwd** %6
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %19, i32 0, i32 0
%21 = load i8*, i8** %20
%22 = load %struct.passwd*, %struct.passwd** %6
%23 = getelementptr inbounds %struct.passwd, %struct.passwd* %22, i32 0, i32 1
%24 = load i8*, i8** %23
%25 = load %struct.passwd*, %struct.passwd** %6
%26 = getelementptr inbounds %struct.passwd, %struct.passwd* %25, i32 0, i32 2
%27 = load i32, i32* %26
%28 = load %struct.passwd*, %struct.passwd** %6
%29 = getelementptr inbounds %struct.passwd, %struct.passwd* %28, i32 0, i32 3
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %24, i32 %27, i32 %30)
%32 = load %struct.passwd*, %struct.passwd** %6
%33 = getelementptr inbounds %struct.passwd, %struct.passwd* %32, i32 0, i32 4
%34 = load i8*, i8** %33
%35 = load %struct.passwd*, %struct.passwd** %6
%36 = getelementptr inbounds %struct.passwd, %struct.passwd* %35, i32 0, i32 5
%37 = load i8*, i8** %36
%38 = load %struct.passwd*, %struct.passwd** %6
%39 = getelementptr inbounds %struct.passwd, %struct.passwd* %38, i32 0, i32 6
%40 = load i8*, i8** %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* %37, i8* %40)
br label %48
42: ; preds = %12
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %45)
%47 = call i32 @exit(i32 -1)
unreachable
48: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i8*, i32, i32, i8*, i8*, i8* }
@.str.1 = [42 x i8] c"name = %s\09passwd = %s\09uid = %d, gid = %d\0A\00"
@.str.2 = [34 x i8] c"comment = %s\09dir = %s\09shell = %s\0A\00"
@.str.3 = [24 x i8] c"there is no username %s\00"
@str = [15 x i8] c"wrong argument\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 -1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call %struct.passwd* @getpwnam(i8* %9)
%11 = icmp eq %struct.passwd* %10, null
br i1 %11, label %29, label %12
12: ; preds = %7
%13 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i64 0, i32 0
%14 = load i8*, i8** %13
%15 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i64 0, i32 1
%16 = load i8*, i8** %15
%17 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i64 0, i32 2
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i64 0, i32 3
%20 = load i32, i32* %19
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %16, i32 %18, i32 %20)
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i64 0, i32 4
%23 = load i8*, i8** %22
%24 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i64 0, i32 5
%25 = load i8*, i8** %24
%26 = getelementptr inbounds %struct.passwd, %struct.passwd* %10, i64 0, i32 6
%27 = load i8*, i8** %26
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %23, i8* %25, i8* %27)
ret i32 0
29: ; preds = %7
%30 = load i8*, i8** %8
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %30)
%32 = tail call i32 @exit(i32 -1)
unreachable
}