#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 */
struct tm {
  int tm_sec;
  int /*<<< orphan*/ tm_min;
  int /*<<< orphan*/ tm_hour;
  int /*<<< orphan*/ tm_mday;
  scalar_t__ tm_mon;
  scalar_t__ tm_year;
};
struct TYPE_2__ {
  int tv_sec;
};
struct timex {
  TYPE_1__ time;
};
struct timespec {
  int tv_nsec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_BOOTTIME;
int TIME_DEL;
int TIME_INS;
int TIME_OOP;
int adjtimex(struct timex *);
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
struct tm *gmtime(int *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, int, scalar_t__,
                          scalar_t__, int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int, char const *);
int /*<<< orphan*/ stdout;
void printline(const char *line) {
  static struct timex timex;
  struct timespec boottime;
  struct tm *utctime;
  int r;
  clock_gettime(CLOCK_BOOTTIME, &boottime);
  r = adjtimex(&timex);
  if (timex.time.tv_sec % (24 * 60 * 60) == 0) {
    if (r == TIME_INS) {
      timex.time.tv_sec -= 1;
      utctime = gmtime(&timex.time.tv_sec);
      utctime->tm_sec += 1;
    } else if (r == TIME_DEL) {
      timex.time.tv_sec += 1;
      utctime = gmtime(&timex.time.tv_sec);
    } else {
      utctime = gmtime(&timex.time.tv_sec);
    }
  } else if (r == TIME_OOP) {
    utctime = gmtime(&timex.time.tv_sec);
    utctime->tm_sec += 1;
  } else {
    utctime = gmtime(&timex.time.tv_sec);
  }
  printf("[%010lu.%04lu %i-%02i-%02i %02i:%02i:%02i UTC] %s", boottime.tv_sec,
         boottime.tv_nsec / 100000, utctime->tm_year + 1900,
         utctime->tm_mon + 1, utctime->tm_mday, utctime->tm_hour,
         utctime->tm_min, utctime->tm_sec, line);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<printline>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x48,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1030 <clock_gettime@plt>
lea    0x2ed6(%rip),%rdi
call   1070 <adjtimex@plt>
mov    %eax,-0x24(%rbp)
mov    0x2ec8(%rip),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1226 <printline+0xd6>
mov    -0x24(%rbp),%eax
mov    0x2e41(%rip),%rcx
cmp    (%rcx),%eax
jne    11d6 <printline+0x86>
mov    0x2e9f(%rip),%eax
sub    $0x1,%eax
mov    %eax,0x2e96(%rip)
lea    0x2e8f(%rip),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1221 <printline+0xd1>
mov    -0x24(%rbp),%eax
mov    0x2df0(%rip),%rcx
cmp    (%rcx),%eax
jne    120c <printline+0xbc>
mov    0x2e5e(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e55(%rip)
lea    0x2e4e(%rip),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x20(%rbp)
jmp    121c <printline+0xcc>
lea    0x2e39(%rip),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x20(%rbp)
jmp    1221 <printline+0xd1>
jmp    126d <printline+0x11d>
mov    -0x24(%rbp),%eax
mov    0x2d90(%rip),%rcx
cmp    (%rcx),%eax
jne    1258 <printline+0x108>
lea    0x2e0d(%rip),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1268 <printline+0x118>
lea    0x2ded(%rip),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x20(%rbp)
jmp    126d <printline+0x11d>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%eax
mov    $0x186a0,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%rcx
add    $0x76c,%rcx
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%r8
add    $0x1,%r8
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%ebx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%r11d
mov    -0x20(%rbp),%rax
mov    (%rax),%r10d
mov    -0x10(%rbp),%rax
lea    0xd3f(%rip),%rdi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1040 <printf@plt>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<printline>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1030 <clock_gettime@plt>
lea    0x2ed7(%rip),%rdi
call   1070 <adjtimex@plt>
mov    %eax,%ebp
mov    0x2eca(%rip),%eax
imul   $0x2d21c10b,%eax,%ecx
add    $0x308b80,%ecx
ror    $0x7,%ecx
cmp    $0xc22e,%ecx
jbe    11b4 <printline+0x64>
mov    0x2e20(%rip),%rax
mov    (%rax),%ebx
lea    0x2ea3(%rip),%rdi
call   1060 <gmtime@plt>
cmp    %ebx,%ebp
je     11d4 <printline+0x84>
jmp    11f9 <printline+0xa9>
mov    0x2e25(%rip),%rcx
cmp    (%rcx),%ebp
jne    11d9 <printline+0x89>
add    $0xffffffff,%eax
mov    %eax,0x2e84(%rip)
lea    0x2e7d(%rip),%rdi
call   1060 <gmtime@plt>
addl   $0x1,(%rax)
jmp    11f9 <printline+0xa9>
mov    0x2df0(%rip),%rcx
cmp    (%rcx),%ebp
jne    11ed <printline+0x9d>
add    $0x1,%eax
mov    %eax,0x2e5f(%rip)
lea    0x2e58(%rip),%rdi
call   1060 <gmtime@plt>
mov    0xc(%rsp),%esi
movslq 0x8(%rsp),%rcx
imul   $0x14f8b589,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x2d,%rdx
add    %ecx,%edx
mov    $0x76c,%ecx
add    0x18(%rax),%rcx
mov    0x10(%rax),%r8
add    $0x1,%r8
mov    0xc(%rax),%r9d
mov    0x8(%rax),%ebp
mov    (%rax),%ebx
mov    0x4(%rax),%eax
lea    0xdc6(%rip),%rdi
push   %r14
push   %rbx
push   %rax
push   %rbp
call   1040 <printf@plt>
add    $0x20,%rsp
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timex = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.timespec = type { i32, i32 }
%struct.tm = type { i32, i32, i32, i32, i64, i64 }
@printline.timex = internal global %struct.timex zeroinitializer
@CLOCK_BOOTTIME = global i32 0
@TIME_INS = global i32 0
@TIME_DEL = global i32 0
@TIME_OOP = global i32 0
@.str = [50 x i8] c"[%010lu.%04lu %i-%02i-%02i %02i:%02i:%02i UTC] %s\00"
@stdout = global i32 0
define void @printline(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.timespec
%4 = alloca %struct.tm*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i32, i32* @CLOCK_BOOTTIME
%7 = call i32 @clock_gettime(i32 %6, %struct.timespec* %3)
%8 = call i32 @adjtimex(%struct.timex* @printline.timex)
store i32 %8, i32* %5
%9 = load i32, i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i32 0, i32 0, i32 0)
%10 = srem i32 %9, 86400
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %36
12: ; preds = %1
%13 = load i32, i32* %5
%14 = load i32, i32* @TIME_INS
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i32, i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i32 0, i32 0, i32 0)
%18 = sub nsw i32 %17, 1
store i32 %18, i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i32 0, i32 0, i32 0)
%19 = call %struct.tm* @gmtime(i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i32 0, i32 0, i32 0))
store %struct.tm* %19, %struct.tm** %4
%20 = load %struct.tm*, %struct.tm** %4
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
store i32 %23, i32* %21
br label %35
24: ; preds = %12
%25 = load i32, i32* %5
%26 = load i32, i32* @TIME_DEL
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i32, i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i32 0, i32 0, i32 0)
%30 = add nsw i32 %29, 1
store i32 %30, i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i32 0, i32 0, i32 0)
%31 = call %struct.tm* @gmtime(i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i32 0, i32 0, i32 0))
store %struct.tm* %31, %struct.tm** %4
br label %34
32: ; preds = %24
%33 = call %struct.tm* @gmtime(i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i32 0, i32 0, i32 0))
store %struct.tm* %33, %struct.tm** %4
br label %34
34: ; preds = %32, %28
br label %35
35: ; preds = %34, %16
br label %49
36: ; preds = %1
%37 = load i32, i32* %5
%38 = load i32, i32* @TIME_OOP
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %46
40: ; preds = %36
%41 = call %struct.tm* @gmtime(i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i32 0, i32 0, i32 0))
store %struct.tm* %41, %struct.tm** %4
%42 = load %struct.tm*, %struct.tm** %4
%43 = getelementptr inbounds %struct.tm, %struct.tm* %42, i32 0, i32 0
%44 = load i32, i32* %43
%45 = add nsw i32 %44, 1
store i32 %45, i32* %43
br label %48
46: ; preds = %36
%47 = call %struct.tm* @gmtime(i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i32 0, i32 0, i32 0))
store %struct.tm* %47, %struct.tm** %4
br label %48
48: ; preds = %46, %40
br label %49
49: ; preds = %48, %35
%50 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
%51 = load i32, i32* %50
%52 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
%53 = load i32, i32* %52
%54 = sdiv i32 %53, 100000
%55 = load %struct.tm*, %struct.tm** %4
%56 = getelementptr inbounds %struct.tm, %struct.tm* %55, i32 0, i32 5
%57 = load i64, i64* %56
%58 = add nsw i64 %57, 1900
%59 = load %struct.tm*, %struct.tm** %4
%60 = getelementptr inbounds %struct.tm, %struct.tm* %59, i32 0, i32 4
%61 = load i64, i64* %60
%62 = add nsw i64 %61, 1
%63 = load %struct.tm*, %struct.tm** %4
%64 = getelementptr inbounds %struct.tm, %struct.tm* %63, i32 0, i32 3
%65 = load i32, i32* %64
%66 = load %struct.tm*, %struct.tm** %4
%67 = getelementptr inbounds %struct.tm, %struct.tm* %66, i32 0, i32 2
%68 = load i32, i32* %67
%69 = load %struct.tm*, %struct.tm** %4
%70 = getelementptr inbounds %struct.tm, %struct.tm* %69, i32 0, i32 1
%71 = load i32, i32* %70
%72 = load %struct.tm*, %struct.tm** %4
%73 = getelementptr inbounds %struct.tm, %struct.tm* %72, i32 0, i32 0
%74 = load i32, i32* %73
%75 = load i8*, i8** %2
%76 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %51, i32 %54, i64 %58, i64 %62, i32 %65, i32 %68, i32 %71, i32 %74, i8* %75)
%77 = load i32, i32* @stdout
%78 = call i32 @fflush(i32 %77)
ret void
}

LLVM IR (-O2):
%struct.timex = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.timespec = type { i32, i32 }
%struct.tm = type { i32, i32, i32, i32, i64, i64 }
@printline.timex = internal global %struct.timex zeroinitializer
@CLOCK_BOOTTIME = global i32 0
@TIME_INS = global i32 0
@TIME_DEL = global i32 0
@TIME_OOP = global i32 0
@.str = [50 x i8] c"[%010lu.%04lu %i-%02i-%02i %02i:%02i:%02i UTC] %s\00"
@stdout = global i32 0
define void @printline(i8* %0) {
%2 = alloca %struct.timespec
%3 = bitcast %struct.timespec* %2 to i8*
%4 = load i32, i32* @CLOCK_BOOTTIME
%5 = call i32 @clock_gettime(i32 %4, %struct.timespec* %2)
%6 = call i32 @adjtimex(%struct.timex* @printline.timex)
%7 = load i32, i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i64 0, i32 0, i32 0)
%8 = srem i32 %7, 86400
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %27
10: ; preds = %1
%11 = load i32, i32* @TIME_INS
%12 = icmp eq i32 %6, %11
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = add nsw i32 %7, -1
store i32 %14, i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i64 0, i32 0, i32 0)
%15 = call %struct.tm* @gmtime(i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i64 0, i32 0, i32 0))
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i64 0, i32 0
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %16
br label %35
19: ; preds = %10
%20 = load i32, i32* @TIME_DEL
%21 = icmp eq i32 %6, %20
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = add nsw i32 %7, 1
store i32 %23, i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i64 0, i32 0, i32 0)
%24 = call %struct.tm* @gmtime(i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i64 0, i32 0, i32 0))
br label %35
25: ; preds = %19
%26 = call %struct.tm* @gmtime(i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i64 0, i32 0, i32 0))
br label %35
27: ; preds = %1
%28 = load i32, i32* @TIME_OOP
%29 = icmp eq i32 %6, %28
%30 = call %struct.tm* @gmtime(i32* getelementptr inbounds (%struct.timex, %struct.timex* @printline.timex, i64 0, i32 0, i32 0))
br i1 %29, label %31, label %35
31: ; preds = %27
%32 = getelementptr inbounds %struct.tm, %struct.tm* %30, i64 0, i32 0
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1
store i32 %34, i32* %32
br label %35
35: ; preds = %27, %31, %13, %25, %22
%36 = phi %struct.tm* [ %15, %13 ], [ %24, %22 ], [ %26, %25 ], [ %30, %31 ], [ %30, %27 ]
%37 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%38 = load i32, i32* %37
%39 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%40 = load i32, i32* %39
%41 = sdiv i32 %40, 100000
%42 = getelementptr inbounds %struct.tm, %struct.tm* %36, i64 0, i32 5
%43 = load i64, i64* %42
%44 = add nsw i64 %43, 1900
%45 = getelementptr inbounds %struct.tm, %struct.tm* %36, i64 0, i32 4
%46 = load i64, i64* %45
%47 = add nsw i64 %46, 1
%48 = getelementptr inbounds %struct.tm, %struct.tm* %36, i64 0, i32 3
%49 = load i32, i32* %48
%50 = getelementptr inbounds %struct.tm, %struct.tm* %36, i64 0, i32 2
%51 = load i32, i32* %50
%52 = getelementptr inbounds %struct.tm, %struct.tm* %36, i64 0, i32 1
%53 = load i32, i32* %52
%54 = getelementptr inbounds %struct.tm, %struct.tm* %36, i64 0, i32 0
%55 = load i32, i32* %54
%56 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %38, i32 %41, i64 %44, i64 %47, i32 %49, i32 %51, i32 %53, i32 %55, i8* %0)
%57 = load i32, i32* @stdout
%58 = call i32 @fflush(i32 %57)
ret void
}