#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_comment(int *tab, int action, char *cur_date, char *cur_time,
                        int utc, char *comment, struct file_header *file_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    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     1189 <print_json_comment+0x59>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    %edi,%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
lea    0xe81(%rip),%rsi
mov    $0x0,%al
call   1040 <xprintf@plt>
mov    -0xc(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     121f <print_json_comment+0xef>
cmpl   $0x0,0x2e9d(%rip)
je     11b1 <print_json_comment+0x81>
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    %edi,%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
lea    0xe4c(%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    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1040 <xprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
add    $0xffffffff,%edi
mov    %edi,(%rax)
lea    0xe41(%rip),%rsi
call   1050 <xprintf0@plt>
movl   $0x1,0x2e1d(%rip)
mov    -0xc(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1268 <print_json_comment+0x138>
cmpl   $0x0,0x2e07(%rip)
je     1251 <print_json_comment+0x121>
lea    0xdbf(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,0x2deb(%rip)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
add    $0xffffffff,%edi
mov    %edi,(%rax)
lea    0xdf0(%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 }
@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) {
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca %struct.file_header*
store i32* %0, i32** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i8* %5, i8** %13
store %struct.file_header* %6, %struct.file_header** %14
%15 = load i32, i32* %9
%16 = and i32 %15, 1
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %7
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = load i32*, i32** %8
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
store i32 %22, i32* %20
%23 = call i32 (i32, i8*, ...) @xprintf(i32 %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %18, %7
%25 = load i32, i32* %9
%26 = and i32 %25, 2
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %52
28: ; preds = %24
%29 = load i32, i32* @print_json_comment.sep
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %33
33: ; preds = %31, %28
%34 = load i32*, i32** %8
%35 = load i32, i32* %34
%36 = add nsw i32 %35, 1
store i32 %36, i32* %34
%37 = call i32 (i32, i8*, ...) @xprintf(i32 %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%38 = load i32*, i32** %8
%39 = load i32, i32* %38
%40 = load i8*, i8** %10
%41 = load i8*, i8** %11
%42 = load i32, i32* %12
%43 = icmp ne i32 %42, 0
%44 = zext i1 %43 to i64
%45 = select i1 %43, i32 1, i32 0
%46 = load i8*, i8** %13
%47 = call i32 (i32, i8*, ...) @xprintf(i32 %39, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i8* %40, i8* %41, i32 %45, i8* %46)
%48 = load i32*, i32** %8
%49 = load i32, i32* %48
%50 = add nsw i32 %49, -1
store i32 %50, i32* %48
%51 = call i32 @xprintf0(i32 %50, 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 %52
52: ; preds = %33, %24
%53 = load i32, i32* %9
%54 = and i32 %53, 4
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %66
56: ; preds = %52
%57 = load i32, i32* @print_json_comment.sep
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = 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 %61
61: ; preds = %59, %56
%62 = load i32*, i32** %8
%63 = load i32, i32* %62
%64 = add nsw i32 %63, -1
store i32 %64, i32* %62
%65 = call i32 @xprintf0(i32 %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %66
66: ; preds = %61, %52
ret void
}

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