#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*/ printf(char *, ...);
void print_char(unsigned char c) {
  if (c < 0x20) {
    switch (c) {
    case '\a':
      printf("\\a");
      break;
    case '\b':
      printf("\\b");
      break;
    case '\f':
      printf("\\f");
      break;
    case '\n':
      printf("\\n");
      break;
    case '\r':
      printf("\\r");
      break;
    case '\t':
      printf("\\t");
      break;
    case '\v':
      printf("\\v");
      break;
    default:
      printf("\\%x", c);
      break;
    }
  } else if (c < 0x7F) {
    printf("%c", c);
  } else {
    printf("\\%x", c);
  }
}


x86 assembly (clang, -O0):
<print_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x20,%eax
jge    11f1 <print_char+0xe1>
movzbl -0x1(%rbp),%eax
add    $0xfffffff9,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     11da <print_char+0xca>
mov    -0x10(%rbp),%rax
lea    0xeb4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <print_char+0xdc>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <print_char+0xdc>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <print_char+0xdc>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <print_char+0xdc>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <print_char+0xdc>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <print_char+0xdc>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <print_char+0xdc>
movzbl -0x1(%rbp),%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122c <print_char+0x11c>
movzbl -0x1(%rbp),%eax
cmp    $0x7f,%eax
jge    1215 <print_char+0x105>
movzbl -0x1(%rbp),%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1227 <print_char+0x117>
movzbl -0x1(%rbp),%esi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122c <print_char+0x11c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_char>:
mov    %edi,%esi
cmp    $0x1f,%sil
ja     1150 <print_char+0x30>
lea    -0x7(%rsi),%eax
cmp    $0x6,%al
ja     115d <print_char+0x3d>
movzbl %al,%eax
lea    0xec7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed3(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
cmp    $0x7e,%sil
ja     115d <print_char+0x3d>
mov    %esi,%edi
jmp    1030 <putchar@plt>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
lea    0xead(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
lea    0xeab(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
lea    0xe97(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
lea    0xe92(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
lea    0xe78(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
lea    0xe70(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"\\a\00"
@.str.1 = [3 x i8] c"\\b\00"
@.str.2 = [3 x i8] c"\\f\00"
@.str.3 = [3 x i8] c"\\n\00"
@.str.4 = [3 x i8] c"\\r\00"
@.str.5 = [3 x i8] c"\\t\00"
@.str.6 = [3 x i8] c"\\v\00"
@.str.7 = [4 x i8] c"\\%x\00"
@.str.8 = [3 x i8] c"%c\00"
define void @print_char(i8 zeroext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = zext i8 %3 to i32
%5 = icmp slt i32 %4, 32
br i1 %5, label %6, label %28
6: ; preds = %1
%7 = load i8, i8* %2
%8 = zext i8 %7 to i32
switch i32 %8, label %23 [
i32 7, label %9
i32 8, label %11
i32 12, label %13
i32 10, label %15
i32 13, label %17
i32 9, label %19
i32 11, label %21
]
9: ; preds = %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %27
11: ; preds = %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %27
13: ; preds = %6
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %27
15: ; preds = %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %27
17: ; preds = %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %27
19: ; preds = %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %27
21: ; preds = %6
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %27
23: ; preds = %6
%24 = load i8, i8* %2
%25 = zext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %23, %21, %19, %17, %15, %13, %11, %9
br label %41
28: ; preds = %1
%29 = load i8, i8* %2
%30 = zext i8 %29 to i32
%31 = icmp slt i32 %30, 127
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i8, i8* %2
%34 = zext i8 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %34)
br label %40
36: ; preds = %28
%37 = load i8, i8* %2
%38 = zext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %36, %32
br label %41
41: ; preds = %40, %27
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\\a\00"
@.str.1 = [3 x i8] c"\\b\00"
@.str.2 = [3 x i8] c"\\f\00"
@.str.3 = [3 x i8] c"\\n\00"
@.str.4 = [3 x i8] c"\\r\00"
@.str.5 = [3 x i8] c"\\t\00"
@.str.6 = [3 x i8] c"\\v\00"
@.str.7 = [4 x i8] c"\\%x\00"
define void @print_char(i8 zeroext %0) {
%2 = zext i8 %0 to i32
%3 = icmp ult i8 %0, 32
br i1 %3, label %4, label %21
4: ; preds = %1
switch i8 %0, label %19 [
i8 7, label %5
i8 8, label %7
i8 12, label %9
i8 10, label %11
i8 13, label %13
i8 9, label %15
i8 11, label %17
]
5: ; preds = %4
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %27
7: ; preds = %4
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %27
9: ; preds = %4
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %27
11: ; preds = %4
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %27
13: ; preds = %4
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %27
15: ; preds = %4
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %27
17: ; preds = %4
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %27
19: ; preds = %4
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %2)
br label %27
21: ; preds = %1
%22 = icmp ult i8 %0, 127
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = tail call i32 @putchar(i32 %2)
br label %27
25: ; preds = %21
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %2)
br label %27
27: ; preds = %23, %25, %5, %7, %9, %11, %13, %15, %17, %19
ret void
}