#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 */
int /*<<< orphan*/ UPB_ASSERT(int /*<<< orphan*/);
char escape_char(char in) {
  switch (in) {
  case 'r':
    return '\r';
  case 't':
    return '\t';
  case 'n':
    return '\n';
  case 'f':
    return '\f';
  case 'b':
    return '\b';
  case '/':
    return '/';
  case '"':
    return '"';
  case '\\':
    return '\\';
  default:
    UPB_ASSERT(0);
    return 'x';
  }
}


x86 assembly (clang, -O0):
<escape_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x22,%eax
je     11e0 <escape_char+0xd0>
jmp    1133 <escape_char+0x23>
mov    -0x8(%rbp),%eax
sub    $0x2f,%eax
je     11d7 <escape_char+0xc7>
jmp    1144 <escape_char+0x34>
mov    -0x8(%rbp),%eax
sub    $0x5c,%eax
je     11e9 <escape_char+0xd9>
jmp    1155 <escape_char+0x45>
mov    -0x8(%rbp),%eax
sub    $0x62,%eax
je     11ce <escape_char+0xbe>
jmp    1166 <escape_char+0x56>
mov    -0x8(%rbp),%eax
sub    $0x66,%eax
je     11c5 <escape_char+0xb5>
jmp    1177 <escape_char+0x67>
mov    -0x8(%rbp),%eax
sub    $0x6e,%eax
je     11bc <escape_char+0xac>
jmp    1188 <escape_char+0x78>
mov    -0x8(%rbp),%eax
sub    $0x72,%eax
je     11aa <escape_char+0x9a>
jmp    1199 <escape_char+0x89>
mov    -0x8(%rbp),%eax
sub    $0x74,%eax
je     11b3 <escape_char+0xa3>
jmp    11f2 <escape_char+0xe2>
movb   $0xd,-0x1(%rbp)
jmp    11fd <escape_char+0xed>
movb   $0x9,-0x1(%rbp)
jmp    11fd <escape_char+0xed>
movb   $0xa,-0x1(%rbp)
jmp    11fd <escape_char+0xed>
movb   $0xc,-0x1(%rbp)
jmp    11fd <escape_char+0xed>
movb   $0x8,-0x1(%rbp)
jmp    11fd <escape_char+0xed>
movb   $0x2f,-0x1(%rbp)
jmp    11fd <escape_char+0xed>
movb   $0x22,-0x1(%rbp)
jmp    11fd <escape_char+0xed>
movb   $0x5c,-0x1(%rbp)
jmp    11fd <escape_char+0xed>
xor    %edi,%edi
call   1030 <UPB_ASSERT@plt>
movb   $0x78,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<escape_char>:
push   %rax
lea    -0x2f(%rdi),%ecx
cmp    $0x45,%ecx
ja     112f <escape_char+0x1f>
mov    $0xd,%al
lea    0xede(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x2f,%al
pop    %rcx
ret
cmp    $0x22,%edi
jne    1138 <escape_char+0x28>
mov    $0x22,%al
pop    %rcx
ret
xor    %edi,%edi
call   1030 <UPB_ASSERT@plt>
mov    $0x78,%al
pop    %rcx
ret
mov    $0x5c,%al
pop    %rcx
ret
mov    $0x8,%al
pop    %rcx
ret
mov    $0xc,%al
pop    %rcx
ret
mov    $0xa,%al
pop    %rcx
ret
mov    $0x9,%al
pop    %rcx
ret

LLVM IR (-O0):
define signext i8 @escape_char(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %14 [
i32 114, label %6
i32 116, label %7
i32 110, label %8
i32 102, label %9
i32 98, label %10
i32 47, label %11
i32 34, label %12
i32 92, label %13
]
6: ; preds = %1
store i8 13, i8* %2
br label %16
7: ; preds = %1
store i8 9, i8* %2
br label %16
8: ; preds = %1
store i8 10, i8* %2
br label %16
9: ; preds = %1
store i8 12, i8* %2
br label %16
10: ; preds = %1
store i8 8, i8* %2
br label %16
11: ; preds = %1
store i8 47, i8* %2
br label %16
12: ; preds = %1
store i8 34, i8* %2
br label %16
13: ; preds = %1
store i8 92, i8* %2
br label %16
14: ; preds = %1
%15 = call i32 @UPB_ASSERT(i32 0)
store i8 120, i8* %2
br label %16
16: ; preds = %14, %13, %12, %11, %10, %9, %8, %7, %6
%17 = load i8, i8* %2
ret i8 %17
}

LLVM IR (-O2):
define signext i8 @escape_char(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %10 [
i32 114, label %12
i32 116, label %3
i32 110, label %4
i32 102, label %5
i32 98, label %6
i32 47, label %7
i32 34, label %8
i32 92, label %9
]
3: ; preds = %1
br label %12
4: ; preds = %1
br label %12
5: ; preds = %1
br label %12
6: ; preds = %1
br label %12
7: ; preds = %1
br label %12
8: ; preds = %1
br label %12
9: ; preds = %1
br label %12
10: ; preds = %1
%11 = tail call i32 @UPB_ASSERT(i32 0)
br label %12
12: ; preds = %1, %10, %9, %8, %7, %6, %5, %4, %3
%13 = phi i8 [ 120, %10 ], [ 92, %9 ], [ 34, %8 ], [ 47, %7 ], [ 8, %6 ], [ 12, %5 ], [ 10, %4 ], [ 9, %3 ], [ 13, %1 ]
ret i8 %13
}