#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 *getpwent();
int /*<<< orphan*/ printf(char *, char *, char *, int, int, char *, char *,
                          char *);
int main(int argc, char **argv) {
  struct passwd *pw;
  while ((pw = getpwent()) != NULL) {
    printf("%s:%s:%d:%d:%s:%s:%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)
mov    $0x0,%al
call   1040 <getpwent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     119b <main+0x7b>
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    0xe78(%rip),%rdi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <printf@plt>
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <getpwent@plt>
test   %rax,%rax
je     116e <main+0x4e>
lea    0xec8(%rip),%rbx
nopl   0x0(%rax,%rax,1)
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)
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getpwent@plt>
test   %rax,%rax
jne    1140 <main+0x20>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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