#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 */
struct passwd *getpwnam(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  struct passwd *pw;
  int i;
  if (argc < 2)
    pw = getpwnam("root");
  else
    pw = getpwnam(argv[1]);
  if (pw == NULL) {
    printf("Not found\n");
    return -1;
  }
  printf("user name=%s,user pw=%s,user id=%d"
         " group id=%d, user info=%s, home dir=%s, sell program=%s\n",
         pw->pw_name, pw->pw_passwd, pw->pw_uid, pw->pw_gid, pw->pw_gecos,
         pw->pw_dir, pw->pw_shell);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1155 <main+0x35>
lea    0xeb9(%rip),%rdi
call   1040 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
jmp    1166 <main+0x46>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118b <main+0x6b>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11df <main+0xbf>
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
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%r9
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%r10
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%rax
lea    0xe48(%rip),%rdi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jge    1143 <main+0x13>
lea    0xebf(%rip),%rdi
jmp    1147 <main+0x17>
mov    0x8(%rsi),%rdi
call   1050 <getpwnam@plt>
test   %rax,%rax
je     117d <main+0x4d>
mov    (%rax),%rsi
mov    0x8(%rax),%rdx
mov    0x10(%rax),%ecx
mov    0x14(%rax),%r8d
mov    0x18(%rax),%r9
movups 0x20(%rax),%xmm0
movups %xmm0,(%rsp)
lea    0xe93(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    118e <main+0x5e>
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.passwd = type { i8*, i8*, i32, i32, i8*, i8*, i8* }
@.str = [5 x i8] c"root\00"
@.str.1 = [11 x i8] c"Not found\0A\00"
@.str.2 = [92 x i8] c"user name=%s,user pw=%s,user id=%d group id=%d, user info=%s, home dir=%s, sell program=%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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store %struct.passwd* %11, %struct.passwd** %6
br label %17
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
br label %17
17: ; preds = %12, %10
%18 = load %struct.passwd*, %struct.passwd** %6
%19 = icmp eq %struct.passwd* %18, null
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %45
22: ; preds = %17
%23 = load %struct.passwd*, %struct.passwd** %6
%24 = getelementptr inbounds %struct.passwd, %struct.passwd* %23, i32 0, i32 0
%25 = load i8*, i8** %24
%26 = load %struct.passwd*, %struct.passwd** %6
%27 = getelementptr inbounds %struct.passwd, %struct.passwd* %26, i32 0, i32 1
%28 = load i8*, i8** %27
%29 = load %struct.passwd*, %struct.passwd** %6
%30 = getelementptr inbounds %struct.passwd, %struct.passwd* %29, i32 0, i32 2
%31 = load i32, i32* %30
%32 = load %struct.passwd*, %struct.passwd** %6
%33 = getelementptr inbounds %struct.passwd, %struct.passwd* %32, i32 0, i32 3
%34 = load i32, i32* %33
%35 = load %struct.passwd*, %struct.passwd** %6
%36 = getelementptr inbounds %struct.passwd, %struct.passwd* %35, i32 0, i32 4
%37 = load i8*, i8** %36
%38 = load %struct.passwd*, %struct.passwd** %6
%39 = getelementptr inbounds %struct.passwd, %struct.passwd* %38, i32 0, i32 5
%40 = load i8*, i8** %39
%41 = load %struct.passwd*, %struct.passwd** %6
%42 = getelementptr inbounds %struct.passwd, %struct.passwd* %41, i32 0, i32 6
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.2, i64 0, i64 0), i8* %25, i8* %28, i32 %31, i32 %34, i8* %37, i8* %40, i8* %43)
store i32 0, i32* %3
br label %45
45: ; preds = %22, %20
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i8*, i32, i32, i8*, i8*, i8* }
@.str = [5 x i8] c"root\00"
@.str.2 = [92 x i8] c"user name=%s,user pw=%s,user id=%d group id=%d, user info=%s, home dir=%s, sell program=%s\0A\00"
@str = [10 x i8] c"Not found\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
br label %7
7: ; preds = %2, %4
%8 = phi i8* [ %6, %4 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %2 ]
%9 = tail call %struct.passwd* @getpwnam(i8* %8)
%10 = icmp eq %struct.passwd* %9, null
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %29
13: ; preds = %7
%14 = getelementptr inbounds %struct.passwd, %struct.passwd* %9, i64 0, i32 0
%15 = load i8*, i8** %14
%16 = getelementptr inbounds %struct.passwd, %struct.passwd* %9, i64 0, i32 1
%17 = load i8*, i8** %16
%18 = getelementptr inbounds %struct.passwd, %struct.passwd* %9, i64 0, i32 2
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %9, i64 0, i32 3
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %9, i64 0, i32 4
%23 = load i8*, i8** %22
%24 = getelementptr inbounds %struct.passwd, %struct.passwd* %9, i64 0, i32 5
%25 = load i8*, i8** %24
%26 = getelementptr inbounds %struct.passwd, %struct.passwd* %9, i64 0, i32 6
%27 = load i8*, i8** %26
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([92 x i8], [92 x i8]* @.str.2, i64 0, i64 0), i8* %15, i8* %17, i32 %19, i32 %21, i8* %23, i8* %25, i8* %27)
br label %29
29: ; preds = %13, %11
%30 = phi i32 [ -1, %11 ], [ 0, %13 ]
ret i32 %30
}