#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 utmp {
  int ut_type;
  TYPE_1__ ut_tv;
};
struct tm {
  int dummy;
};

/* Variables and functions */
struct utmp *getutent();
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ setutent();
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void m_opt() {
  struct utmp *info;
  time_t current_time, start_time;
  struct tm *y2k;
  char date[20];
  setutent();
  info = getutent();
  while (info != NULL) {
    if (info->ut_type == 7) {
      current_time = time(NULL);
      start_time = info->ut_tv.tv_sec;
      y2k = localtime(&start_time);
      strftime(date, 20, "%F %R", y2k);
      printf("System boot %s\n", date);
    }
  }
}


x86 assembly (clang, -O0):
<m_opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1080 <setutent@plt>
mov    $0x0,%al
call   1060 <getutent@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11e3 <m_opt+0x83>
mov    -0x8(%rbp),%rax
cmpl   $0x7,(%rax)
jne    11de <m_opt+0x7e>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x14,%esi
lea    0xe37(%rip),%rdx
call   1070 <strftime@plt>
lea    -0x30(%rbp),%rsi
lea    0xe2d(%rip),%rdi
call   1040 <printf@plt>
jmp    117a <m_opt+0x1a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m_opt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
xor    %eax,%eax
call   1080 <setutent@plt>
xor    %eax,%eax
call   1060 <getutent@plt>
test   %rax,%rax
je     11db <m_opt+0x7b>
mov    %rax,%rbx
lea    0xc(%rsp),%r14
lea    0xe71(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xe6b(%rip),%r13
nopl   0x0(%rax,%rax,1)
cmpl   $0x7,(%rbx)
jne    11a0 <m_opt+0x40>
xor    %edi,%edi
call   1050 <time@plt>
mov    0x4(%rbx),%eax
mov    %eax,0xc(%rsp)
mov    %r14,%rdi
call   1030 <localtime@plt>
mov    %r12,%rdi
mov    $0x14,%esi
mov    %r15,%rdx
mov    %rax,%rcx
call   1070 <strftime@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
jmp    11a0 <m_opt+0x40>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.utmp = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.tm = type { i32 }
@.str = [6 x i8] c"%F %R\00"
@.str.1 = [16 x i8] c"System boot %s\0A\00"
define void @m_opt() {
%1 = alloca %struct.utmp*
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca [20 x i8]
%6 = call i32 (...) @setutent()
%7 = call %struct.utmp* (...) @getutent()
store %struct.utmp* %7, %struct.utmp** %1
br label %8
8: ; preds = %28, %0
%9 = load %struct.utmp*, %struct.utmp** %1
%10 = icmp ne %struct.utmp* %9, null
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = load %struct.utmp*, %struct.utmp** %1
%13 = getelementptr inbounds %struct.utmp, %struct.utmp* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 7
br i1 %15, label %16, label %28
16: ; preds = %11
%17 = call i32 @time(i32* null)
store i32 %17, i32* %2
%18 = load %struct.utmp*, %struct.utmp** %1
%19 = getelementptr inbounds %struct.utmp, %struct.utmp* %18, i32 0, i32 1
%20 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %19, i32 0, i32 0
%21 = load i32, i32* %20
store i32 %21, i32* %3
%22 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %22, %struct.tm** %4
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%24 = load %struct.tm*, %struct.tm** %4
%25 = call i32 @strftime(i8* %23, i32 20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.tm* %24)
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %16, %11
br label %8
29: ; preds = %8
ret void
}

LLVM IR (-O2):
%struct.utmp = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.tm = type { i32 }
@.str = [6 x i8] c"%F %R\00"
@.str.1 = [16 x i8] c"System boot %s\0A\00"
define void @m_opt() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (...) @setutent()
%6 = tail call %struct.utmp* (...) @getutent()
%7 = icmp eq %struct.utmp* %6, null
br i1 %7, label %21, label %8
8: ; preds = %0
%9 = getelementptr inbounds %struct.utmp, %struct.utmp* %6, i64 0, i32 0
%10 = getelementptr inbounds %struct.utmp, %struct.utmp* %6, i64 0, i32 1, i32 0
br label %11
11: ; preds = %20, %8
%12 = load i32, i32* %9
%13 = icmp eq i32 %12, 7
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = call i32 @time(i32* null)
%16 = load i32, i32* %10
store i32 %16, i32* %1
%17 = call %struct.tm* @localtime(i32* %1)
%18 = call i32 @strftime(i8* %4, i32 20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.tm* %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %20
20: ; preds = %14, %11
br label %11
21: ; preds = %0
ret void
}