#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 activity {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ xprintf(int, char *);
int /*<<< orphan*/ xprintf0(int, char *);
void print_json_statistics(int *tab, int action, struct activity *act[],
                           unsigned int id_seq[]) {
  static int sep = 0;
  if (action & 0x01) {
    printf(",\n");
    xprintf((*tab)++, "\"statistics\": [");
  }
  if (action & 0x02) {
    if (sep) {
      xprintf(--(*tab), "},");
    }
    xprintf((*tab)++, "{");
    sep = 1;
  }
  if (action & 0x04) {
    if (sep) {
      xprintf(--(*tab), "}");
      sep = 0;
    }
    xprintf0(--(*tab), "]");
  }
}


x86 assembly (clang, -O0):
<print_json_statistics>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     117b <print_json_statistics+0x4b>
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    %edi,%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
lea    0xe8d(%rip),%rsi
call   1040 <xprintf@plt>
mov    -0xc(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11d1 <print_json_statistics+0xa1>
cmpl   $0x0,0x2eab(%rip)
je     11ae <print_json_statistics+0x7e>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
add    $0xffffffff,%edi
mov    %edi,(%rax)
lea    0xe6a(%rip),%rsi
call   1040 <xprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    %edi,%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
lea    0xe54(%rip),%rsi
call   1040 <xprintf@plt>
movl   $0x1,0x2e6b(%rip)
mov    -0xc(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1225 <print_json_statistics+0xf5>
cmpl   $0x0,0x2e55(%rip)
je     120e <print_json_statistics+0xde>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
add    $0xffffffff,%edi
mov    %edi,(%rax)
lea    0xe19(%rip),%rsi
call   1040 <xprintf@plt>
movl   $0x0,0x2e2e(%rip)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
add    $0xffffffff,%edi
mov    %edi,(%rax)
lea    0xdfa(%rip),%rsi
call   1050 <xprintf0@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_json_statistics>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
test   $0x1,%bpl
jne    1151 <print_json_statistics+0x21>
test   $0x2,%bpl
jne    1176 <print_json_statistics+0x46>
test   $0x4,%bpl
jne    11b2 <print_json_statistics+0x82>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%edi
lea    0x1(%rdi),%eax
mov    %eax,(%rbx)
lea    0xe95(%rip),%rsi
call   1040 <xprintf@plt>
test   $0x2,%bpl
je     1144 <print_json_statistics+0x14>
cmpb   $0x1,0x2ebf(%rip)
jne    1192 <print_json_statistics+0x62>
mov    (%rbx),%edi
add    $0xffffffff,%edi
mov    %edi,(%rbx)
lea    0xe83(%rip),%rsi
call   1040 <xprintf@plt>
mov    (%rbx),%edi
lea    0x1(%rdi),%eax
mov    %eax,(%rbx)
lea    0xe73(%rip),%rsi
call   1040 <xprintf@plt>
movb   $0x1,0x2e90(%rip)
test   $0x4,%bpl
je     114a <print_json_statistics+0x1a>
cmpb   $0x1,0x2e83(%rip)
jne    11d5 <print_json_statistics+0xa5>
mov    (%rbx),%edi
add    $0xffffffff,%edi
mov    %edi,(%rbx)
lea    0xe4c(%rip),%rsi
call   1040 <xprintf@plt>
movb   $0x0,0x2e67(%rip)
mov    (%rbx),%edi
add    $0xffffffff,%edi
mov    %edi,(%rbx)
lea    0xe34(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <xprintf0@plt>

LLVM IR (-O0):
%struct.activity = type { i32 }
@print_json_statistics.sep = internal global i32 0
@.str = [3 x i8] c",\0A\00"
@.str.1 = [16 x i8] c"\22statistics\22: [\00"
@.str.2 = [3 x i8] c"},\00"
@.str.3 = [2 x i8] c"{\00"
@.str.4 = [2 x i8] c"}\00"
@.str.5 = [2 x i8] c"]\00"
define void @print_json_statistics(i32* %0, i32 %1, %struct.activity** %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca %struct.activity**
%8 = alloca i32*
store i32* %0, i32** %5
store i32 %1, i32* %6
store %struct.activity** %2, %struct.activity*** %7
store i32* %3, i32** %8
%9 = load i32, i32* %6
%10 = and i32 %9, 1
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %4
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = load i32*, i32** %5
%15 = load i32, i32* %14
%16 = add nsw i32 %15, 1
store i32 %16, i32* %14
%17 = call i32 @xprintf(i32 %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %12, %4
%19 = load i32, i32* %6
%20 = and i32 %19, 2
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %35
22: ; preds = %18
%23 = load i32, i32* @print_json_statistics.sep
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i32*, i32** %5
%27 = load i32, i32* %26
%28 = add nsw i32 %27, -1
store i32 %28, i32* %26
%29 = call i32 @xprintf(i32 %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %25, %22
%31 = load i32*, i32** %5
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
store i32 %33, i32* %31
%34 = call i32 @xprintf(i32 %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* @print_json_statistics.sep
br label %35
35: ; preds = %30, %18
%36 = load i32, i32* %6
%37 = and i32 %36, 4
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %52
39: ; preds = %35
%40 = load i32, i32* @print_json_statistics.sep
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %39
%43 = load i32*, i32** %5
%44 = load i32, i32* %43
%45 = add nsw i32 %44, -1
store i32 %45, i32* %43
%46 = call i32 @xprintf(i32 %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* @print_json_statistics.sep
br label %47
47: ; preds = %42, %39
%48 = load i32*, i32** %5
%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.5, i64 0, i64 0))
br label %52
52: ; preds = %47, %35
ret void
}

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