#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*/ m_putc(int, char);
void repl_char(int buf, char ch) {
  char tab[] = {'\\', '\0', '\n', '\r', '\'', '"', '\x1a'};
  char rep[] = {'\\', '0', 'n', 'r', '\'', '"', 'Z'};
  int i;
  for (i = 0; i < sizeof tab; i++)
    if (tab[i] == ch) {
      m_putc(buf, '\\');
      m_putc(buf, rep[i]);
      return;
    }
  m_putc(buf, ch);
}


x86 assembly (clang, -O0):
<repl_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    0xed9(%rip),%eax
mov    %eax,-0xc(%rbp)
mov    0xed3(%rip),%ax
mov    %ax,-0x8(%rbp)
mov    0xecb(%rip),%al
mov    %al,-0x6(%rbp)
mov    0xec3(%rip),%eax
mov    %eax,-0x13(%rbp)
mov    0xebd(%rip),%ax
mov    %ax,-0xf(%rbp)
mov    0xeb5(%rip),%al
mov    %al,-0xd(%rbp)
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x7,%rax
jae    11bb <repl_char+0xab>
movslq -0x18(%rbp),%rax
movsbl -0xc(%rbp,%rax,1),%eax
movsbl -0x5(%rbp),%ecx
cmp    %ecx,%eax
jne    11a8 <repl_char+0x98>
mov    -0x4(%rbp),%edi
mov    $0x5c,%esi
call   1030 <m_putc@plt>
mov    -0x4(%rbp),%edi
movslq -0x18(%rbp),%rax
movsbl -0x13(%rbp,%rax,1),%esi
call   1030 <m_putc@plt>
jmp    11c7 <repl_char+0xb7>
jmp    11ad <repl_char+0x9d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1162 <repl_char+0x52>
mov    -0x4(%rbp),%edi
movsbl -0x5(%rbp),%esi
call   1030 <m_putc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<repl_char>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x27,%sil
ja     1138 <repl_char+0x28>
movzbl %sil,%eax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%r14d
jmp    1169 <repl_char+0x59>
cmp    $0x5c,%sil
jne    1180 <repl_char+0x70>
xor    %r14d,%r14d
jmp    1169 <repl_char+0x59>
mov    $0x2,%r14d
jmp    1169 <repl_char+0x59>
mov    $0x3,%r14d
jmp    1169 <repl_char+0x59>
mov    $0x6,%r14d
jmp    1169 <repl_char+0x59>
mov    $0x5,%r14d
jmp    1169 <repl_char+0x59>
mov    $0x4,%r14d
mov    %ebx,%edi
mov    $0x5c,%esi
call   1030 <m_putc@plt>
lea    0xf24(%rip),%rax
mov    (%r14,%rax,1),%sil
movsbl %sil,%esi
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <m_putc@plt>

LLVM IR (-O0):
@__const.repl_char.tab = [7 x i8] c"\\\00\0A\0D'\22\1A"
@__const.repl_char.rep = [7 x i8] c"\\0nr'\22Z"
define void @repl_char(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca [7 x i8]
%6 = alloca [7 x i8]
%7 = alloca i32
store i32 %0, i32* %3
store i8 %1, i8* %4
%8 = bitcast [7 x i8]* %5 to i8*
%9 = bitcast [7 x i8]* %6 to i8*
store i32 0, i32* %7
br label %10
10: ; preds = %33, %2
%11 = load i32, i32* %7
%12 = sext i32 %11 to i64
%13 = icmp ult i64 %12, 7
br i1 %13, label %14, label %36
14: ; preds = %10
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = load i8, i8* %4
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %19, %21
br i1 %22, label %23, label %32
23: ; preds = %14
%24 = load i32, i32* %3
%25 = call i32 @m_putc(i32 %24, i8 signext 92)
%26 = load i32, i32* %3
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @m_putc(i32 %26, i8 signext %30)
br label %40
32: ; preds = %14
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %10
36: ; preds = %10
%37 = load i32, i32* %3
%38 = load i8, i8* %4
%39 = call i32 @m_putc(i32 %37, i8 signext %38)
br label %40
40: ; preds = %36, %23
ret void
}

LLVM IR (-O2):
@__const.repl_char.rep = [7 x i8] c"\\0nr'\22Z"
define void @repl_char(i32 %0, i8 signext %1) {
switch i8 %1, label %14 [
i8 92, label %9
i8 0, label %3
i8 10, label %4
i8 13, label %5
i8 39, label %6
i8 34, label %7
i8 26, label %8
]
3: ; preds = %2
br label %9
4: ; preds = %2
br label %9
5: ; preds = %2
br label %9
6: ; preds = %2
br label %9
7: ; preds = %2
br label %9
8: ; preds = %2
br label %9
9: ; preds = %2, %8, %7, %6, %5, %4, %3
%10 = phi i64 [ 0, %2 ], [ 1, %3 ], [ 2, %4 ], [ 3, %5 ], [ 4, %6 ], [ 5, %7 ], [ 6, %8 ]
%11 = tail call i32 @m_putc(i32 %0, i8 signext 92)
%12 = getelementptr inbounds [7 x i8], [7 x i8]* @__const.repl_char.rep, i64 0, i64 %10
%13 = load i8, i8* %12
br label %14
14: ; preds = %2, %9
%15 = phi i8 [ %13, %9 ], [ %1, %2 ]
%16 = tail call i32 @m_putc(i32 %0, i8 signext %15)
ret void
}