#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*/ endpwent();
int /*<<< orphan*/ exit(int);
struct passwd *getpwent();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setpwent();
scalar_t__ strcmp(char const *, char *);
int main(int argc, const char *argv[]) {
  struct passwd *ptr;
  if (argc != 2) {
    printf("wrong argument\n");
    exit(-1);
  }
  setpwent();
  while ((ptr = getpwent()) != NULL) {
    if (strcmp(argv[1], ptr->pw_name) == 0) {
      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);
      break;
    }
  }
  endpwent();
  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     1198 <main+0x38>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    $0x0,%al
call   1050 <setpwent@plt>
mov    $0x0,%al
call   1060 <getpwent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     122e <main+0xce>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1229 <main+0xc9>
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    0xe19(%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    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122e <main+0xce>
jmp    119f <main+0x3f>
mov    $0x0,%al
call   1070 <endpwent@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    11f7 <main+0x87>
mov    %rsi,%r14
xor    %eax,%eax
call   1060 <setpwent@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1070 <getpwent@plt>
test   %rax,%rax
je     11e6 <main+0x76>
mov    %rax,%rbx
mov    0x8(%r14),%rdi
mov    (%rax),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1190 <main+0x20>
mov    (%rbx),%rsi
mov    0x8(%rbx),%rdx
mov    0x10(%rbx),%ecx
mov    0x14(%rbx),%r8d
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%rsi
mov    0x20(%rbx),%rdx
mov    0x28(%rbx),%rcx
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1080 <endpwent@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1090 <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"
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 = call i32 (...) @setpwent()
br label %14
14: ; preds = %50, %12
%15 = call %struct.passwd* (...) @getpwent()
store %struct.passwd* %15, %struct.passwd** %6
%16 = icmp ne %struct.passwd* %15, null
br i1 %16, label %17, label %51
17: ; preds = %14
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = load %struct.passwd*, %struct.passwd** %6
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %21, i32 0, i32 0
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %20, i8* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %50
26: ; preds = %17
%27 = load %struct.passwd*, %struct.passwd** %6
%28 = getelementptr inbounds %struct.passwd, %struct.passwd* %27, i32 0, i32 0
%29 = load i8*, i8** %28
%30 = load %struct.passwd*, %struct.passwd** %6
%31 = getelementptr inbounds %struct.passwd, %struct.passwd* %30, i32 0, i32 1
%32 = load i8*, i8** %31
%33 = load %struct.passwd*, %struct.passwd** %6
%34 = getelementptr inbounds %struct.passwd, %struct.passwd* %33, i32 0, i32 2
%35 = load i32, i32* %34
%36 = load %struct.passwd*, %struct.passwd** %6
%37 = getelementptr inbounds %struct.passwd, %struct.passwd* %36, i32 0, i32 3
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %32, i32 %35, i32 %38)
%40 = load %struct.passwd*, %struct.passwd** %6
%41 = getelementptr inbounds %struct.passwd, %struct.passwd* %40, i32 0, i32 4
%42 = load i8*, i8** %41
%43 = load %struct.passwd*, %struct.passwd** %6
%44 = getelementptr inbounds %struct.passwd, %struct.passwd* %43, i32 0, i32 5
%45 = load i8*, i8** %44
%46 = load %struct.passwd*, %struct.passwd** %6
%47 = getelementptr inbounds %struct.passwd, %struct.passwd* %46, i32 0, i32 6
%48 = load i8*, i8** %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %42, i8* %45, i8* %48)
br label %51
50: ; preds = %17
br label %14
51: ; preds = %26, %14
%52 = call i32 (...) @endpwent()
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 = [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 = tail call i32 (...) @setpwent()
%9 = getelementptr inbounds i8*, i8** %1, i64 1
br label %10
10: ; preds = %13, %7
%11 = tail call %struct.passwd* (...) @getpwent()
%12 = icmp eq %struct.passwd* %11, null
br i1 %12, label %36, label %13
13: ; preds = %10
%14 = load i8*, i8** %9
%15 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 0
%16 = load i8*, i8** %15
%17 = tail call i64 @strcmp(i8* %14, i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %10
19: ; preds = %13
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 0
%21 = load i8*, i8** %20
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 1
%23 = load i8*, i8** %22
%24 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 2
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 3
%27 = load i32, i32* %26
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %23, i32 %25, i32 %27)
%29 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 4
%30 = load i8*, i8** %29
%31 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 5
%32 = load i8*, i8** %31
%33 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 6
%34 = load i8*, i8** %33
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %30, i8* %32, i8* %34)
br label %36
36: ; preds = %10, %19
%37 = tail call i32 (...) @endpwent()
ret i32 0
}