#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*/ perror(int /*<<< orphan*/);
int /*<<< orphan*/ show_info(struct utmp *);
int /*<<< orphan*/ utmp_close();
struct utmp *utmp_next();
int utmp_open(int /*<<< orphan*/);
int main(int argc, char **argv) {
  struct utmp *utmpf;
  if ((utmp_open(UTMP_FILE)) == -1)
    perror(UTMP_FILE);
  while ((utmpf = utmp_next()) != NULL)
    show_info(utmpf);
  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    0x2e83(%rip),%rax
mov    (%rax),%edi
call   1040 <utmp_open@plt>
cmp    $0xffffffff,%eax
jne    118b <main+0x3b>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
call   1070 <perror@plt>
jmp    1190 <main+0x40>
mov    $0x0,%al
call   1060 <utmp_next@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11b3 <main+0x63>
mov    -0x18(%rbp),%rdi
call   1030 <show_info@plt>
jmp    1190 <main+0x40>
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    0x2e98(%rip),%rbx
mov    (%rbx),%edi
call   1040 <utmp_open@plt>
cmp    $0xffffffff,%eax
jne    1178 <main+0x28>
mov    (%rbx),%edi
call   1070 <perror@plt>
jmp    1178 <main+0x28>
nopl   (%rax)
mov    %rax,%rdi
call   1030 <show_info@plt>
xor    %eax,%eax
call   1060 <utmp_next@plt>
test   %rax,%rax
jne    1170 <main+0x20>
xor    %eax,%eax
call   1050 <utmp_close@plt>
xor    %eax,%eax
pop    %rbx
ret

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 %13
10: ; preds = %2
%11 = load i32, i32* @UTMP_FILE
%12 = call i32 @perror(i32 %11)
br label %13
13: ; preds = %10, %2
br label %14
14: ; preds = %17, %13
%15 = call %struct.utmp* (...) @utmp_next()
store %struct.utmp* %15, %struct.utmp** %6
%16 = icmp ne %struct.utmp* %15, null
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load %struct.utmp*, %struct.utmp** %6
%19 = call i32 @show_info(%struct.utmp* %18)
br label %14
20: ; preds = %14
%21 = 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 %6, label %9
6: ; preds = %2
%7 = load i32, i32* @UTMP_FILE
%8 = tail call i32 @perror(i32 %7)
br label %9
9: ; preds = %6, %2
%10 = tail call %struct.utmp* (...) @utmp_next()
%11 = icmp eq %struct.utmp* %10, null
br i1 %11, label %17, label %12
12: ; preds = %9, %12
%13 = phi %struct.utmp* [ %15, %12 ], [ %10, %9 ]
%14 = tail call i32 @show_info(%struct.utmp* %13)
%15 = tail call %struct.utmp* (...) @utmp_next()
%16 = icmp eq %struct.utmp* %15, null
br i1 %16, label %17, label %12
17: ; preds = %12, %9
%18 = tail call i32 (...) @utmp_close()
ret i32 0
}