#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();
struct passwd *getpwent();
struct passwd *getpwnam(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ setpwent();
int main(int argc, char *argv[]) {
  struct passwd *user;
  setpwent();
  while ((user = getpwent()) != NULL) {
    printf("%s\n", user->pw_name);
  }
  endpwent();
  user = getpwnam("linuxmin");
  printf("name:%s,passwd:%s,uid:%d,gid:%d,userinfo:%s,home:%s,shell:%s\n",
         user->pw_name, user->pw_passwd, user->pw_uid, user->pw_gid,
         user->pw_gecos, user->pw_dir, user->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)
mov    $0x0,%al
call   1050 <setpwent@plt>
mov    $0x0,%al
call   1060 <getpwent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     119c <main+0x4c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116d <main+0x1d>
mov    $0x0,%al
call   1070 <endpwent@plt>
lea    0xe56(%rip),%rdi
call   1040 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
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    0xe19(%rip),%rdi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <setpwent@plt>
xor    %eax,%eax
call   1060 <getpwent@plt>
test   %rax,%rax
je     1189 <main+0x39>
lea    0xed4(%rip),%rbx
nop
mov    (%rax),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <getpwent@plt>
test   %rax,%rax
jne    1170 <main+0x20>
xor    %eax,%eax
call   1070 <endpwent@plt>
lea    0xe69(%rip),%rdi
call   1040 <getpwnam@plt>
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    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.passwd = type { i8*, i8*, i32, i32, i8*, i8*, i8* }
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [9 x i8] c"linuxmin\00"
@.str.2 = [62 x i8] c"name:%s,passwd:%s,uid:%d,gid:%d,userinfo:%s,home:%s,shell:%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 = call i32 (...) @setpwent()
br label %8
8: ; preds = %11, %2
%9 = call %struct.passwd* (...) @getpwent()
store %struct.passwd* %9, %struct.passwd** %6
%10 = icmp ne %struct.passwd* %9, null
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = load %struct.passwd*, %struct.passwd** %6
%13 = getelementptr inbounds %struct.passwd, %struct.passwd* %12, i32 0, i32 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %8
16: ; preds = %8
%17 = call i32 (...) @endpwent()
%18 = call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store %struct.passwd* %18, %struct.passwd** %6
%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 = load %struct.passwd*, %struct.passwd** %6
%32 = getelementptr inbounds %struct.passwd, %struct.passwd* %31, i32 0, i32 4
%33 = load i8*, i8** %32
%34 = load %struct.passwd*, %struct.passwd** %6
%35 = getelementptr inbounds %struct.passwd, %struct.passwd* %34, i32 0, i32 5
%36 = load i8*, i8** %35
%37 = load %struct.passwd*, %struct.passwd** %6
%38 = getelementptr inbounds %struct.passwd, %struct.passwd* %37, i32 0, i32 6
%39 = load i8*, i8** %38
%40 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i8* %21, i8* %24, i32 %27, i32 %30, i8* %33, i8* %36, i8* %39)
ret i32 0
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i8*, i32, i32, i8*, i8*, i8* }
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [9 x i8] c"linuxmin\00"
@.str.2 = [62 x i8] c"name:%s,passwd:%s,uid:%d,gid:%d,userinfo:%s,home:%s,shell:%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @setpwent()
%4 = tail call %struct.passwd* (...) @getpwent()
%5 = icmp eq %struct.passwd* %4, null
br i1 %5, label %13, label %6
6: ; preds = %2, %6
%7 = phi %struct.passwd* [ %11, %6 ], [ %4, %2 ]
%8 = getelementptr inbounds %struct.passwd, %struct.passwd* %7, i64 0, i32 0
%9 = load i8*, i8** %8
%10 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call %struct.passwd* (...) @getpwent()
%12 = icmp eq %struct.passwd* %11, null
br i1 %12, label %13, label %6
13: ; preds = %6, %2
%14 = tail call i32 (...) @endpwent()
%15 = tail call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds %struct.passwd, %struct.passwd* %15, i64 0, i32 0
%17 = load i8*, i8** %16
%18 = getelementptr inbounds %struct.passwd, %struct.passwd* %15, i64 0, i32 1
%19 = load i8*, i8** %18
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %15, i64 0, i32 2
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %15, i64 0, i32 3
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.passwd, %struct.passwd* %15, i64 0, i32 4
%25 = load i8*, i8** %24
%26 = getelementptr inbounds %struct.passwd, %struct.passwd* %15, i64 0, i32 5
%27 = load i8*, i8** %26
%28 = getelementptr inbounds %struct.passwd, %struct.passwd* %15, i64 0, i32 6
%29 = load i8*, i8** %28
%30 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i8* %17, i8* %19, i32 %21, i32 %23, i8* %25, i8* %27, i8* %29)
ret i32 0
}