#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(unsigned char);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
char const *strchar(unsigned char ch) {
  static char buf[8];
  switch (ch) {
  case '\a':
    return "'\\a'";
  case '\t':
    return "'\\t'";
  case '\b':
    return "'\\b'";
  case '\v':
    return "'\\v'";
  case '\f':
    return "'\\f'";
  case '\'':
    return "'\\''";
  case '\n':
    return "'\\n'";
  case '\\':
    return "'\\\\'";
  case '\r':
    return "'\\r'";
  case '\0':
    return "0";
  }
  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):
<strchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x5c,%rax
ja     11f4 <strchar+0xd4>
mov    -0x18(%rbp),%rax
lea    0xeb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x1019(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1259 <strchar+0x139>
lea    0x100e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1259 <strchar+0x139>
lea    0x1003(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1259 <strchar+0x139>
lea    0xff8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1259 <strchar+0x139>
lea    0xfed(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1259 <strchar+0x139>
lea    0xfe2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1259 <strchar+0x139>
lea    0xfd7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1259 <strchar+0x139>
lea    0xfcc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1259 <strchar+0x139>
lea    0xfc1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1259 <strchar+0x139>
lea    0xfb6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1259 <strchar+0x139>
movzbl -0x9(%rbp),%edi
call   1030 <isprint@plt>
cmp    $0x0,%rax
jne    1214 <strchar+0xf4>
movzbl -0x9(%rbp),%eax
cmp    $0x20,%eax
jne    1237 <strchar+0x117>
movb   $0x27,0x2e16(%rip)
mov    -0x9(%rbp),%al
mov    %al,0x2e0e(%rip)
movb   $0x27,0x2e08(%rip)
movb   $0x0,0x2e02(%rip)
jmp    124e <strchar+0x12e>
lea    0x2df3(%rip),%rdi
lea    0xf5e(%rip),%rsi
movzbl -0x9(%rbp),%edx
call   1040 <sprintf@plt>
lea    0x2ddc(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strchar>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
cmp    $0x5c,%bpl
ja     1151 <strchar+0x31>
lea    0x1041(%rip),%rbx
mov    %ebp,%eax
lea    0xec4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x1055(%rip),%rbx
jmp    11e9 <strchar+0xc9>
movzbl %bpl,%r14d
mov    %r14d,%edi
call   1030 <isprint@plt>
cmp    $0x20,%bpl
je     11cb <strchar+0xab>
test   %rax,%rax
jne    11cb <strchar+0xab>
lea    0x2ec2(%rip),%rbx
lea    0x102d(%rip),%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
call   1040 <sprintf@plt>
jmp    11e9 <strchar+0xc9>
lea    0xff4(%rip),%rbx
jmp    11e9 <strchar+0xc9>
lea    0xff0(%rip),%rbx
jmp    11e9 <strchar+0xc9>
lea    0xfec(%rip),%rbx
jmp    11e9 <strchar+0xc9>
lea    0xff7(%rip),%rbx
jmp    11e9 <strchar+0xc9>
lea    0xfcb(%rip),%rbx
jmp    11e9 <strchar+0xc9>
lea    0xfdb(%rip),%rbx
jmp    11e9 <strchar+0xc9>
lea    0xfcd(%rip),%rbx
jmp    11e9 <strchar+0xc9>
lea    0xfce(%rip),%rbx
jmp    11e9 <strchar+0xc9>
movb   $0x27,0x2e5f(%rip)
lea    0x2e58(%rip),%rbx
mov    %bpl,0x2e52(%rip)
movw   $0x27,0x2e4a(%rip)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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