#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite_repr(char *, int, int /*<<< orphan*/ *);
int begin_sss_collection(void *ctx, char *ks, int kslen, char *svc, int svclen,
                         char *key, int keylen, int mode) {
  FILE *fp = ctx;
  fputs("{\"ks\":", fp);
  fwrite_repr(ks, kslen, fp);
  fputs(",\"svc\":", fp);
  fwrite_repr(svc, svclen, fp);
  fputs(",\"key\":", fp);
  fwrite_repr(key, keylen, fp);
  if (mode == 'l') {
    fputs(",\"mode\":\"list\",\"value\":[", fp);
  } else {
    fputs(",\"mode\":\"set\",\"value\":[", fp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<begin_sss_collection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xea8(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x38(%rbp),%rdx
call   1040 <fwrite_repr@plt>
mov    -0x38(%rbp),%rsi
lea    0xe8f(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x38(%rbp),%rdx
call   1040 <fwrite_repr@plt>
mov    -0x38(%rbp),%rsi
lea    0xe77(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x30(%rbp),%rdi
mov    0x10(%rbp),%esi
mov    -0x38(%rbp),%rdx
call   1040 <fwrite_repr@plt>
cmpl   $0x6c,0x18(%rbp)
jne    11cc <begin_sss_collection+0xac>
mov    -0x38(%rbp),%rsi
lea    0xe55(%rip),%rdi
call   1030 <fputs@plt>
jmp    11dc <begin_sss_collection+0xbc>
mov    -0x38(%rbp),%rsi
lea    0xe59(%rip),%rdi
call   1030 <fputs@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<begin_sss_collection>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8d,%r12d
mov    %rcx,%r13
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xebd(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fwrite@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1040 <fwrite_repr@plt>
lea    0xe9e(%rip),%rdi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fwrite@plt>
mov    %r13,%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
call   1040 <fwrite_repr@plt>
lea    0xe7f(%rip),%rdi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fwrite@plt>
mov    %r14,%rdi
mov    0x40(%rsp),%esi
mov    %rbx,%rdx
call   1040 <fwrite_repr@plt>
cmpl   $0x6c,0x48(%rsp)
jne    11c6 <begin_sss_collection+0xa6>
lea    0xe58(%rip),%rdi
mov    $0x18,%esi
jmp    11d2 <begin_sss_collection+0xb2>
lea    0xe63(%rip),%rdi
mov    $0x17,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fwrite@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"{\22ks\22:\00"
@.str.1 = [8 x i8] c",\22svc\22:\00"
@.str.2 = [8 x i8] c",\22key\22:\00"
@.str.3 = [25 x i8] c",\22mode\22:\22list\22,\22value\22:[\00"
@.str.4 = [24 x i8] c",\22mode\22:\22set\22,\22value\22:[\00"
define i32 @begin_sss_collection(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4, i8* %5, i32 %6, i32 %7) {
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
store i8* %0, i8** %9
store i8* %1, i8** %10
store i32 %2, i32* %11
store i8* %3, i8** %12
store i32 %4, i32* %13
store i8* %5, i8** %14
store i32 %6, i32* %15
store i32 %7, i32* %16
%18 = load i8*, i8** %9
%19 = bitcast i8* %18 to i32*
store i32* %19, i32** %17
%20 = load i32*, i32** %17
%21 = call i32 @fputs(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %20)
%22 = load i8*, i8** %10
%23 = load i32, i32* %11
%24 = load i32*, i32** %17
%25 = call i32 @fwrite_repr(i8* %22, i32 %23, i32* %24)
%26 = load i32*, i32** %17
%27 = call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %26)
%28 = load i8*, i8** %12
%29 = load i32, i32* %13
%30 = load i32*, i32** %17
%31 = call i32 @fwrite_repr(i8* %28, i32 %29, i32* %30)
%32 = load i32*, i32** %17
%33 = call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* %32)
%34 = load i8*, i8** %14
%35 = load i32, i32* %15
%36 = load i32*, i32** %17
%37 = call i32 @fwrite_repr(i8* %34, i32 %35, i32* %36)
%38 = load i32, i32* %16
%39 = icmp eq i32 %38, 108
br i1 %39, label %40, label %43
40: ; preds = %8
%41 = load i32*, i32** %17
%42 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32* %41)
br label %46
43: ; preds = %8
%44 = load i32*, i32** %17
%45 = call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32* %44)
br label %46
46: ; preds = %43, %40
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"{\22ks\22:\00"
@.str.1 = [8 x i8] c",\22svc\22:\00"
@.str.2 = [8 x i8] c",\22key\22:\00"
@.str.3 = [25 x i8] c",\22mode\22:\22list\22,\22value\22:[\00"
@.str.4 = [24 x i8] c",\22mode\22:\22set\22,\22value\22:[\00"
define i32 @begin_sss_collection(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4, i8* %5, i32 %6, i32 %7) {
%9 = bitcast i8* %0 to i32*
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 6, i64 1, i32* %9)
%11 = tail call i32 @fwrite_repr(i8* %1, i32 %2, i32* %9)
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 7, i64 1, i32* %9)
%13 = tail call i32 @fwrite_repr(i8* %3, i32 %4, i32* %9)
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 7, i64 1, i32* %9)
%15 = tail call i32 @fwrite_repr(i8* %5, i32 %6, i32* %9)
%16 = icmp eq i32 %7, 108
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64 24, i64 1, i32* %9)
br label %21
19: ; preds = %8
%20 = tail call i64 @fwrite(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i64 23, i64 1, i32* %9)
br label %21
21: ; preds = %19, %17
ret i32 0
}