#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 {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ endpwent();
scalar_t__ errno;
struct passwd *getpwent();
int /*<<< orphan*/ printf(char *, scalar_t__);
int /*<<< orphan*/ setpwent();
int main(int argc, char **argv) {
  setpwent();
  for (;;) {
    errno = 0;
    struct passwd *pw = getpwent();
    if (!pw) {
      if (errno != 0)
        printf("ERRNO: %u %m\n", errno);
      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)
mov    $0x0,%al
call   1040 <setpwent@plt>
mov    0x2e7c(%rip),%rax
movq   $0x0,(%rax)
mov    $0x0,%al
call   1050 <getpwent@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ad <main+0x6d>
mov    0x2e58(%rip),%rax
cmpq   $0x0,(%rax)
je     11a8 <main+0x68>
mov    0x2e47(%rip),%rax
mov    (%rax),%rsi
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
jmp    11b2 <main+0x72>
jmp    115d <main+0x1d>
mov    $0x0,%al
call   1060 <endpwent@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <setpwent@plt>
mov    0x2e91(%rip),%rbx
nop
movq   $0x0,(%rbx)
xor    %eax,%eax
call   1050 <getpwent@plt>
test   %rax,%rax
jne    1150 <main+0x10>
mov    (%rbx),%rsi
test   %rsi,%rsi
je     1177 <main+0x37>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <endpwent@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.passwd = type { i32 }
@errno = global i64 0
@.str = [14 x i8] c"ERRNO: %u %m\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 = %19, %2
store i64 0, i64* @errno
%9 = call %struct.passwd* (...) @getpwent()
store %struct.passwd* %9, %struct.passwd** %6
%10 = load %struct.passwd*, %struct.passwd** %6
%11 = icmp ne %struct.passwd* %10, null
br i1 %11, label %19, label %12
12: ; preds = %8
%13 = load i64, i64* @errno
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i64, i64* @errno
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %16)
br label %18
18: ; preds = %15, %12
br label %20
19: ; preds = %8
br label %8
20: ; preds = %18
%21 = call i32 (...) @endpwent()
ret i32 0
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
@errno = global i64 0
@.str = [14 x i8] c"ERRNO: %u %m\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @setpwent()
br label %4
4: ; preds = %4, %2
store i64 0, i64* @errno
%5 = tail call %struct.passwd* (...) @getpwent()
%6 = icmp eq %struct.passwd* %5, null
br i1 %6, label %7, label %4
7: ; preds = %4
%8 = load i64, i64* @errno
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %8)
br label %12
12: ; preds = %10, %7
%13 = tail call i32 (...) @endpwent()
ret i32 0
}