#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*/ fprintf(int /*<<< orphan*/ *, char *, long long);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite_base32hex(char *, int, int /*<<< orphan*/ *);
int begin_key(void *ctx, int type, char *key, int keylen,
              long long expiretime) {
  FILE *fp = ctx;
  fputs("{\"key\":", fp);
  fwrite_base32hex(key, keylen, fp);
  fprintf(fp, " ,\"expire\":%lld,", expiretime);
  switch (type) {
  case 's':
    fputs("\"type\":\"string\",\"value\":", fp);
    break;
  case 'l':
    fputs("\"type\":\"list\",\"value\":[", fp);
    break;
  case 'S':
    fputs("\"type\":\"set\",\"value\":[", fp);
    break;
  case 'z':
    fputs("\"type\":\"zset\",\"value\":[", fp);
    break;
  case 'h':
    fputs("\"type\":\"hash\",\"value\":[", fp);
    break;
  case 't':
    fputs("\"type\":\"sss\",\"value\":[", fp);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<begin_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xf43(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1050 <fwrite_base32hex@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xf27(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffad,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x27,%eax
ja     1228 <begin_key+0xf8>
mov    -0x38(%rbp),%rax
lea    0xe5a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x30(%rbp),%rsi
lea    0xeff(%rip),%rdi
call   1030 <fputs@plt>
jmp    1228 <begin_key+0xf8>
mov    -0x30(%rbp),%rsi
lea    0xf03(%rip),%rdi
call   1030 <fputs@plt>
jmp    1228 <begin_key+0xf8>
mov    -0x30(%rbp),%rsi
lea    0xf06(%rip),%rdi
call   1030 <fputs@plt>
jmp    1228 <begin_key+0xf8>
mov    -0x30(%rbp),%rsi
lea    0xf08(%rip),%rdi
call   1030 <fputs@plt>
jmp    1228 <begin_key+0xf8>
mov    -0x30(%rbp),%rsi
lea    0xf0b(%rip),%rdi
call   1030 <fputs@plt>
jmp    1228 <begin_key+0xf8>
mov    -0x30(%rbp),%rsi
lea    0xf0e(%rip),%rdi
call   1030 <fputs@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<begin_key>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%r15
mov    %ecx,%r12d
mov    %rdx,%rbp
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xf53(%rip),%rdi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fwrite@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r14,%rdx
call   1040 <fwrite_base32hex@plt>
lea    0xf34(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
call   1030 <fprintf@plt>
add    $0xffffffad,%ebx
cmp    $0x27,%ebx
ja     11e7 <begin_key+0xb7>
lea    0xe72(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xf4c(%rip),%rdi
jmp    11c7 <begin_key+0x97>
lea    0xf72(%rip),%rdi
jmp    11d5 <begin_key+0xa5>
lea    0xf22(%rip),%rdi
jmp    11d5 <begin_key+0xa5>
lea    0xf00(%rip),%rdi
mov    $0x18,%esi
jmp    11da <begin_key+0xaa>
lea    0xf6a(%rip),%rdi
mov    $0x16,%esi
jmp    11da <begin_key+0xaa>
lea    0xf2c(%rip),%rdi
mov    $0x17,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fwrite@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"{\22key\22:\00"
@.str.1 = [17 x i8] c" ,\22expire\22:%lld,\00"
@.str.2 = [25 x i8] c"\22type\22:\22string\22,\22value\22:\00"
@.str.3 = [24 x i8] c"\22type\22:\22list\22,\22value\22:[\00"
@.str.4 = [23 x i8] c"\22type\22:\22set\22,\22value\22:[\00"
@.str.5 = [24 x i8] c"\22type\22:\22zset\22,\22value\22:[\00"
@.str.6 = [24 x i8] c"\22type\22:\22hash\22,\22value\22:[\00"
@.str.7 = [23 x i8] c"\22type\22:\22sss\22,\22value\22:[\00"
define i32 @begin_key(i8* %0, i32 %1, i8* %2, i32 %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i64
%11 = alloca i32*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i64 %4, i64* %10
%12 = load i8*, i8** %6
%13 = bitcast i8* %12 to i32*
store i32* %13, i32** %11
%14 = load i32*, i32** %11
%15 = call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %14)
%16 = load i8*, i8** %8
%17 = load i32, i32* %9
%18 = load i32*, i32** %11
%19 = call i32 @fwrite_base32hex(i8* %16, i32 %17, i32* %18)
%20 = load i32*, i32** %11
%21 = load i64, i64* %10
%22 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i64 %21)
%23 = load i32, i32* %7
switch i32 %23, label %42 [
i32 115, label %24
i32 108, label %27
i32 83, label %30
i32 122, label %33
i32 104, label %36
i32 116, label %39
]
24: ; preds = %5
%25 = load i32*, i32** %11
%26 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32* %25)
br label %42
27: ; preds = %5
%28 = load i32*, i32** %11
%29 = call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32* %28)
br label %42
30: ; preds = %5
%31 = load i32*, i32** %11
%32 = call i32 @fputs(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32* %31)
br label %42
33: ; preds = %5
%34 = load i32*, i32** %11
%35 = call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32* %34)
br label %42
36: ; preds = %5
%37 = load i32*, i32** %11
%38 = call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32* %37)
br label %42
39: ; preds = %5
%40 = load i32*, i32** %11
%41 = call i32 @fputs(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32* %40)
br label %42
42: ; preds = %5, %39, %36, %33, %30, %27, %24
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"{\22key\22:\00"
@.str.1 = [17 x i8] c" ,\22expire\22:%lld,\00"
@.str.2 = [25 x i8] c"\22type\22:\22string\22,\22value\22:\00"
@.str.3 = [24 x i8] c"\22type\22:\22list\22,\22value\22:[\00"
@.str.4 = [23 x i8] c"\22type\22:\22set\22,\22value\22:[\00"
@.str.5 = [24 x i8] c"\22type\22:\22zset\22,\22value\22:[\00"
@.str.6 = [24 x i8] c"\22type\22:\22hash\22,\22value\22:[\00"
@.str.7 = [23 x i8] c"\22type\22:\22sss\22,\22value\22:[\00"
define i32 @begin_key(i8* %0, i32 %1, i8* %2, i32 %3, i64 %4) {
%6 = bitcast i8* %0 to i32*
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 7, i64 1, i32* %6)
%8 = tail call i32 @fwrite_base32hex(i8* %2, i32 %3, i32* %6)
%9 = tail call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i64 %4)
switch i32 %1, label %22 [
i32 115, label %10
i32 108, label %12
i32 83, label %14
i32 122, label %16
i32 104, label %18
i32 116, label %20
]
10: ; preds = %5
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i64 24, i64 1, i32* %6)
br label %22
12: ; preds = %5
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i64 23, i64 1, i32* %6)
br label %22
14: ; preds = %5
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i64 22, i64 1, i32* %6)
br label %22
16: ; preds = %5
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i64 23, i64 1, i32* %6)
br label %22
18: ; preds = %5
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i64 23, i64 1, i32* %6)
br label %22
20: ; preds = %5
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i64 22, i64 1, i32* %6)
br label %22
22: ; preds = %5, %20, %18, %16, %14, %12, %10
ret i32 0
}