#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*/ EXIT_FAILURE;
int /*<<< orphan*/ UTMP_FILE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ show_info(struct utmp *);
int /*<<< orphan*/ utmp_close();
struct utmp *utmp_next();
int utmpopen(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct utmp *utbufp;
  if (utmpopen(UTMP_FILE) == -1) {
    perror("open UTMP_FILE failed:");
    exit(EXIT_FAILURE);
  }
  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   1080 <utmpopen@plt>
cmp    $0xffffffff,%eax
jne    11a7 <main+0x47>
lea    0xe6c(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    11ac <main+0x4c>
mov    $0x0,%al
call   1050 <utmp_next@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11cf <main+0x6f>
mov    -0x18(%rbp),%rdi
call   1030 <show_info@plt>
jmp    11ac <main+0x4c>
mov    $0x0,%al
call   1040 <utmp_close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
call   1080 <utmpopen@plt>
cmp    $0xffffffff,%eax
je     11a1 <main+0x41>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <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   1040 <utmp_close@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe58(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.utmp = type { i32 }
@UTMP_FILE = global i32 0
@.str = [23 x i8] c"open UTMP_FILE failed:\00"
@EXIT_FAILURE = 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 @utmpopen(i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
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
@.str = [23 x i8] c"open UTMP_FILE failed:\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @UTMP_FILE
%4 = tail call i32 @utmpopen(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 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
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
}