#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 add_named_escape(char, char **, char *);
int add_octal_escape(char, char **, char *);
int add_untransformed_char(char, char **, char *);
bool add_c_escaped_char(char ch, char **buffer, char *buffer_end) {
  if (ch < ' ') {
    switch (ch) {
    case '\a':
      return add_named_escape('a', buffer, buffer_end);
    case '\b':
      return add_named_escape('b', buffer, buffer_end);
    case '\f':
      return add_named_escape('f', buffer, buffer_end);
    case '\n':
      return add_named_escape('n', buffer, buffer_end);
    case '\r':
      return add_named_escape('r', buffer, buffer_end);
    case '\t':
      return add_named_escape('t', buffer, buffer_end);
    case '\v':
      return add_named_escape('v', buffer, buffer_end);
    default:
      return add_octal_escape(ch, buffer, buffer_end);
    }
  } else if (ch == '\\') {
    return add_named_escape('\\', buffer, buffer_end);
  } else {
    return add_untransformed_char(ch, buffer, buffer_end);
  }
}


x86 assembly (clang, -O0):
<add_c_escaped_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
jge    124e <add_c_escaped_char+0x11e>
movsbl -0x5(%rbp),%eax
add    $0xfffffff9,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x6,%eax
ja     1233 <add_c_escaped_char+0x103>
mov    -0x20(%rbp),%rax
lea    0xe8c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x61,%edi
call   1030 <add_named_escape@plt>
mov    %eax,-0x4(%rbp)
jmp    128b <add_c_escaped_char+0x15b>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x62,%edi
call   1030 <add_named_escape@plt>
mov    %eax,-0x4(%rbp)
jmp    128b <add_c_escaped_char+0x15b>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x66,%edi
call   1030 <add_named_escape@plt>
mov    %eax,-0x4(%rbp)
jmp    128b <add_c_escaped_char+0x15b>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x6e,%edi
call   1030 <add_named_escape@plt>
mov    %eax,-0x4(%rbp)
jmp    128b <add_c_escaped_char+0x15b>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x72,%edi
call   1030 <add_named_escape@plt>
mov    %eax,-0x4(%rbp)
jmp    128b <add_c_escaped_char+0x15b>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x74,%edi
call   1030 <add_named_escape@plt>
mov    %eax,-0x4(%rbp)
jmp    128b <add_c_escaped_char+0x15b>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x76,%edi
call   1030 <add_named_escape@plt>
mov    %eax,-0x4(%rbp)
jmp    128b <add_c_escaped_char+0x15b>
mov    -0x5(%rbp),%al
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
movsbl %al,%edi
call   1050 <add_octal_escape@plt>
mov    %eax,-0x4(%rbp)
jmp    128b <add_c_escaped_char+0x15b>
movsbl -0x5(%rbp),%eax
cmp    $0x5c,%eax
jne    1275 <add_c_escaped_char+0x145>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x5c,%edi
call   1030 <add_named_escape@plt>
mov    %eax,-0x4(%rbp)
jmp    128b <add_c_escaped_char+0x15b>
mov    -0x5(%rbp),%al
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
movsbl %al,%edi
call   1040 <add_untransformed_char@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_c_escaped_char>:
cmp    $0x1f,%dil
jg     115c <add_c_escaped_char+0x2c>
movsbl %dil,%edi
lea    -0x7(%rdi),%eax
cmp    $0x6,%eax
ja     1175 <add_c_escaped_char+0x45>
lea    0xeb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x61,%edi
jmp    1030 <add_named_escape@plt>
cmp    $0x5c,%dil
jne    116c <add_c_escaped_char+0x3c>
mov    $0x5c,%edi
jmp    1030 <add_named_escape@plt>
movsbl %dil,%edi
jmp    1040 <add_untransformed_char@plt>
jmp    1050 <add_octal_escape@plt>
mov    $0x62,%edi
jmp    1030 <add_named_escape@plt>
mov    $0x74,%edi
jmp    1030 <add_named_escape@plt>
mov    $0x6e,%edi
jmp    1030 <add_named_escape@plt>
mov    $0x76,%edi
jmp    1030 <add_named_escape@plt>
mov    $0x66,%edi
jmp    1030 <add_named_escape@plt>
mov    $0x72,%edi
jmp    1030 <add_named_escape@plt>

LLVM IR (-O0):
define i32 @add_c_escaped_char(i8 signext %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8**
%7 = alloca i8*
store i8 %0, i8* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
%10 = icmp slt i32 %9, 32
br i1 %10, label %11, label %47
11: ; preds = %3
%12 = load i8, i8* %5
%13 = sext i8 %12 to i32
switch i32 %13, label %42 [
i32 7, label %14
i32 8, label %18
i32 12, label %22
i32 10, label %26
i32 13, label %30
i32 9, label %34
i32 11, label %38
]
14: ; preds = %11
%15 = load i8**, i8*** %6
%16 = load i8*, i8** %7
%17 = call i32 @add_named_escape(i8 signext 97, i8** %15, i8* %16)
store i32 %17, i32* %4
br label %60
18: ; preds = %11
%19 = load i8**, i8*** %6
%20 = load i8*, i8** %7
%21 = call i32 @add_named_escape(i8 signext 98, i8** %19, i8* %20)
store i32 %21, i32* %4
br label %60
22: ; preds = %11
%23 = load i8**, i8*** %6
%24 = load i8*, i8** %7
%25 = call i32 @add_named_escape(i8 signext 102, i8** %23, i8* %24)
store i32 %25, i32* %4
br label %60
26: ; preds = %11
%27 = load i8**, i8*** %6
%28 = load i8*, i8** %7
%29 = call i32 @add_named_escape(i8 signext 110, i8** %27, i8* %28)
store i32 %29, i32* %4
br label %60
30: ; preds = %11
%31 = load i8**, i8*** %6
%32 = load i8*, i8** %7
%33 = call i32 @add_named_escape(i8 signext 114, i8** %31, i8* %32)
store i32 %33, i32* %4
br label %60
34: ; preds = %11
%35 = load i8**, i8*** %6
%36 = load i8*, i8** %7
%37 = call i32 @add_named_escape(i8 signext 116, i8** %35, i8* %36)
store i32 %37, i32* %4
br label %60
38: ; preds = %11
%39 = load i8**, i8*** %6
%40 = load i8*, i8** %7
%41 = call i32 @add_named_escape(i8 signext 118, i8** %39, i8* %40)
store i32 %41, i32* %4
br label %60
42: ; preds = %11
%43 = load i8, i8* %5
%44 = load i8**, i8*** %6
%45 = load i8*, i8** %7
%46 = call i32 @add_octal_escape(i8 signext %43, i8** %44, i8* %45)
store i32 %46, i32* %4
br label %60
47: ; preds = %3
%48 = load i8, i8* %5
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 92
br i1 %50, label %51, label %55
51: ; preds = %47
%52 = load i8**, i8*** %6
%53 = load i8*, i8** %7
%54 = call i32 @add_named_escape(i8 signext 92, i8** %52, i8* %53)
store i32 %54, i32* %4
br label %60
55: ; preds = %47
%56 = load i8, i8* %5
%57 = load i8**, i8*** %6
%58 = load i8*, i8** %7
%59 = call i32 @add_untransformed_char(i8 signext %56, i8** %57, i8* %58)
store i32 %59, i32* %4
br label %60
60: ; preds = %55, %51, %42, %38, %34, %30, %26, %22, %18, %14
%61 = load i32, i32* %4
ret i32 %61
}

LLVM IR (-O2):
define i32 @add_c_escaped_char(i8 signext %0, i8** %1, i8* %2) {
%4 = icmp slt i8 %0, 32
br i1 %4, label %5, label %23
5: ; preds = %3
%6 = sext i8 %0 to i32
switch i32 %6, label %21 [
i32 7, label %7
i32 8, label %9
i32 12, label %11
i32 10, label %13
i32 13, label %15
i32 9, label %17
i32 11, label %19
]
7: ; preds = %5
%8 = tail call i32 @add_named_escape(i8 signext 97, i8** %1, i8* %2)
br label %29
9: ; preds = %5
%10 = tail call i32 @add_named_escape(i8 signext 98, i8** %1, i8* %2)
br label %29
11: ; preds = %5
%12 = tail call i32 @add_named_escape(i8 signext 102, i8** %1, i8* %2)
br label %29
13: ; preds = %5
%14 = tail call i32 @add_named_escape(i8 signext 110, i8** %1, i8* %2)
br label %29
15: ; preds = %5
%16 = tail call i32 @add_named_escape(i8 signext 114, i8** %1, i8* %2)
br label %29
17: ; preds = %5
%18 = tail call i32 @add_named_escape(i8 signext 116, i8** %1, i8* %2)
br label %29
19: ; preds = %5
%20 = tail call i32 @add_named_escape(i8 signext 118, i8** %1, i8* %2)
br label %29
21: ; preds = %5
%22 = tail call i32 @add_octal_escape(i8 signext %0, i8** %1, i8* %2)
br label %29
23: ; preds = %3
%24 = icmp eq i8 %0, 92
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = tail call i32 @add_named_escape(i8 signext 92, i8** %1, i8* %2)
br label %29
27: ; preds = %23
%28 = tail call i32 @add_untransformed_char(i8 signext %0, i8** %1, i8* %2)
br label %29
29: ; preds = %27, %25, %21, %19, %17, %15, %13, %11, %9, %7
%30 = phi i32 [ %22, %21 ], [ %20, %19 ], [ %18, %17 ], [ %16, %15 ], [ %14, %13 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %26, %25 ], [ %28, %27 ]
ret i32 %30
}