#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 */

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fputs_unlocked(char *, int /*<<< orphan*/);
scalar_t__ getchar_unlocked();
int /*<<< orphan*/ put_string_char(int);
int /*<<< orphan*/ putchar_unlocked(char);
int readchar();
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ transform_value(int);
void transform_doc(int is_array) {
  for (int i = 0; i < 4; i++) {
    if (getchar_unlocked() == EOF) {
      exit(0);
    }
  }
  putchar_unlocked(is_array ? '[' : '{');
  for (int initial = 1;; initial = 0) {
    int type = readchar();
    if (!type) {
      break;
    }
    if (!initial) {
      putchar_unlocked(',');
    }
    if (!is_array) {
      putchar_unlocked('"');
    }
    int namechar = readchar();
    while (namechar) {
      if (!is_array) {
        put_string_char(namechar);
      }
      namechar = readchar();
    }
    if (!is_array) {
      fputs_unlocked("\":", stdout);
    }
    transform_value(type);
  }
  putchar_unlocked(is_array ? ']' : '}');
}


x86 assembly (clang, -O0):
<transform_doc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11bd <transform_doc+0x4d>
mov    $0x0,%al
call   1050 <getchar_unlocked@plt>
mov    0x2e4e(%rip),%rcx
cmp    (%rcx),%rax
jne    11aa <transform_doc+0x3a>
xor    %edi,%edi
call   1090 <exit@plt>
jmp    11af <transform_doc+0x3f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1182 <transform_doc+0x12>
mov    -0x4(%rbp),%edx
mov    $0x7b,%eax
mov    $0x5b,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1070 <putchar_unlocked@plt>
movl   $0x1,-0xc(%rbp)
mov    $0x0,%al
call   1040 <readchar@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11f8 <transform_doc+0x88>
jmp    1288 <transform_doc+0x118>
cmpl   $0x0,-0xc(%rbp)
jne    120c <transform_doc+0x9c>
mov    $0x2c,%edi
call   1070 <putchar_unlocked@plt>
cmpl   $0x0,-0x4(%rbp)
jne    1220 <transform_doc+0xb0>
mov    $0x22,%edi
call   1070 <putchar_unlocked@plt>
mov    $0x0,%al
call   1040 <readchar@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1255 <transform_doc+0xe5>
cmpl   $0x0,-0x4(%rbp)
jne    1246 <transform_doc+0xd6>
mov    -0x14(%rbp),%edi
call   1080 <put_string_char@plt>
mov    $0x0,%al
call   1040 <readchar@plt>
mov    %eax,-0x14(%rbp)
jmp    122a <transform_doc+0xba>
cmpl   $0x0,-0x4(%rbp)
jne    1274 <transform_doc+0x104>
mov    0x2d72(%rip),%rax
mov    (%rax),%esi
lea    0xd91(%rip),%rdi
call   1060 <fputs_unlocked@plt>
mov    -0x10(%rbp),%edi
call   1030 <transform_value@plt>
movl   $0x0,-0xc(%rbp)
jmp    11df <transform_doc+0x6f>
mov    -0x4(%rbp),%edx
mov    $0x7d,%eax
mov    $0x5d,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1070 <putchar_unlocked@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transform_doc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <getchar_unlocked@plt>
mov    0x2e61(%rip),%rbp
cmp    0x0(%rbp),%rax
je     1284 <transform_doc+0x114>
xor    %eax,%eax
call   1050 <getchar_unlocked@plt>
cmp    0x0(%rbp),%rax
je     1284 <transform_doc+0x114>
xor    %eax,%eax
call   1050 <getchar_unlocked@plt>
cmp    0x0(%rbp),%rax
je     1284 <transform_doc+0x114>
xor    %eax,%eax
call   1050 <getchar_unlocked@plt>
cmp    0x0(%rbp),%rax
je     1284 <transform_doc+0x114>
xor    %edi,%edi
test   %ebx,%ebx
sete   %dil
shl    $0x5,%edi
or     $0x5b,%edi
call   1070 <putchar_unlocked@plt>
xor    %eax,%eax
call   1040 <readchar@plt>
test   %eax,%eax
je     1267 <transform_doc+0xf7>
mov    %eax,%ebp
mov    0x2de9(%rip),%r15
lea    0xe0a(%rip),%r14
xor    %eax,%eax
jmp    1216 <transform_doc+0xa6>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <transform_value@plt>
xor    %eax,%eax
call   1040 <readchar@plt>
mov    %eax,%ebp
mov    $0x1,%al
test   %ebp,%ebp
je     1267 <transform_doc+0xf7>
test   $0x1,%al
jne    1220 <transform_doc+0xb0>
test   %ebx,%ebx
jne    124b <transform_doc+0xdb>
jmp    122e <transform_doc+0xbe>
mov    $0x2c,%edi
call   1070 <putchar_unlocked@plt>
test   %ebx,%ebx
jne    124b <transform_doc+0xdb>
mov    $0x22,%edi
call   1070 <putchar_unlocked@plt>
jmp    124b <transform_doc+0xdb>
nopw   0x0(%rax,%rax,1)
test   %ebx,%ebx
jne    124b <transform_doc+0xdb>
mov    %eax,%edi
call   1080 <put_string_char@plt>
xor    %eax,%eax
call   1040 <readchar@plt>
test   %eax,%eax
jne    1240 <transform_doc+0xd0>
test   %ebx,%ebx
jne    1200 <transform_doc+0x90>
mov    (%r15),%esi
mov    %r14,%rdi
call   1060 <fputs_unlocked@plt>
jmp    1200 <transform_doc+0x90>
xor    %edi,%edi
test   %ebx,%ebx
sete   %dil
shl    $0x5,%edi
or     $0x5d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <putchar_unlocked@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@EOF = global i64 0
@.str = [3 x i8] c"\22:\00"
@stdout = global i32 0
define void @transform_doc(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %7
7: ; preds = %17, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = call i64 (...) @getchar_unlocked()
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %10
br label %17
17: ; preds = %16
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %7
20: ; preds = %7
%21 = load i32, i32* %2
%22 = icmp ne i32 %21, 0
%23 = zext i1 %22 to i64
%24 = select i1 %22, i32 91, i32 123
%25 = trunc i32 %24 to i8
%26 = call i32 @putchar_unlocked(i8 signext %25)
store i32 1, i32* %4
br label %27
27: ; preds = %64, %20
%28 = call i32 (...) @readchar()
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %27
br label %65
32: ; preds = %27
%33 = load i32, i32* %4
%34 = icmp ne i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = call i32 @putchar_unlocked(i8 signext 44)
br label %37
37: ; preds = %35, %32
%38 = load i32, i32* %2
%39 = icmp ne i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = call i32 @putchar_unlocked(i8 signext 34)
br label %42
42: ; preds = %40, %37
%43 = call i32 (...) @readchar()
store i32 %43, i32* %6
br label %44
44: ; preds = %53, %42
%45 = load i32, i32* %6
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %55
47: ; preds = %44
%48 = load i32, i32* %2
%49 = icmp ne i32 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %47
%51 = load i32, i32* %6
%52 = call i32 @put_string_char(i32 %51)
br label %53
53: ; preds = %50, %47
%54 = call i32 (...) @readchar()
store i32 %54, i32* %6
br label %44
55: ; preds = %44
%56 = load i32, i32* %2
%57 = icmp ne i32 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %55
%59 = load i32, i32* @stdout
%60 = call i32 @fputs_unlocked(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %58, %55
%62 = load i32, i32* %5
%63 = call i32 @transform_value(i32 %62)
br label %64
64: ; preds = %61
store i32 0, i32* %4
br label %27
65: ; preds = %31
%66 = load i32, i32* %2
%67 = icmp ne i32 %66, 0
%68 = zext i1 %67 to i64
%69 = select i1 %67, i32 93, i32 125
%70 = trunc i32 %69 to i8
%71 = call i32 @putchar_unlocked(i8 signext %70)
ret void
}

LLVM IR (-O2):
@EOF = global i64 0
@.str = [3 x i8] c"\22:\00"
@stdout = global i32 0
define void @transform_doc(i32 %0) {
%2 = tail call i64 (...) @getchar_unlocked()
%3 = load i64, i64* @EOF
%4 = icmp eq i64 %2, %3
br i1 %4, label %23, label %5
5: ; preds = %1
%6 = tail call i64 (...) @getchar_unlocked()
%7 = load i64, i64* @EOF
%8 = icmp eq i64 %6, %7
br i1 %8, label %23, label %9
9: ; preds = %5
%10 = tail call i64 (...) @getchar_unlocked()
%11 = load i64, i64* @EOF
%12 = icmp eq i64 %10, %11
br i1 %12, label %23, label %13
13: ; preds = %9
%14 = tail call i64 (...) @getchar_unlocked()
%15 = load i64, i64* @EOF
%16 = icmp eq i64 %14, %15
br i1 %16, label %23, label %17
17: ; preds = %13
%18 = icmp eq i32 %0, 0
%19 = select i1 %18, i8 123, i8 91
%20 = tail call i32 @putchar_unlocked(i8 signext %19)
%21 = tail call i32 (...) @readchar()
%22 = icmp eq i32 %21, 0
br i1 %22, label %51, label %25
23: ; preds = %13, %9, %5, %1
%24 = tail call i32 @exit(i32 0)
unreachable
25: ; preds = %17, %47
%26 = phi i32 [ %49, %47 ], [ %21, %17 ]
%27 = phi i1 [ true, %47 ], [ false, %17 ]
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = tail call i32 @putchar_unlocked(i8 signext 44)
br label %30
30: ; preds = %28, %25
br i1 %18, label %31, label %33
31: ; preds = %30
%32 = tail call i32 @putchar_unlocked(i8 signext 34)
br label %33
33: ; preds = %31, %30
%34 = tail call i32 (...) @readchar()
%35 = icmp eq i32 %34, 0
br i1 %35, label %43, label %36
36: ; preds = %33, %40
%37 = phi i32 [ %41, %40 ], [ %34, %33 ]
br i1 %18, label %38, label %40
38: ; preds = %36
%39 = tail call i32 @put_string_char(i32 %37)
br label %40
40: ; preds = %38, %36
%41 = tail call i32 (...) @readchar()
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %36
43: ; preds = %40, %33
br i1 %18, label %44, label %47
44: ; preds = %43
%45 = load i32, i32* @stdout
%46 = tail call i32 @fputs_unlocked(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %44, %43
%48 = tail call i32 @transform_value(i32 %26)
%49 = tail call i32 (...) @readchar()
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %25
51: ; preds = %47, %17
%52 = select i1 %18, i8 125, i8 93
%53 = tail call i32 @putchar_unlocked(i8 signext %52)
ret void
}