#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*/ SEEK_CUR;
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int end_key(void *ctx, int type) {
  FILE *fp = ctx;
  fseek(fp, -1, SEEK_CUR);
  switch (type) {
  case 's':
    fputs("\"}\n", fp);
    break;
  case 'l':
  case 'S':
  case 'z':
  case 'h':
  case 't':
    fputs("]}\n", fp);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<end_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2ea6(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%esi
call   1040 <fseek@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x53,%eax
je     11cc <end_key+0xac>
jmp    1162 <end_key+0x42>
mov    -0x1c(%rbp),%eax
sub    $0x68,%eax
je     11cc <end_key+0xac>
jmp    1173 <end_key+0x53>
mov    -0x1c(%rbp),%eax
sub    $0x6c,%eax
je     11cc <end_key+0xac>
jmp    1184 <end_key+0x64>
mov    -0x1c(%rbp),%eax
sub    $0x73,%eax
je     11b7 <end_key+0x97>
jmp    1195 <end_key+0x75>
mov    -0x1c(%rbp),%eax
sub    $0x74,%eax
je     11cc <end_key+0xac>
jmp    11a6 <end_key+0x86>
mov    -0x1c(%rbp),%eax
sub    $0x7a,%eax
je     11cc <end_key+0xac>
jmp    11dc <end_key+0xbc>
mov    -0x18(%rbp),%rsi
lea    0xe3e(%rip),%rdi
call   1030 <fputs@plt>
jmp    11dc <end_key+0xbc>
mov    -0x18(%rbp),%rsi
lea    0xe2d(%rip),%rdi
call   1030 <fputs@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<end_key>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
mov    0x2eb8(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%esi
call   1030 <fseek@plt>
add    $0xffffffad,%ebx
cmp    $0x27,%ebx
ja     116d <end_key+0x4d>
movabs $0x8202200001,%rax
bt     %rbx,%rax
jae    1177 <end_key+0x57>
lea    0xea9(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fwrite@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
cmp    $0x20,%rbx
jne    116d <end_key+0x4d>
lea    0xe7c(%rip),%rdi
jmp    115b <end_key+0x3b>

LLVM IR (-O0):
@SEEK_CUR = global i32 0
@.str = [4 x i8] c"\22}\0A\00"
@.str.1 = [4 x i8] c"]}\0A\00"
define i32 @end_key(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = bitcast i8* %6 to i32*
store i32* %7, i32** %5
%8 = load i32*, i32** %5
%9 = load i32, i32* @SEEK_CUR
%10 = call i32 @fseek(i32* %8, i32 -1, i32 %9)
%11 = load i32, i32* %4
switch i32 %11, label %18 [
i32 115, label %12
i32 108, label %15
i32 83, label %15
i32 122, label %15
i32 104, label %15
i32 116, label %15
]
12: ; preds = %2
%13 = load i32*, i32** %5
%14 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %13)
br label %18
15: ; preds = %2, %2, %2, %2, %2
%16 = load i32*, i32** %5
%17 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %16)
br label %18
18: ; preds = %2, %15, %12
ret i32 0
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
@.str = [4 x i8] c"\22}\0A\00"
@.str.1 = [4 x i8] c"]}\0A\00"
define i32 @end_key(i8* nocapture %0, i32 %1) {
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* @SEEK_CUR
%5 = tail call i32 @fseek(i32* %3, i32 -1, i32 %4)
switch i32 %1, label %10 [
i32 115, label %7
i32 108, label %6
i32 83, label %6
i32 122, label %6
i32 104, label %6
i32 116, label %6
]
6: ; preds = %2, %2, %2, %2, %2
br label %7
7: ; preds = %2, %6
%8 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %6 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %2 ]
%9 = tail call i64 @fwrite(i8* %8, i64 3, i64 1, i32* %3)
br label %10
10: ; preds = %7, %2
ret i32 0
}