#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 record_header {
  int dummy;
};
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_comment(int *tab, int action, char *cur_date, char *cur_time,
                        int utc, char *comment, struct file_header *file_hdr,
                        struct record_header *record_hdr) {
  static int sep = 0;
  if (action & 0x01) {
    printf(",\n");
    xprintf((*tab)++, "\"comments\": [");
  }
  if (action & 0x02) {
    if (sep) {
      printf(",\n");
    }
    xprintf((*tab)++, "{");
    xprintf(*tab,
            "\"comment\": {\"date\": \"%s\", \"time\": \"%s\", "
            "\"utc\": %d, \"com\": \"%s\"}",
            cur_date, cur_time, utc ? 1 : 0, comment);
    xprintf0(--(*tab), "}");
    sep = 1;
  }
  if (action & 0x04) {
    if (sep) {
      printf("\n");
      sep = 0;
    }
    xprintf0(--(*tab), "]");
  }
}


x86 assembly (clang, -O0):
<print_json_comment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
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     118d <print_json_comment+0x5d>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    %edi,%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1040 <xprintf@plt>
mov    -0xc(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1223 <print_json_comment+0xf3>
cmpl   $0x0,0x2e99(%rip)
je     11b5 <print_json_comment+0x85>
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    %edi,%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
lea    0xe48(%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
mov    -0x30(%rbp),%r9
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1040 <xprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
add    $0xffffffff,%edi
mov    %edi,(%rax)
lea    0xe3d(%rip),%rsi
call   1050 <xprintf0@plt>
movl   $0x1,0x2e19(%rip)
mov    -0xc(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     126c <print_json_comment+0x13c>
cmpl   $0x0,0x2e03(%rip)
je     1255 <print_json_comment+0x125>
lea    0xdbb(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,0x2de7(%rip)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
add    $0xffffffff,%edi
mov    %edi,(%rax)
lea    0xdec(%rip),%rsi
call   1050 <xprintf0@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_json_comment>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8d,%r13d
mov    %rcx,%r15
mov    %rdx,%r12
mov    %esi,%ebp
mov    %rdi,%rbx
test   $0x1,%bpl
jne    1181 <print_json_comment+0x41>
test   $0x2,%bpl
jne    11a8 <print_json_comment+0x68>
test   $0x4,%bpl
jne    1219 <print_json_comment+0xd9>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xeca(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%edi
lea    0x1(%rdi),%eax
mov    %eax,(%rbx)
lea    0xe65(%rip),%rsi
xor    %eax,%eax
call   1050 <xprintf@plt>
test   $0x2,%bpl
je     1168 <print_json_comment+0x28>
cmpb   $0x1,0x2e95(%rip)
jne    11bd <print_json_comment+0x7d>
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%edi
lea    0x1(%rdi),%eax
mov    %eax,(%rbx)
lea    0xe43(%rip),%rsi
xor    %eax,%eax
call   1050 <xprintf@plt>
mov    (%rbx),%edi
xor    %r8d,%r8d
test   %r13d,%r13d
setne  %r8b
lea    0xe2b(%rip),%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r9
xor    %eax,%eax
call   1050 <xprintf@plt>
mov    (%rbx),%edi
add    $0xffffffff,%edi
mov    %edi,(%rbx)
lea    0xe4b(%rip),%rsi
call   1060 <xprintf0@plt>
movb   $0x1,0x2e35(%rip)
test   $0x4,%bpl
je     1172 <print_json_comment+0x32>
cmpb   $0x1,0x2e24(%rip)
jne    1233 <print_json_comment+0xf3>
mov    $0xa,%edi
call   1030 <putchar@plt>
movb   $0x0,0x2e11(%rip)
mov    (%rbx),%edi
add    $0xffffffff,%edi
mov    %edi,(%rbx)
lea    0xe0f(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <xprintf0@plt>

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

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