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

/* Variables and functions */
int /*<<< orphan*/ UTMP_FILE;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(int /*<<< orphan*/);
int /*<<< orphan*/ show_info(struct utmp *);
int /*<<< orphan*/ utmp_close();
int utmp_open(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct utmp *utbufp, *utmp_next();
  if (utmp_open(UTMP_FILE) == -1) {
    perror(UTMP_FILE);
    exit(1);
  }
  while ((utbufp = utmp_next()) != ((struct utmp *)NULL))
    show_info(utbufp);
  utmp_close();
  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    0x2e73(%rip),%rax
mov    (%rax),%edi
call   1040 <utmp_open@plt>
cmp    $0xffffffff,%eax
jne    11a5 <main+0x45>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11aa <main+0x4a>
mov    $0x0,%al
call   1060 <utmp_next@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11cd <main+0x6d>
mov    -0x18(%rbp),%rdi
call   1030 <show_info@plt>
jmp    11aa <main+0x4a>
mov    $0x0,%al
call   1050 <utmp_close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e88(%rip),%rbx
mov    (%rbx),%edi
call   1040 <utmp_open@plt>
cmp    $0xffffffff,%eax
je     11a1 <main+0x41>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <utmp_next@plt>
test   %rax,%rax
je     1196 <main+0x36>
mov    %rax,%rdi
call   1030 <show_info@plt>
jmp    1180 <main+0x20>
xor    %eax,%eax
call   1050 <utmp_close@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    (%rbx),%edi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.utmp = type { i32 }
@UTMP_FILE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.utmp*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @UTMP_FILE
%8 = call i32 @utmp_open(i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @UTMP_FILE
%12 = call i32 @perror(i32 %11)
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
br label %15
15: ; preds = %18, %14
%16 = call %struct.utmp* (...) @utmp_next()
store %struct.utmp* %16, %struct.utmp** %6
%17 = icmp ne %struct.utmp* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load %struct.utmp*, %struct.utmp** %6
%20 = call i32 @show_info(%struct.utmp* %19)
br label %15
21: ; preds = %15
%22 = call i32 (...) @utmp_close()
ret i32 0
}

LLVM IR (-O2):
%struct.utmp = type { i32 }
@UTMP_FILE = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @UTMP_FILE
%4 = tail call i32 @utmp_open(i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call %struct.utmp* (...) @utmp_next()
%8 = icmp eq %struct.utmp* %7, null
br i1 %8, label %18, label %13
9: ; preds = %2
%10 = load i32, i32* @UTMP_FILE
%11 = tail call i32 @perror(i32 %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %6, %13
%14 = phi %struct.utmp* [ %16, %13 ], [ %7, %6 ]
%15 = tail call i32 @show_info(%struct.utmp* %14)
%16 = tail call %struct.utmp* (...) @utmp_next()
%17 = icmp eq %struct.utmp* %16, null
br i1 %17, label %18, label %13
18: ; preds = %13, %6
%19 = tail call i32 (...) @utmp_close()
ret i32 0
}