#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ time_t;
struct TYPE_2__ {
  int /*<<< orphan*/ tv_sec;
};
struct utmpx {
  scalar_t__ ut_type;
  char *ut_user;
  char *ut_line;
  TYPE_1__ ut_tv;
};
struct tm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
scalar_t__ INIT_PROCESS;
scalar_t__ LOGIN_PROCESS;
scalar_t__ USER_PROCESS;
int /*<<< orphan*/ endutxent();
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
struct utmpx *getutxent();
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ pexit(char *);
int /*<<< orphan*/ printf(char *, char *, char *, char *);
int /*<<< orphan*/ setutxent();
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ utmpname(char *);
int main(int argc, char *argv[]) {
  if (argc > 1)
    utmpname(argv[1]);
  struct utmpx *ut;
  errno = 0;
  setutxent();
  if (errno != 0)
    pexit("setutxent");
  while ((ut = getutxent()) != NULL) {
    if (ut->ut_type == INIT_PROCESS || ut->ut_type == LOGIN_PROCESS ||
        ut->ut_type == USER_PROCESS) {
      struct tm *t = localtime((time_t *)&ut->ut_tv.tv_sec);
      char s[32];
      strftime(s, 32, "%F %T", t);
      printf("%12s %10s %20s\n", ut->ut_user, ut->ut_line, s);
    }
  }
  errno = 0;
  endutxent();
  if (errno != 0)
    pexit("endutxent");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11bd <main+0x2d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <utmpname@plt>
mov    0x2e0c(%rip),%rax
movq   $0x0,(%rax)
mov    $0x0,%al
call   1070 <setutxent@plt>
mov    0x2df7(%rip),%rax
cmpq   $0x0,(%rax)
je     11ef <main+0x5f>
lea    0xe16(%rip),%rdi
call   10b0 <pexit@plt>
jmp    11f4 <main+0x64>
mov    $0x0,%al
call   1090 <getutxent@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     129d <main+0x10d>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2dc1(%rip),%rcx
cmp    (%rcx),%rax
je     124e <main+0xbe>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2d8a(%rip),%rcx
cmp    (%rcx),%rax
je     124e <main+0xbe>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2da3(%rip),%rcx
cmp    (%rcx),%rax
jne    1298 <main+0x108>
mov    -0x18(%rbp),%rdi
add    $0x18,%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x20,%esi
lea    0xd97(%rip),%rdx
call   1080 <strftime@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rdx
lea    -0x40(%rbp),%rcx
lea    0xd7d(%rip),%rdi
call   1060 <printf@plt>
jmp    11f4 <main+0x64>
mov    0x2d2c(%rip),%rax
movq   $0x0,(%rax)
mov    $0x0,%al
call   1040 <endutxent@plt>
mov    0x2d17(%rip),%rax
cmpq   $0x0,(%rax)
je     12cf <main+0x13f>
lea    0xd56(%rip),%rdi
call   10b0 <pexit@plt>
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x2,%edi
jl     11ac <main+0x1c>
mov    0x8(%rsi),%rdi
call   1050 <utmpname@plt>
mov    0x2e1d(%rip),%rbx
movq   $0x0,(%rbx)
xor    %eax,%eax
call   1070 <setutxent@plt>
cmpq   $0x0,(%rbx)
je     11d3 <main+0x43>
lea    0xe32(%rip),%rdi
call   10b0 <pexit@plt>
xor    %eax,%eax
call   1090 <getutxent@plt>
test   %rax,%rax
jne    1214 <main+0x84>
mov    0x2dea(%rip),%rbx
movq   $0x0,(%rbx)
xor    %eax,%eax
call   1040 <endutxent@plt>
cmpq   $0x0,(%rbx)
je     1206 <main+0x76>
lea    0xe1f(%rip),%rdi
call   10b0 <pexit@plt>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    %rax,%rbx
mov    0x2dba(%rip),%rbp
mov    0x2d93(%rip),%r13
mov    0x2dbc(%rip),%r14
mov    %rsp,%r12
lea    0xdda(%rip),%r15
jmp    1286 <main+0xf6>
nopl   0x0(%rax,%rax,1)
lea    0x18(%rbx),%rdi
call   1030 <localtime@plt>
mov    %r12,%rdi
mov    $0x20,%esi
lea    0xdb2(%rip),%rdx
mov    %rax,%rcx
call   1080 <strftime@plt>
mov    0x8(%rbx),%rsi
mov    0x10(%rbx),%rdx
mov    %r15,%rdi
mov    %r12,%rcx
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <getutxent@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11df <main+0x4f>
mov    (%rbx),%rax
cmp    0x0(%rbp),%rax
je     1240 <main+0xb0>
cmp    0x0(%r13),%rax
je     1240 <main+0xb0>
cmp    (%r14),%rax
jne    1273 <main+0xe3>
jmp    1240 <main+0xb0>

LLVM IR (-O0):
%struct.utmpx = type { i64, i8*, i8*, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.tm = type { i32 }
@errno = global i64 0
@.str = [10 x i8] c"setutxent\00"
@INIT_PROCESS = global i64 0
@LOGIN_PROCESS = global i64 0
@USER_PROCESS = global i64 0
@.str.1 = [6 x i8] c"%F %T\00"
@.str.2 = [16 x i8] c"%12s %10s %20s\0A\00"
@.str.3 = [10 x i8] c"endutxent\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.utmpx*
%7 = alloca %struct.tm*
%8 = alloca [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @utmpname(i8* %14)
br label %16
16: ; preds = %11, %2
store i64 0, i64* @errno
%17 = call i32 (...) @setutxent()
%18 = load i64, i64* @errno
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @pexit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
br label %23
23: ; preds = %60, %22
%24 = call %struct.utmpx* (...) @getutxent()
store %struct.utmpx* %24, %struct.utmpx** %6
%25 = icmp ne %struct.utmpx* %24, null
br i1 %25, label %26, label %61
26: ; preds = %23
%27 = load %struct.utmpx*, %struct.utmpx** %6
%28 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %27, i32 0, i32 0
%29 = load i64, i64* %28
%30 = load i64, i64* @INIT_PROCESS
%31 = icmp eq i64 %29, %30
br i1 %31, label %44, label %32
32: ; preds = %26
%33 = load %struct.utmpx*, %struct.utmpx** %6
%34 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %33, i32 0, i32 0
%35 = load i64, i64* %34
%36 = load i64, i64* @LOGIN_PROCESS
%37 = icmp eq i64 %35, %36
br i1 %37, label %44, label %38
38: ; preds = %32
%39 = load %struct.utmpx*, %struct.utmpx** %6
%40 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %39, i32 0, i32 0
%41 = load i64, i64* %40
%42 = load i64, i64* @USER_PROCESS
%43 = icmp eq i64 %41, %42
br i1 %43, label %44, label %60
44: ; preds = %38, %32, %26
%45 = load %struct.utmpx*, %struct.utmpx** %6
%46 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %45, i32 0, i32 3
%47 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %46, i32 0, i32 0
%48 = call %struct.tm* @localtime(i32* %47)
store %struct.tm* %48, %struct.tm** %7
%49 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%50 = load %struct.tm*, %struct.tm** %7
%51 = call i32 @strftime(i8* %49, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %50)
%52 = load %struct.utmpx*, %struct.utmpx** %6
%53 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %52, i32 0, i32 1
%54 = load i8*, i8** %53
%55 = load %struct.utmpx*, %struct.utmpx** %6
%56 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %55, i32 0, i32 2
%57 = load i8*, i8** %56
%58 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%59 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %54, i8* %57, i8* %58)
br label %60
60: ; preds = %44, %38
br label %23
61: ; preds = %23
store i64 0, i64* @errno
%62 = call i32 (...) @endutxent()
%63 = load i64, i64* @errno
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = call i32 @pexit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %67
67: ; preds = %65, %61
%68 = load i32, i32* @EXIT_SUCCESS
%69 = call i32 @exit(i32 %68)
unreachable
}

LLVM IR (-O2):
%struct.utmpx = type { i64, i8*, i8*, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.tm = type { i32 }
@errno = global i64 0
@.str = [10 x i8] c"setutxent\00"
@INIT_PROCESS = global i64 0
@LOGIN_PROCESS = global i64 0
@USER_PROCESS = global i64 0
@.str.1 = [6 x i8] c"%F %T\00"
@.str.2 = [16 x i8] c"%12s %10s %20s\0A\00"
@.str.3 = [10 x i8] c"endutxent\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @utmpname(i8* %7)
br label %9
9: ; preds = %5, %2
store i64 0, i64* @errno
%10 = tail call i32 (...) @setutxent()
%11 = load i64, i64* @errno
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = tail call i32 @pexit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
%16 = call %struct.utmpx* (...) @getutxent()
%17 = icmp eq %struct.utmpx* %16, null
br i1 %17, label %44, label %18
18: ; preds = %15
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
br label %20
20: ; preds = %18, %41
%21 = phi %struct.utmpx* [ %16, %18 ], [ %42, %41 ]
%22 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %21, i64 0, i32 0
%23 = load i64, i64* %22
%24 = load i64, i64* @INIT_PROCESS
%25 = icmp eq i64 %23, %24
%26 = load i64, i64* @LOGIN_PROCESS
%27 = icmp eq i64 %23, %26
%28 = select i1 %25, i1 true, i1 %27
%29 = load i64, i64* @USER_PROCESS
%30 = icmp eq i64 %23, %29
%31 = select i1 %28, i1 true, i1 %30
br i1 %31, label %32, label %41
32: ; preds = %20
%33 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %21, i64 0, i32 3, i32 0
%34 = call %struct.tm* @localtime(i32* %33)
%35 = call i32 @strftime(i8* %19, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %34)
%36 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %21, i64 0, i32 1
%37 = load i8*, i8** %36
%38 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %21, i64 0, i32 2
%39 = load i8*, i8** %38
%40 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %37, i8* %39, i8* %19)
br label %41
41: ; preds = %20, %32
%42 = call %struct.utmpx* (...) @getutxent()
%43 = icmp eq %struct.utmpx* %42, null
br i1 %43, label %44, label %20
44: ; preds = %41, %15
store i64 0, i64* @errno
%45 = call i32 (...) @endutxent()
%46 = load i64, i64* @errno
%47 = icmp eq i64 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %44
%49 = call i32 @pexit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %48, %44
%51 = load i32, i32* @EXIT_SUCCESS
%52 = call i32 @exit(i32 %51)
unreachable
}