#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*/ endutent();
struct utmp *getutent();
int /*<<< orphan*/ print_entry(int /*<<< orphan*/, struct utmp *);
int /*<<< orphan*/ print_usage(char *);
int /*<<< orphan*/ read_from_stdin();
int /*<<< orphan*/ setutent();
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ utmpname(char *);
int main(int argc, char **argv) {
  struct utmp *current = NULL;
  if (argc >= 2) {
    if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
      print_usage(argv[0]);
      return 1;
    } else if (strcmp(argv[1], "--") == 0) {
      read_from_stdin();
      return 0;
    }
    utmpname(argv[1]);
  }
  setutent();
  while ((current = getutent())) {
    print_entry(stdout, current);
  }
  endutent();
  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)
movq   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     123f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe49(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11e4 <main+0x64>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11fc <main+0x7c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <print_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1280 <main+0x100>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdff(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    122d <main+0xad>
mov    $0x0,%al
call   1080 <read_from_stdin@plt>
movl   $0x0,-0x4(%rbp)
jmp    1280 <main+0x100>
jmp    1232 <main+0xb2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <utmpname@plt>
mov    $0x0,%al
call   1070 <setutent@plt>
mov    $0x0,%al
call   1060 <getutent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1272 <main+0xf2>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   10a0 <print_entry@plt>
jmp    1246 <main+0xc6>
mov    $0x0,%al
call   1040 <endutent@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11d3 <main+0x53>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe6a(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     120f <main+0x8f>
mov    0x8(%rbx),%rdi
lea    0xe58(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     120f <main+0x8f>
mov    0x8(%rbx),%rdi
lea    0xe4a(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     121e <main+0x9e>
mov    0x8(%rbx),%rdi
call   1030 <utmpname@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1070 <setutent@plt>
xor    %eax,%eax
call   1060 <getutent@plt>
test   %rax,%rax
je     1206 <main+0x86>
mov    0x2df1(%rip),%rbx
nop
mov    (%rbx),%edi
mov    %rax,%rsi
call   10a0 <print_entry@plt>
xor    %eax,%eax
call   1060 <getutent@plt>
test   %rax,%rax
jne    11f0 <main+0x70>
xor    %eax,%eax
call   1040 <endutent@plt>
jmp    1227 <main+0xa7>
mov    (%rbx),%rdi
call   1090 <print_usage@plt>
mov    $0x1,%ebp
jmp    1227 <main+0xa7>
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <read_from_stdin@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.utmp = type { i32 }
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [3 x i8] c"--\00"
@stdout = 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
store %struct.utmp* null, %struct.utmp** %6
%7 = load i32, i32* %4
%8 = icmp sge i32 %7, 2
br i1 %8, label %9, label %40
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %9
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %15, %9
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 @print_usage(i8* %24)
store i32 1, i32* %3
br label %51
26: ; preds = %15
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = call i32 (...) @read_from_stdin()
store i32 0, i32* %3
br label %51
34: ; preds = %26
br label %35
35: ; preds = %34
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @utmpname(i8* %38)
br label %40
40: ; preds = %35, %2
%41 = call i32 (...) @setutent()
br label %42
42: ; preds = %45, %40
%43 = call %struct.utmp* (...) @getutent()
store %struct.utmp* %43, %struct.utmp** %6
%44 = icmp ne %struct.utmp* %43, null
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load i32, i32* @stdout
%47 = load %struct.utmp*, %struct.utmp** %6
%48 = call i32 @print_entry(i32 %46, %struct.utmp* %47)
br label %42
49: ; preds = %42
%50 = call i32 (...) @endutent()
store i32 0, i32* %3
br label %51
51: ; preds = %49, %32, %21
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
%struct.utmp = type { i32 }
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [3 x i8] c"--\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %25
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = load i8*, i8** %5
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9, %4
%14 = load i8*, i8** %1
%15 = tail call i32 @print_usage(i8* %14)
br label %37
16: ; preds = %9
%17 = load i8*, i8** %5
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = tail call i32 (...) @read_from_stdin()
br label %37
22: ; preds = %16
%23 = load i8*, i8** %5
%24 = tail call i32 @utmpname(i8* %23)
br label %25
25: ; preds = %22, %2
%26 = tail call i32 (...) @setutent()
%27 = tail call %struct.utmp* (...) @getutent()
%28 = icmp eq %struct.utmp* %27, null
br i1 %28, label %35, label %29
29: ; preds = %25, %29
%30 = phi %struct.utmp* [ %33, %29 ], [ %27, %25 ]
%31 = load i32, i32* @stdout
%32 = tail call i32 @print_entry(i32 %31, %struct.utmp* %30)
%33 = tail call %struct.utmp* (...) @getutent()
%34 = icmp eq %struct.utmp* %33, null
br i1 %34, label %35, label %29
35: ; preds = %29, %25
%36 = tail call i32 (...) @endutent()
br label %37
37: ; preds = %35, %20, %13
%38 = phi i32 [ 1, %13 ], [ 0, %20 ], [ 0, %35 ]
ret i32 %38
}