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

/* Variables and functions */
int /*<<< orphan*/ endpwent();
struct passwd *getpwent();
int /*<<< orphan*/ printf(char *, char *, long, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct passwd *pwd;
  while ((pwd = getpwent()) != NULL) {
    printf("%-15s %-5ld %-15s\n", pwd->pw_name, (long)pwd->pw_uid,
           pwd->pw_shell);
  }
  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)
mov    $0x0,%al
call   1040 <getpwent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1182 <main+0x52>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%ecx
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
jmp    1146 <main+0x16>
mov    $0x0,%al
call   1050 <endpwent@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <getpwent@plt>
test   %rax,%rax
je     116e <main+0x3e>
lea    0xebc(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rax),%rsi
mov    0x10(%rax),%rdx
mov    0x8(%rax),%ecx
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getpwent@plt>
test   %rax,%rax
jne    1150 <main+0x20>
xor    %eax,%eax
call   1050 <endpwent@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.passwd = type { i8*, i32, i64 }
@.str = [19 x i8] c"%-15s %-5ld %-15s\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 %21
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 2
%16 = load i64, i64* %15
%17 = load %struct.passwd*, %struct.passwd** %6
%18 = getelementptr inbounds %struct.passwd, %struct.passwd* %17, i32 0, i32 1
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %13, i64 %16, i32 %19)
br label %7
21: ; preds = %7
%22 = call i32 (...) @endpwent()
ret i32 0
}

LLVM IR (-O2):
%struct.passwd = type { i8*, i32, i64 }
@.str = [19 x i8] c"%-15s %-5ld %-15s\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 %16, label %5
5: ; preds = %2, %5
%6 = phi %struct.passwd* [ %14, %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 2
%10 = load i64, i64* %9
%11 = getelementptr inbounds %struct.passwd, %struct.passwd* %6, i64 0, i32 1
%12 = load i32, i32* %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %8, i64 %10, i32 %12)
%14 = tail call %struct.passwd* (...) @getpwent()
%15 = icmp eq %struct.passwd* %14, null
br i1 %15, label %16, label %5
16: ; preds = %5, %2
%17 = tail call i32 (...) @endpwent()
ret i32 0
}