#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__ isprint(int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
char const *cqchar(int ch) {
  static char buf[8];
  switch (ch) {
  case '\a':
    return "'\\a'";
  case '\t':
    return "'\\t'";
  case '\b':
    return "'\\b'";
  case '\v':
    return "'\\t'";
  case '\f':
    return "'\\f'";
  case '\0':
    return "'\\0'";
  case '\n':
    return "'\\n'";
  case '\'':
    return "'\\''";
  case '\r':
    return "'\\r'";
  case '\\':
    return "'\\\\'";
  }
  if (isprint(ch) || ch == ' ') {
    buf[0] = '\'';
    buf[1] = ch;
    buf[2] = '\'';
    buf[3] = '\0';
  } else
    sprintf(buf, "0x%02X", (unsigned char)ch);
  return buf;
}


x86 assembly (clang, -O0):
<cqchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x5c,%rax
ja     11f0 <cqchar+0xd0>
mov    -0x18(%rbp),%rax
lea    0xeb9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x101d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1253 <cqchar+0x133>
lea    0x1012(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1253 <cqchar+0x133>
lea    0x1007(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1253 <cqchar+0x133>
lea    0xff2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1253 <cqchar+0x133>
lea    0xfec(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1253 <cqchar+0x133>
lea    0xfe1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1253 <cqchar+0x133>
lea    0xfd6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1253 <cqchar+0x133>
lea    0xfcb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1253 <cqchar+0x133>
lea    0xfc0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1253 <cqchar+0x133>
lea    0xfb5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1253 <cqchar+0x133>
mov    -0xc(%rbp),%edi
call   1030 <isprint@plt>
cmp    $0x0,%rax
jne    120c <cqchar+0xec>
cmpl   $0x20,-0xc(%rbp)
jne    122f <cqchar+0x10f>
movb   $0x27,0x2e1e(%rip)
mov    -0xc(%rbp),%eax
mov    %al,0x2e16(%rip)
movb   $0x27,0x2e10(%rip)
movb   $0x0,0x2e0a(%rip)
jmp    1248 <cqchar+0x128>
mov    -0xc(%rbp),%eax
lea    0x2df8(%rip),%rdi
lea    0xf61(%rip),%rsi
movzbl %al,%edx
call   1040 <sprintf@plt>
lea    0x2de2(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cqchar>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
cmp    $0x5c,%edi
ja     115b <cqchar+0x3b>
lea    0x1043(%rip),%rbx
mov    %ebp,%eax
lea    0xec6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x102f(%rip),%rbx
jmp    11dc <cqchar+0xbc>
lea    0x1032(%rip),%rbx
jmp    11dc <cqchar+0xbc>
mov    %ebp,%edi
call   1030 <isprint@plt>
cmp    $0x20,%ebp
je     11be <cqchar+0x9e>
test   %rax,%rax
jne    11be <cqchar+0x9e>
movzbl %bpl,%edx
lea    0x2eba(%rip),%rbx
lea    0x1023(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
jmp    11dc <cqchar+0xbc>
lea    0xfef(%rip),%rbx
jmp    11dc <cqchar+0xbc>
lea    0xfeb(%rip),%rbx
jmp    11dc <cqchar+0xbc>
lea    0xff6(%rip),%rbx
jmp    11dc <cqchar+0xbc>
lea    0xfe3(%rip),%rbx
jmp    11dc <cqchar+0xbc>
lea    0xfdf(%rip),%rbx
jmp    11dc <cqchar+0xbc>
lea    0xfe0(%rip),%rbx
jmp    11dc <cqchar+0xbc>
movb   $0x27,0x2e6c(%rip)
lea    0x2e65(%rip),%rbx
mov    %bpl,0x2e5f(%rip)
movw   $0x27,0x2e57(%rip)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@cqchar.buf = internal global [8 x i8] zeroinitializer
@.str = [5 x i8] c"'\\a'\00"
@.str.1 = [5 x i8] c"'\\t'\00"
@.str.2 = [5 x i8] c"'\\b'\00"
@.str.3 = [5 x i8] c"'\\f'\00"
@.str.4 = [5 x i8] c"'\\0'\00"
@.str.5 = [5 x i8] c"'\\n'\00"
@.str.6 = [5 x i8] c"'\\''\00"
@.str.7 = [5 x i8] c"'\\r'\00"
@.str.8 = [5 x i8] c"'\\\\'\00"
@.str.9 = [7 x i8] c"0x%02X\00"
define i8* @cqchar(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %15 [
i32 7, label %5
i32 9, label %6
i32 8, label %7
i32 11, label %8
i32 12, label %9
i32 0, label %10
i32 10, label %11
i32 39, label %12
i32 13, label %13
i32 92, label %14
]
5: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2
br label %30
6: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %30
7: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %30
8: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %30
9: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %30
10: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %30
11: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %30
12: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %30
13: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %30
14: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %30
15: ; preds = %1
%16 = load i32, i32* %3
%17 = call i64 @isprint(i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %15
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 32
br i1 %21, label %22, label %25
22: ; preds = %19, %15
store i8 39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @cqchar.buf, i64 0, i64 0)
%23 = load i32, i32* %3
%24 = trunc i32 %23 to i8
store i8 %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @cqchar.buf, i64 0, i64 1)
store i8 39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @cqchar.buf, i64 0, i64 2)
store i8 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @cqchar.buf, i64 0, i64 3)
br label %29
25: ; preds = %19
%26 = load i32, i32* %3
%27 = trunc i32 %26 to i8
%28 = call i32 @sprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @cqchar.buf, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8 zeroext %27)
br label %29
29: ; preds = %25, %22
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @cqchar.buf, i64 0, i64 0), i8** %2
br label %30
30: ; preds = %29, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%31 = load i8*, i8** %2
ret i8* %31
}

LLVM IR (-O2):
@cqchar.buf = internal global [8 x i8] zeroinitializer
@.str = [5 x i8] c"'\\a'\00"
@.str.1 = [5 x i8] c"'\\t'\00"
@.str.2 = [5 x i8] c"'\\b'\00"
@.str.3 = [5 x i8] c"'\\f'\00"
@.str.4 = [5 x i8] c"'\\0'\00"
@.str.5 = [5 x i8] c"'\\n'\00"
@.str.6 = [5 x i8] c"'\\''\00"
@.str.7 = [5 x i8] c"'\\r'\00"
@.str.8 = [5 x i8] c"'\\\\'\00"
@.str.9 = [7 x i8] c"0x%02X\00"
define i8* @cqchar(i32 %0) {
switch i32 %0, label %11 [
i32 7, label %21
i32 9, label %2
i32 8, label %3
i32 11, label %4
i32 12, label %5
i32 0, label %6
i32 10, label %7
i32 39, label %8
i32 13, label %9
i32 92, label %10
]
2: ; preds = %1
br label %21
3: ; preds = %1
br label %21
4: ; preds = %1
br label %21
5: ; preds = %1
br label %21
6: ; preds = %1
br label %21
7: ; preds = %1
br label %21
8: ; preds = %1
br label %21
9: ; preds = %1
br label %21
10: ; preds = %1
br label %21
11: ; preds = %1
%12 = tail call i64 @isprint(i32 %0)
%13 = icmp ne i64 %12, 0
%14 = icmp eq i32 %0, 32
%15 = or i1 %14, %13
br i1 %15, label %16, label %18
16: ; preds = %11
store i8 39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @cqchar.buf, i64 0, i64 0)
%17 = trunc i32 %0 to i8
store i8 %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @cqchar.buf, i64 0, i64 1)
store i8 39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @cqchar.buf, i64 0, i64 2)
store i8 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @cqchar.buf, i64 0, i64 3)
br label %21
18: ; preds = %11
%19 = trunc i32 %0 to i8
%20 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @cqchar.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8 zeroext %19)
br label %21
21: ; preds = %16, %18, %1, %10, %9, %8, %7, %6, %5, %4, %3, %2
%22 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), %10 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), %9 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), %8 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %6 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @cqchar.buf, i64 0, i64 0), %18 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @cqchar.buf, i64 0, i64 0), %16 ]
ret i8* %22
}