#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 EXIT_SUCCESS;
int /*<<< orphan*/ endutent();
struct utmp *getutent();
int /*<<< orphan*/ print_entry(struct utmp *);
int /*<<< orphan*/ setutent();
int /*<<< orphan*/ utmpname(char *);
int main(int argc, char *argv[]) {
  struct utmp *up;
  if (argc > 1)
    utmpname(argv[1]);
  setutent();
  while ((up = getutent()))
    print_entry(up);
  endutent();
  return EXIT_SUCCESS;
}


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)
cmpl   $0x1,-0x8(%rbp)
jle    117d <main+0x2d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <utmpname@plt>
mov    $0x0,%al
call   1060 <setutent@plt>
mov    $0x0,%al
call   1050 <getutent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11a7 <main+0x57>
mov    -0x18(%rbp),%rdi
call   1070 <print_entry@plt>
jmp    1184 <main+0x34>
mov    $0x0,%al
call   1040 <endutent@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jl     115f <main+0xf>
mov    0x8(%rsi),%rdi
call   1030 <utmpname@plt>
xor    %eax,%eax
call   1060 <setutent@plt>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getutent@plt>
test   %rax,%rax
je     1186 <main+0x36>
mov    %rax,%rdi
call   1070 <print_entry@plt>
jmp    1170 <main+0x20>
xor    %eax,%eax
call   1040 <endutent@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.utmp = type { i32 }
@EXIT_SUCCESS = 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* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @utmpname(i8* %12)
br label %14
14: ; preds = %9, %2
%15 = call i32 (...) @setutent()
br label %16
16: ; preds = %19, %14
%17 = call %struct.utmp* (...) @getutent()
store %struct.utmp* %17, %struct.utmp** %6
%18 = icmp ne %struct.utmp* %17, null
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load %struct.utmp*, %struct.utmp** %6
%21 = call i32 @print_entry(%struct.utmp* %20)
br label %16
22: ; preds = %16
%23 = call i32 (...) @endutent()
%24 = load i32, i32* @EXIT_SUCCESS
ret i32 %24
}

LLVM IR (-O2):
%struct.utmp = type { i32 }
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @utmpname(i8* %6)
br label %8
8: ; preds = %4, %2
%9 = tail call i32 (...) @setutent()
%10 = tail call %struct.utmp* (...) @getutent()
%11 = icmp eq %struct.utmp* %10, null
br i1 %11, label %17, label %12
12: ; preds = %8, %12
%13 = phi %struct.utmp* [ %15, %12 ], [ %10, %8 ]
%14 = tail call i32 @print_entry(%struct.utmp* %13)
%15 = tail call %struct.utmp* (...) @getutent()
%16 = icmp eq %struct.utmp* %15, null
br i1 %16, label %17, label %12
17: ; preds = %12, %8
%18 = tail call i32 (...) @endutent()
%19 = load i32, i32* @EXIT_SUCCESS
ret i32 %19
}