#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 */
struct file_header {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ xprintf(int, char *, ...);
int /*<<< orphan*/ xprintf0(int, char *);
void print_json_restart(int *tab, int action, char *cur_date, char *cur_time,
                        int utc, struct file_header *file_hdr) {
  static int sep = 0;
  if (action & 0x01) {
    printf(",\n");
    xprintf((*tab)++, "\"restarts\": [");
  }
  if (action & 0x02) {
    if (sep) {
      printf(",\n");
    }
    xprintf((*tab)++, "{");
    xprintf(*tab, "\"boot\": {\"date\": \"%s\", \"time\": \"%s\", \"utc\": %d}",
            cur_date, cur_time, utc ? 1 : 0);
    xprintf0(--(*tab), "}");
    sep = 1;
  }
  if (action & 0x04) {
    if (sep) {
      printf("\n");
      sep = 0;
    }
    xprintf0(--(*tab), "]");
  }
}


x86 assembly (clang, -O0):
<print_json_restart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1185 <print_json_restart+0x55>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    %edi,%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1040 <xprintf@plt>
mov    -0xc(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1217 <print_json_restart+0xe7>
cmpl   $0x0,0x2ea1(%rip)
je     11ad <print_json_restart+0x7d>
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    %edi,%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1040 <xprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%esi
xor    %r8d,%r8d
mov    $0x1,%eax
cmp    $0x0,%esi
cmovne %eax,%r8d
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1040 <xprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
add    $0xffffffff,%edi
mov    %edi,(%rax)
lea    0xe39(%rip),%rsi
call   1050 <xprintf0@plt>
movl   $0x1,0x2e25(%rip)
mov    -0xc(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1260 <print_json_restart+0x130>
cmpl   $0x0,0x2e0f(%rip)
je     1249 <print_json_restart+0x119>
lea    0xdc7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,0x2df3(%rip)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
add    $0xffffffff,%edi
mov    %edi,(%rax)
lea    0xde8(%rip),%rsi
call   1050 <xprintf0@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_json_restart>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r12d
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%rbx
test   $0x1,%bpl
jne    1175 <print_json_restart+0x35>
test   $0x2,%bpl
jne    119c <print_json_restart+0x5c>
test   $0x4,%bpl
jne    120a <print_json_restart+0xca>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%edi
lea    0x1(%rdi),%eax
mov    %eax,(%rbx)
lea    0xe71(%rip),%rsi
xor    %eax,%eax
call   1050 <xprintf@plt>
test   $0x2,%bpl
je     1162 <print_json_restart+0x22>
cmpb   $0x1,0x2ea1(%rip)
jne    11b1 <print_json_restart+0x71>
lea    0xe96(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%edi
lea    0x1(%rdi),%eax
mov    %eax,(%rbx)
lea    0xe4f(%rip),%rsi
xor    %eax,%eax
call   1050 <xprintf@plt>
mov    (%rbx),%edi
xor    %r8d,%r8d
test   %r12d,%r12d
setne  %r8b
lea    0xe37(%rip),%rsi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <xprintf@plt>
mov    (%rbx),%edi
add    $0xffffffff,%edi
mov    %edi,(%rbx)
lea    0xe4a(%rip),%rsi
call   1060 <xprintf0@plt>
movb   $0x1,0x2e44(%rip)
test   $0x4,%bpl
je     116c <print_json_restart+0x2c>
cmpb   $0x1,0x2e33(%rip)
jne    1224 <print_json_restart+0xe4>
mov    $0xa,%edi
call   1030 <putchar@plt>
movb   $0x0,0x2e20(%rip)
mov    (%rbx),%edi
add    $0xffffffff,%edi
mov    %edi,(%rbx)
lea    0xe0e(%rip),%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <xprintf0@plt>

LLVM IR (-O0):
%struct.file_header = type { i32 }
@print_json_restart.sep = internal global i32 0
@.str = [3 x i8] c",\0A\00"
@.str.1 = [14 x i8] c"\22restarts\22: [\00"
@.str.2 = [2 x i8] c"{\00"
@.str.3 = [48 x i8] c"\22boot\22: {\22date\22: \22%s\22, \22time\22: \22%s\22, \22utc\22: %d}\00"
@.str.4 = [2 x i8] c"}\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [2 x i8] c"]\00"
define void @print_json_restart(i32* %0, i32 %1, i8* %2, i8* %3, i32 %4, %struct.file_header* %5) {
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca %struct.file_header*
store i32* %0, i32** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store %struct.file_header* %5, %struct.file_header** %12
%13 = load i32, i32* %8
%14 = and i32 %13, 1
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %6
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = load i32*, i32** %7
%19 = load i32, i32* %18
%20 = add nsw i32 %19, 1
store i32 %20, i32* %18
%21 = call i32 (i32, i8*, ...) @xprintf(i32 %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %16, %6
%23 = load i32, i32* %8
%24 = and i32 %23, 2
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %49
26: ; preds = %22
%27 = load i32, i32* @print_json_restart.sep
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
%32 = load i32*, i32** %7
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1
store i32 %34, i32* %32
%35 = call i32 (i32, i8*, ...) @xprintf(i32 %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32*, i32** %7
%37 = load i32, i32* %36
%38 = load i8*, i8** %9
%39 = load i8*, i8** %10
%40 = load i32, i32* %11
%41 = icmp ne i32 %40, 0
%42 = zext i1 %41 to i64
%43 = select i1 %41, i32 1, i32 0
%44 = call i32 (i32, i8*, ...) @xprintf(i32 %37, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %38, i8* %39, i32 %43)
%45 = load i32*, i32** %7
%46 = load i32, i32* %45
%47 = add nsw i32 %46, -1
store i32 %47, i32* %45
%48 = call i32 @xprintf0(i32 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* @print_json_restart.sep
br label %49
49: ; preds = %31, %22
%50 = load i32, i32* %8
%51 = and i32 %50, 4
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %63
53: ; preds = %49
%54 = load i32, i32* @print_json_restart.sep
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* @print_json_restart.sep
br label %58
58: ; preds = %56, %53
%59 = load i32*, i32** %7
%60 = load i32, i32* %59
%61 = add nsw i32 %60, -1
store i32 %61, i32* %59
%62 = call i32 @xprintf0(i32 %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %63
63: ; preds = %58, %49
ret void
}

LLVM IR (-O2):
%struct.file_header = type { i32 }
@print_json_restart.sep = internal unnamed_addr global i1 false
@.str.1 = [14 x i8] c"\22restarts\22: [\00"
@.str.2 = [2 x i8] c"{\00"
@.str.3 = [48 x i8] c"\22boot\22: {\22date\22: \22%s\22, \22time\22: \22%s\22, \22utc\22: %d}\00"
@.str.4 = [2 x i8] c"}\00"
@.str.6 = [2 x i8] c"]\00"
@str.7 = [2 x i8] c",\00"
define void @print_json_restart(i32* nocapture %0, i32 %1, i8* %2, i8* %3, i32 %4, %struct.file_header* nocapture readnone %5) {
%7 = and i32 %1, 1
%8 = icmp eq i32 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.7, i64 0, i64 0))
%11 = load i32, i32* %0
%12 = add nsw i32 %11, 1
store i32 %12, i32* %0
%13 = tail call i32 (i32, i8*, ...) @xprintf(i32 %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %9, %6
%15 = and i32 %1, 2
%16 = icmp eq i32 %15, 0
br i1 %16, label %32, label %17
17: ; preds = %14
%18 = load i1, i1* @print_json_restart.sep
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.7, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
%22 = load i32, i32* %0
%23 = add nsw i32 %22, 1
store i32 %23, i32* %0
%24 = tail call i32 (i32, i8*, ...) @xprintf(i32 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = load i32, i32* %0
%26 = icmp ne i32 %4, 0
%27 = zext i1 %26 to i32
%28 = tail call i32 (i32, i8*, ...) @xprintf(i32 %25, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %2, i8* %3, i32 %27)
%29 = load i32, i32* %0
%30 = add nsw i32 %29, -1
store i32 %30, i32* %0
%31 = tail call i32 @xprintf0(i32 %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i1 true, i1* @print_json_restart.sep
br label %32
32: ; preds = %21, %14
%33 = and i32 %1, 4
%34 = icmp eq i32 %33, 0
br i1 %34, label %43, label %35
35: ; preds = %32
%36 = load i1, i1* @print_json_restart.sep
br i1 %36, label %37, label %39
37: ; preds = %35
%38 = tail call i32 @putchar(i32 10)
store i1 false, i1* @print_json_restart.sep
br label %39
39: ; preds = %37, %35
%40 = load i32, i32* %0
%41 = add nsw i32 %40, -1
store i32 %41, i32* %0
%42 = tail call i32 @xprintf0(i32 %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %43
43: ; preds = %39, %32
ret void
}