#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 /*<<< orphan*/ pw_shell;
  int /*<<< orphan*/ pw_dir;
  int /*<<< orphan*/ pw_gecos;
  scalar_t__ pw_gid;
  scalar_t__ pw_uid;
};

/* Variables and functions */
int /*<<< orphan*/ endpwent();
struct passwd *getpwent();
int /*<<< orphan*/ printf(char *, char *, char *, long, long,
                          int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int main(int argc, char **argv) {
  struct passwd *p;
  while ((p = getpwent()) != NULL)
    printf("%s:%s:%ld:%ld:%s:%s:%s\n", p->pw_name, p->pw_passwd,
           (long)p->pw_uid, (long)p->pw_gid, p->pw_gecos, p->pw_dir,
           p->pw_shell);
  endpwent();
  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     11aa <main+0x7a>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%rcx
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%r8
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%r9d
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%r10d
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%eax
lea    0xe68(%rip),%rdi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <printf@plt>
jmp    1146 <main+0x16>
mov    $0x0,%al
call   1050 <endpwent@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getpwent@plt>
test   %rax,%rax
je     1183 <main+0x53>
lea    0xeb9(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    (%rax),%rsi
mov    0x8(%rax),%rdx
mov    0x28(%rax),%rcx
mov    0x20(%rax),%r8
mov    0x18(%rax),%r9d
mov    0x14(%rax),%ebx
mov    0x10(%rax),%eax
mov    %r14,%rdi
push   %rax
push   %rbx
call   1030 <printf@plt>
add    $0x10,%rsp
xor    %eax,%eax
call   1040 <getpwent@plt>
test   %rax,%rax
jne    1150 <main+0x20>
xor    %eax,%eax
call   1050 <endpwent@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.passwd = type { i8*, i8*, i32, i32, i32, i64, i64 }
@.str = [24 x i8] c"%s:%s:%ld:%ld:%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 6
%19 = load i64, i64* %18
%20 = load %struct.passwd*, %struct.passwd** %6
%21 = getelementptr inbounds %struct.passwd, %struct.passwd* %20, i32 0, i32 5
%22 = load i64, i64* %21
%23 = load %struct.passwd*, %struct.passwd** %6
%24 = getelementptr inbounds %struct.passwd, %struct.passwd* %23, i32 0, i32 4
%25 = load i32, i32* %24
%26 = load %struct.passwd*, %struct.passwd** %6
%27 = getelementptr inbounds %struct.passwd, %struct.passwd* %26, i32 0, i32 3
%28 = load i32, i32* %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 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %16, i64 %19, i64 %22, i32 %25, i32 %28, i32 %31)
br label %7
33: ; preds = %7
%34 = call i32 (...) @endpwent()
ret i32 0
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i8*, i32, i32, i32, i64, i64 }
@.str = [24 x i8] c"%s:%s:%ld:%ld:%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 6
%12 = load i64, i64* %11
%13 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 5
%14 = load i64, i64* %13
%15 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 4
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 3
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 2
%20 = load i32, i32* %19
%21 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %10, i64 %12, i64 %14, i32 %16, i32 %18, i32 %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
%25 = tail call i32 (...) @endpwent()
ret i32 0
}