#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 scalar_t__ time_t;
typedef int /*<<< orphan*/ time_str;
struct TYPE_2__ {
  scalar_t__ tv_sec;
};
struct utmpx {
  scalar_t__ ut_type;
  TYPE_1__ ut_tv;
};
struct tm {
  int dummy;
};

/* Variables and functions */
scalar_t__ BOOT_TIME;
int /*<<< orphan*/ endutxent();
struct utmpx *getutxent();
struct tm *gmtime(scalar_t__ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int main() {
  struct utmpx *ut;
  while ((ut = getutxent()) != NULL && ut->ut_type != BOOT_TIME)
    ;
  if (ut != NULL) {
    char time_str[64];
    struct tm *tm;
    time_t as_time_t = ut->ut_tv.tv_sec;
    tm = gmtime(&as_time_t);
    strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M:%S", tm);
    printf("epoch\tL\t%llu\n", (long long unsigned)ut->ut_tv.tv_sec);
    printf("date\ts\t%s\n", time_str);
  } else {
    printf("epoch\tL\t[[null]]\n");
    printf("date\ts\t[[null]]\n");
  }
  endutxent();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <getutxent@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x61(%rbp)
je     1193 <main+0x43>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e56(%rip),%rcx
cmp    (%rcx),%rax
setne  %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    11a3 <main+0x53>
jmp    11a8 <main+0x58>
jmp    115f <main+0xf>
cmpq   $0x0,-0x10(%rbp)
je     1212 <main+0xc2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x60(%rbp)
lea    -0x60(%rbp),%rdi
call   1070 <gmtime@plt>
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rcx
mov    $0x40,%esi
lea    0xe20(%rip),%rdx
call   1050 <strftime@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    122e <main+0xde>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <endutxent@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    0x2e72(%rip),%r14
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <getutxent@plt>
test   %rax,%rax
je     11db <main+0x7b>
mov    %rax,%rbx
mov    (%rax),%rax
cmp    (%r14),%rax
jne    1170 <main+0x10>
mov    0x8(%rbx),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1080 <gmtime@plt>
lea    0xe5f(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rax,%rcx
call   1060 <strftime@plt>
mov    0x8(%rbx),%rsi
lea    0xe51(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe51(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11f3 <main+0x93>
lea    0xe49(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <endutxent@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.utmpx = type { i64, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64 }
%struct.tm = type { i32 }
@BOOT_TIME = global i64 0
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.1 = [14 x i8] c"epoch\09L\09%llu\0A\00"
@.str.2 = [11 x i8] c"date\09s\09%s\0A\00"
@.str.3 = [18 x i8] c"epoch\09L\09[[null]]\0A\00"
@.str.4 = [17 x i8] c"date\09s\09[[null]]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.utmpx*
%3 = alloca [64 x i8]
%4 = alloca %struct.tm*
%5 = alloca i64
store i32 0, i32* %1
br label %6
6: ; preds = %17, %0
%7 = call %struct.utmpx* (...) @getutxent()
store %struct.utmpx* %7, %struct.utmpx** %2
%8 = icmp ne %struct.utmpx* %7, null
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = load %struct.utmpx*, %struct.utmpx** %2
%11 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %10, i32 0, i32 0
%12 = load i64, i64* %11
%13 = load i64, i64* @BOOT_TIME
%14 = icmp ne i64 %12, %13
br label %15
15: ; preds = %9, %6
%16 = phi i1 [ false, %6 ], [ %14, %9 ]
br i1 %16, label %17, label %18
17: ; preds = %15
br label %6
18: ; preds = %15
%19 = load %struct.utmpx*, %struct.utmpx** %2
%20 = icmp ne %struct.utmpx* %19, null
br i1 %20, label %21, label %37
21: ; preds = %18
%22 = load %struct.utmpx*, %struct.utmpx** %2
%23 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %22, i32 0, i32 1
%24 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %23, i32 0, i32 0
%25 = load i64, i64* %24
store i64 %25, i64* %5
%26 = call %struct.tm* @gmtime(i64* %5)
store %struct.tm* %26, %struct.tm** %4
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%28 = load %struct.tm*, %struct.tm** %4
%29 = call i32 @strftime(i8* %27, i32 64, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %28)
%30 = load %struct.utmpx*, %struct.utmpx** %2
%31 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %30, i32 0, i32 1
%32 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %31, i32 0, i32 0
%33 = load i64, i64* %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 %33)
%35 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %35)
br label %40
37: ; preds = %18
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %37, %21
%41 = call i32 (...) @endutxent()
ret i32 0
}

LLVM IR (-O2):
%struct.utmpx = type { i64, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64 }
%struct.tm = type { i32 }
@BOOT_TIME = global i64 0
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.1 = [14 x i8] c"epoch\09L\09%llu\0A\00"
@.str.2 = [11 x i8] c"date\09s\09%s\0A\00"
@str = [17 x i8] c"epoch\09L\09[[null]]\00"
@str.5 = [16 x i8] c"date\09s\09[[null]]\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = alloca i64
br label %3
3: ; preds = %6, %0
%4 = tail call %struct.utmpx* (...) @getutxent()
%5 = icmp eq %struct.utmpx* %4, null
br i1 %5, label %21, label %6
6: ; preds = %3
%7 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %4, i64 0, i32 0
%8 = load i64, i64* %7
%9 = load i64, i64* @BOOT_TIME
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %3
11: ; preds = %6
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%13 = bitcast i64* %2 to i8*
%14 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %4, i64 0, i32 1, i32 0
%15 = load i64, i64* %14
store i64 %15, i64* %2
%16 = call %struct.tm* @gmtime(i64* %2)
%17 = call i32 @strftime(i8* %12, i32 64, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %16)
%18 = load i64, i64* %14
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 %18)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %24
21: ; preds = %3
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.5, i64 0, i64 0))
br label %24
24: ; preds = %21, %11
%25 = call i32 (...) @endutxent()
ret i32 0
}