#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*/ sprintf(char *, char *, unsigned char);
char *str_char(unsigned char c) {
  static char s[8];
  if (c >= 32 && 126) {
    sprintf(s, "'%c' ", c);
    return s;
  }
  switch (c) {
  case '\0':
    return "'\\0'";
  case '\r':
    return "'\\r'";
  case '\n':
    return "'\\n'";
  default:
    sprintf(s, "?%.3d", c);
    return s;
  }
}


x86 assembly (clang, -O0):
<str_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0x20,%eax
jl     1152 <str_char+0x42>
lea    0x2ef7(%rip),%rdi
lea    0xec7(%rip),%rsi
movzbl -0x9(%rbp),%edx
call   1030 <sprintf@plt>
lea    0x2ee0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11da <str_char+0xca>
movzbl -0x9(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     1188 <str_char+0x78>
jmp    1166 <str_char+0x56>
mov    -0x10(%rbp),%eax
sub    $0xa,%eax
je     11a8 <str_char+0x98>
jmp    1177 <str_char+0x67>
mov    -0x10(%rbp),%eax
sub    $0xd,%eax
je     1198 <str_char+0x88>
jmp    11b8 <str_char+0xa8>
lea    0xe77(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11da <str_char+0xca>
lea    0xe6c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11da <str_char+0xca>
lea    0xe61(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11da <str_char+0xca>
lea    0x2e6a(%rip),%rdi
lea    0xe4f(%rip),%rsi
movzbl -0x9(%rbp),%edx
call   1030 <sprintf@plt>
lea    0x2e53(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_char>:
push   %rbx
cmp    $0x20,%dil
jb     112b <str_char+0x1b>
movzbl %dil,%edx
lea    0x2f07(%rip),%rbx
lea    0xed7(%rip),%rsi
jmp    1169 <str_char+0x59>
test   %dil,%dil
je     1145 <str_char+0x35>
cmp    $0xa,%dil
je     114e <str_char+0x3e>
cmp    $0xd,%dil
jne    1157 <str_char+0x47>
lea    0xec8(%rip),%rbx
jmp    1171 <str_char+0x61>
lea    0xeba(%rip),%rbx
jmp    1171 <str_char+0x61>
lea    0xebb(%rip),%rbx
jmp    1171 <str_char+0x61>
movzbl %dil,%edx
lea    0x2ec7(%rip),%rbx
lea    0xeac(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@str_char.s = internal global [8 x i8] zeroinitializer
@.str = [6 x i8] c"'%c' \00"
@.str.1 = [5 x i8] c"'\\0'\00"
@.str.2 = [5 x i8] c"'\\r'\00"
@.str.3 = [5 x i8] c"'\\n'\00"
@.str.4 = [6 x i8] c"?%.3d\00"
define i8* @str_char(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
%6 = icmp sge i32 %5, 32
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i8, i8* %3
%9 = call i32 @sprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str_char.s, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 zeroext %8)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str_char.s, i64 0, i64 0), i8** %2
br label %19
10: ; preds = %1
%11 = load i8, i8* %3
%12 = zext i8 %11 to i32
switch i32 %12, label %16 [
i32 0, label %13
i32 13, label %14
i32 10, label %15
]
13: ; preds = %10
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %19
14: ; preds = %10
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %19
15: ; preds = %10
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %19
16: ; preds = %10
%17 = load i8, i8* %3
%18 = call i32 @sprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str_char.s, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %17)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str_char.s, i64 0, i64 0), i8** %2
br label %19
19: ; preds = %16, %15, %14, %13, %7
%20 = load i8*, i8** %2
ret i8* %20
}

LLVM IR (-O2):
@str_char.s = internal global [8 x i8] zeroinitializer
@.str = [6 x i8] c"'%c' \00"
@.str.1 = [5 x i8] c"'\\0'\00"
@.str.2 = [5 x i8] c"'\\r'\00"
@.str.3 = [5 x i8] c"'\\n'\00"
@.str.4 = [6 x i8] c"?%.3d\00"
define i8* @str_char(i8 zeroext %0) {
%2 = icmp ugt i8 %0, 31
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str_char.s, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 zeroext %0)
br label %10
5: ; preds = %1
switch i8 %0, label %8 [
i8 0, label %10
i8 13, label %6
i8 10, label %7
]
6: ; preds = %5
br label %10
7: ; preds = %5
br label %10
8: ; preds = %5
%9 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str_char.s, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %0)
br label %10
10: ; preds = %5, %8, %7, %6, %3
%11 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @str_char.s, i64 0, i64 0), %3 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str_char.s, i64 0, i64 0), %8 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %7 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %5 ]
ret i8* %11
}