#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 */
typedef int /*<<< orphan*/ u;
struct utmp {
  char *ut_name;
  char *ut_line;
  int /*<<< orphan*/ ut_time;
};

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ O_RDONLY;
char *UT_LINESIZE;
char *UT_NAMESIZE;
int /*<<< orphan*/ _PATH_UTMP;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ ctime_r(int /*<<< orphan*/ *, char *);
int open(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *, char *, char *, char *);
int read(int, struct utmp *, int);
int /*<<< orphan*/ warn(char *);
int main(int argc, char *argv[]) {
  int fd;
  struct utmp u;
  char utime[32];
  fd = open(_PATH_UTMP, O_RDONLY);
  if (fd < 0) {
    warn("who: can't open utmp");
    return (EXIT_FAILURE);
  }
  while (read(fd, &u, sizeof(u)) == sizeof(u)) {
    if (*u.ut_name == '\0' || *u.ut_line == '\0')
      continue;
    ctime_r(&u.ut_time, utime);
    printf("%-8.*s %-8.*s %s", UT_NAMESIZE, u.ut_name, UT_LINESIZE, u.ut_line,
           utime + 4);
  }
  close(fd);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11b7 <main+0x57>
lea    0xe5f(%rip),%rdi
call   1030 <warn@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1258 <main+0xf8>
jmp    11bc <main+0x5c>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x18,%edx
call   1060 <read@plt>
cltq
cmp    $0x18,%rax
jne    1244 <main+0xe4>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f9 <main+0x99>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11fe <main+0x9e>
jmp    11bc <main+0x5c>
lea    -0x30(%rbp),%rdi
add    $0x10,%rdi
lea    -0x50(%rbp),%rsi
call   1070 <ctime_r@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%rsi
mov    -0x30(%rbp),%rdx
mov    0x2dac(%rip),%rax
mov    (%rax),%rcx
mov    -0x28(%rbp),%r8
lea    -0x50(%rbp),%r9
add    $0x4,%r9
lea    0xddb(%rip),%rdi
call   1040 <printf@plt>
jmp    11bc <main+0x5c>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
test   %eax,%eax
js     1234 <main+0xd4>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
mov    $0x18,%edx
call   1060 <read@plt>
cmp    $0x18,%eax
jne    1224 <main+0xc4>
lea    0x8(%rsp),%r12
lea    0x20(%rsp),%r13
mov    0x2e3e(%rip),%r14
mov    0x2e0f(%rip),%r15
lea    0xe4d(%rip),%rbp
jmp    11e4 <main+0x84>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r12,%rsi
mov    $0x18,%edx
call   1060 <read@plt>
cmp    $0x18,%eax
jne    1224 <main+0xc4>
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     11d0 <main+0x70>
mov    0x10(%rsp),%rax
cmpb   $0x0,(%rax)
je     11d0 <main+0x70>
lea    0x18(%rsp),%rdi
mov    %r13,%rsi
call   1070 <ctime_r@plt>
mov    (%r14),%rsi
mov    (%r15),%rcx
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%r8
mov    %rbp,%rdi
lea    0x24(%rsp),%r9
call   1040 <printf@plt>
jmp    11d0 <main+0x70>
mov    %ebx,%edi
call   1050 <close@plt>
mov    0x2d86(%rip),%rax
jmp    1247 <main+0xe7>
lea    0xdc5(%rip),%rdi
call   1030 <warn@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.utmp = type { i8*, i8*, i32 }
@_PATH_UTMP = global i32 0
@O_RDONLY = global i32 0
@.str = [21 x i8] c"who: can't open utmp\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [17 x i8] c"%-8.*s %-8.*s %s\00"
@UT_NAMESIZE = global i8* null
@UT_LINESIZE = global i8* null
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.utmp
%8 = alloca [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @_PATH_UTMP
%10 = load i32, i32* @O_RDONLY
%11 = call i32 @open(i32 %9, i32 %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 @warn(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
store i32 %16, i32* %3
br label %53
17: ; preds = %2
br label %18
18: ; preds = %36, %35, %17
%19 = load i32, i32* %6
%20 = call i32 @read(i32 %19, %struct.utmp* %7, i32 24)
%21 = sext i32 %20 to i64
%22 = icmp eq i64 %21, 24
br i1 %22, label %23, label %49
23: ; preds = %18
%24 = getelementptr inbounds %struct.utmp, %struct.utmp* %7, i32 0, i32 0
%25 = load i8*, i8** %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %23
%30 = getelementptr inbounds %struct.utmp, %struct.utmp* %7, i32 0, i32 1
%31 = load i8*, i8** %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %29, %23
br label %18
36: ; preds = %29
%37 = getelementptr inbounds %struct.utmp, %struct.utmp* %7, i32 0, i32 2
%38 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%39 = call i32 @ctime_r(i32* %37, i8* %38)
%40 = load i8*, i8** @UT_NAMESIZE
%41 = getelementptr inbounds %struct.utmp, %struct.utmp* %7, i32 0, i32 0
%42 = load i8*, i8** %41
%43 = load i8*, i8** @UT_LINESIZE
%44 = getelementptr inbounds %struct.utmp, %struct.utmp* %7, i32 0, i32 1
%45 = load i8*, i8** %44
%46 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%47 = getelementptr inbounds i8, i8* %46, i64 4
%48 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %40, i8* %42, i8* %43, i8* %45, i8* %47)
br label %18
49: ; preds = %18
%50 = load i32, i32* %6
%51 = call i32 @close(i32 %50)
%52 = load i32, i32* @EXIT_SUCCESS
store i32 %52, i32* %3
br label %53
53: ; preds = %49, %14
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
%struct.utmp = type { i8*, i8*, i32 }
@_PATH_UTMP = global i32 0
@O_RDONLY = global i32 0
@.str = [21 x i8] c"who: can't open utmp\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [17 x i8] c"%-8.*s %-8.*s %s\00"
@UT_NAMESIZE = global i8* null
@UT_LINESIZE = global i8* null
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.utmp
%4 = alloca [32 x i8]
%5 = bitcast %struct.utmp* %3 to i8*
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* @_PATH_UTMP
%8 = load i32, i32* @O_RDONLY
%9 = tail call i32 @open(i32 %7, i32 %8)
%10 = icmp slt i32 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %2
%12 = call i32 @read(i32 %9, %struct.utmp* %3, i32 24)
%13 = icmp eq i32 %12, 24
br i1 %13, label %14, label %39
14: ; preds = %11
%15 = getelementptr inbounds %struct.utmp, %struct.utmp* %3, i64 0, i32 0
%16 = getelementptr inbounds %struct.utmp, %struct.utmp* %3, i64 0, i32 1
%17 = getelementptr inbounds %struct.utmp, %struct.utmp* %3, i64 0, i32 2
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 4
br label %21
19: ; preds = %2
%20 = tail call i32 @warn(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %41
21: ; preds = %14, %29
%22 = load i8*, i8** %15
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i8*, i8** %16
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %21, %25, %32
%30 = call i32 @read(i32 %9, %struct.utmp* %3, i32 24)
%31 = icmp eq i32 %30, 24
br i1 %31, label %21, label %39
32: ; preds = %25
%33 = call i32 @ctime_r(i32* %17, i8* %6)
%34 = load i8*, i8** @UT_NAMESIZE
%35 = load i8*, i8** %15
%36 = load i8*, i8** @UT_LINESIZE
%37 = load i8*, i8** %16
%38 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %34, i8* %35, i8* %36, i8* %37, i8* %18)
br label %29
39: ; preds = %29, %11
%40 = call i32 @close(i32 %9)
br label %41
41: ; preds = %39, %19
%42 = phi i32* [ @EXIT_FAILURE, %19 ], [ @EXIT_SUCCESS, %39 ]
%43 = load i32, i32* %42
ret i32 %43
}