#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 */
char *createFixedStr(char *, int);
char *lowerCharToUnicode(char, size_t *);
char *encodeControlChar(char c, size_t *len) {
  if (c == '"') {
    *len = 2;
    return createFixedStr("\\\"", 2);
  } else if (c == '\\') {
    *len = 2;
    return createFixedStr("\\\\", 2);
  } else if (c == '/') {
    *len = 2;
    return createFixedStr("\\/", 2);
  } else if (c == '\b') {
    *len = 2;
    return createFixedStr("\\b", 2);
  } else if (c == '\f') {
    *len = 2;
    return createFixedStr("\\f", 2);
  } else if (c == '\n') {
    *len = 2;
    return createFixedStr("\\n", 2);
  } else if (c == '\r') {
    *len = 2;
    return createFixedStr("\\r", 2);
  } else if (c == '\t') {
    *len = 2;
    return createFixedStr("\\t", 2);
  } else {
    return lowerCharToUnicode(c, len);
  }
}


x86 assembly (clang, -O0):
<encodeControlChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
mov    %rsi,-0x18(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x22,%eax
jne    1164 <encodeControlChar+0x44>
mov    -0x18(%rbp),%rax
movq   $0x2,(%rax)
lea    0xeaf(%rip),%rdi
mov    $0x2,%esi
call   1030 <createFixedStr@plt>
mov    %rax,-0x8(%rbp)
jmp    12d5 <encodeControlChar+0x1b5>
movsbl -0x9(%rbp),%eax
cmp    $0x5c,%eax
jne    1196 <encodeControlChar+0x76>
mov    -0x18(%rbp),%rax
movq   $0x2,(%rax)
lea    0xe80(%rip),%rdi
mov    $0x2,%esi
call   1030 <createFixedStr@plt>
mov    %rax,-0x8(%rbp)
jmp    12d5 <encodeControlChar+0x1b5>
movsbl -0x9(%rbp),%eax
cmp    $0x2f,%eax
jne    11c8 <encodeControlChar+0xa8>
mov    -0x18(%rbp),%rax
movq   $0x2,(%rax)
lea    0xe51(%rip),%rdi
mov    $0x2,%esi
call   1030 <createFixedStr@plt>
mov    %rax,-0x8(%rbp)
jmp    12d5 <encodeControlChar+0x1b5>
movsbl -0x9(%rbp),%eax
cmp    $0x8,%eax
jne    11fa <encodeControlChar+0xda>
mov    -0x18(%rbp),%rax
movq   $0x2,(%rax)
lea    0xe22(%rip),%rdi
mov    $0x2,%esi
call   1030 <createFixedStr@plt>
mov    %rax,-0x8(%rbp)
jmp    12d5 <encodeControlChar+0x1b5>
movsbl -0x9(%rbp),%eax
cmp    $0xc,%eax
jne    122c <encodeControlChar+0x10c>
mov    -0x18(%rbp),%rax
movq   $0x2,(%rax)
lea    0xdf3(%rip),%rdi
mov    $0x2,%esi
call   1030 <createFixedStr@plt>
mov    %rax,-0x8(%rbp)
jmp    12d5 <encodeControlChar+0x1b5>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
jne    125e <encodeControlChar+0x13e>
mov    -0x18(%rbp),%rax
movq   $0x2,(%rax)
lea    0xdc4(%rip),%rdi
mov    $0x2,%esi
call   1030 <createFixedStr@plt>
mov    %rax,-0x8(%rbp)
jmp    12d5 <encodeControlChar+0x1b5>
movsbl -0x9(%rbp),%eax
cmp    $0xd,%eax
jne    1290 <encodeControlChar+0x170>
mov    -0x18(%rbp),%rax
movq   $0x2,(%rax)
lea    0xd95(%rip),%rdi
mov    $0x2,%esi
call   1030 <createFixedStr@plt>
mov    %rax,-0x8(%rbp)
jmp    12d5 <encodeControlChar+0x1b5>
movsbl -0x9(%rbp),%eax
cmp    $0x9,%eax
jne    12c2 <encodeControlChar+0x1a2>
mov    -0x18(%rbp),%rax
movq   $0x2,(%rax)
lea    0xd66(%rip),%rdi
mov    $0x2,%esi
call   1030 <createFixedStr@plt>
mov    %rax,-0x8(%rbp)
jmp    12d5 <encodeControlChar+0x1b5>
mov    -0x9(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1040 <lowerCharToUnicode@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encodeControlChar>:
lea    -0x8(%rdi),%eax
cmp    $0x27,%al
ja     1152 <encodeControlChar+0x32>
movzbl %al,%eax
lea    0xecf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movq   $0x2,(%rsi)
lea    0xf61(%rip),%rdi
mov    $0x2,%esi
jmp    1030 <createFixedStr@plt>
cmp    $0x5c,%dil
jne    1170 <encodeControlChar+0x50>
movq   $0x2,(%rsi)
lea    0xf3d(%rip),%rdi
mov    $0x2,%esi
jmp    1030 <createFixedStr@plt>
movsbl %dil,%edi
jmp    1040 <lowerCharToUnicode@plt>
movq   $0x2,(%rsi)
lea    0xf2e(%rip),%rdi
mov    $0x2,%esi
jmp    1030 <createFixedStr@plt>
movq   $0x2,(%rsi)
lea    0xf10(%rip),%rdi
mov    $0x2,%esi
jmp    1030 <createFixedStr@plt>
movq   $0x2,(%rsi)
lea    0xef5(%rip),%rdi
mov    $0x2,%esi
jmp    1030 <createFixedStr@plt>
movq   $0x2,(%rsi)
lea    0xee3(%rip),%rdi
mov    $0x2,%esi
jmp    1030 <createFixedStr@plt>
movq   $0x2,(%rsi)
lea    0xeb9(%rip),%rdi
mov    $0x2,%esi
jmp    1030 <createFixedStr@plt>
movq   $0x2,(%rsi)
lea    0xea7(%rip),%rdi
mov    $0x2,%esi
jmp    1030 <createFixedStr@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"\\\22\00"
@.str.1 = [3 x i8] c"\\\\\00"
@.str.2 = [3 x i8] c"\\/\00"
@.str.3 = [3 x i8] c"\\b\00"
@.str.4 = [3 x i8] c"\\f\00"
@.str.5 = [3 x i8] c"\\n\00"
@.str.6 = [3 x i8] c"\\r\00"
@.str.7 = [3 x i8] c"\\t\00"
define i8* @encodeControlChar(i8 signext %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i64*
store i8 %0, i8* %4
store i64* %1, i64** %5
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 34
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i64*, i64** %5
store i64 2, i64* %10
%11 = call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
store i8* %11, i8** %3
br label %65
12: ; preds = %2
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 92
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i64*, i64** %5
store i64 2, i64* %17
%18 = call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
store i8* %18, i8** %3
br label %65
19: ; preds = %12
%20 = load i8, i8* %4
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 47
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i64*, i64** %5
store i64 2, i64* %24
%25 = call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
store i8* %25, i8** %3
br label %65
26: ; preds = %19
%27 = load i8, i8* %4
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 8
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i64*, i64** %5
store i64 2, i64* %31
%32 = call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
store i8* %32, i8** %3
br label %65
33: ; preds = %26
%34 = load i8, i8* %4
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 12
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i64*, i64** %5
store i64 2, i64* %38
%39 = call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
store i8* %39, i8** %3
br label %65
40: ; preds = %33
%41 = load i8, i8* %4
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 10
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i64*, i64** %5
store i64 2, i64* %45
%46 = call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
store i8* %46, i8** %3
br label %65
47: ; preds = %40
%48 = load i8, i8* %4
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 13
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = load i64*, i64** %5
store i64 2, i64* %52
%53 = call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 2)
store i8* %53, i8** %3
br label %65
54: ; preds = %47
%55 = load i8, i8* %4
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 9
br i1 %57, label %58, label %61
58: ; preds = %54
%59 = load i64*, i64** %5
store i64 2, i64* %59
%60 = call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
store i8* %60, i8** %3
br label %65
61: ; preds = %54
%62 = load i8, i8* %4
%63 = load i64*, i64** %5
%64 = call i8* @lowerCharToUnicode(i8 signext %62, i64* %63)
store i8* %64, i8** %3
br label %65
65: ; preds = %61, %58, %51, %44, %37, %30, %23, %16, %9
%66 = load i8*, i8** %3
ret i8* %66
}

LLVM IR (-O2):
@.str = [3 x i8] c"\\\22\00"
@.str.1 = [3 x i8] c"\\\\\00"
@.str.2 = [3 x i8] c"\\/\00"
@.str.3 = [3 x i8] c"\\b\00"
@.str.4 = [3 x i8] c"\\f\00"
@.str.5 = [3 x i8] c"\\n\00"
@.str.6 = [3 x i8] c"\\r\00"
@.str.7 = [3 x i8] c"\\t\00"
define i8* @encodeControlChar(i8 signext %0, i64* %1) {
switch i8 %0, label %19 [
i8 34, label %3
i8 92, label %5
i8 47, label %7
i8 8, label %9
i8 12, label %11
i8 10, label %13
i8 13, label %15
i8 9, label %17
]
3: ; preds = %2
store i64 2, i64* %1
%4 = tail call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
br label %21
5: ; preds = %2
store i64 2, i64* %1
%6 = tail call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %21
7: ; preds = %2
store i64 2, i64* %1
%8 = tail call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
br label %21
9: ; preds = %2
store i64 2, i64* %1
%10 = tail call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
br label %21
11: ; preds = %2
store i64 2, i64* %1
%12 = tail call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
br label %21
13: ; preds = %2
store i64 2, i64* %1
%14 = tail call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 2)
br label %21
15: ; preds = %2
store i64 2, i64* %1
%16 = tail call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 2)
br label %21
17: ; preds = %2
store i64 2, i64* %1
%18 = tail call i8* @createFixedStr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
br label %21
19: ; preds = %2
%20 = tail call i8* @lowerCharToUnicode(i8 signext %0, i64* %1)
br label %21
21: ; preds = %19, %17, %15, %13, %11, %9, %7, %5, %3
%22 = phi i8* [ %4, %3 ], [ %6, %5 ], [ %8, %7 ], [ %10, %9 ], [ %12, %11 ], [ %14, %13 ], [ %16, %15 ], [ %18, %17 ], [ %20, %19 ]
ret i8* %22
}