char *readable_form(c)
register int c;
{
  static char rform[10];
  if ((c >= 0 && c < 32) || c >= 127) {
    switch (c) {
    case '\n':
      return ("\\n");
    case '\t':
      return ("\\t");
    case '\f':
      return ("\\f");
    case '\r':
      return ("\\r");
    case '\b':
      return ("\\b");
    default:
      (void)sprintf(rform, "\\%.3o", c);
      return (rform);
    }
  } else if (c == ' ')
    return ("' '");
  else {
    rform[0] = c;
    rform[1] = '\0';
    return (rform);
  }
}


x86 assembly (clang, -O0):
<readable_form>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     112f <readable_form+0x1f>
cmpl   $0x20,-0xc(%rbp)
jl     1139 <readable_form+0x29>
cmpl   $0x7f,-0xc(%rbp)
jl     11da <readable_form+0xca>
mov    -0xc(%rbp),%eax
add    $0xfffffff8,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     11b2 <readable_form+0xa2>
mov    -0x18(%rbp),%rax
lea    0xea7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeaf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <readable_form+0xff>
lea    0xea2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <readable_form+0xff>
lea    0xe95(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <readable_form+0xff>
lea    0xe88(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <readable_form+0xff>
lea    0xe7b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <readable_form+0xff>
mov    -0xc(%rbp),%edx
lea    0x2e6d(%rip),%rdi
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
lea    0x2e58(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <readable_form+0xff>
cmpl   $0x20,-0xc(%rbp)
jne    11f4 <readable_form+0xe4>
lea    0xe42(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120f <readable_form+0xff>
mov    -0xc(%rbp),%eax
mov    %al,0x2e2c(%rip)
movb   $0x0,0x2e26(%rip)
lea    0x2e1e(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readable_form>:
push   %rbx
mov    %edi,%edx
cmp    $0x20,%edi
jb     112b <readable_form+0x1b>
cmp    $0x7f,%edx
jge    112b <readable_form+0x1b>
cmp    $0x20,%edx
jne    1157 <readable_form+0x47>
lea    0xeec(%rip),%rbx
jmp    117d <readable_form+0x6d>
lea    -0x8(%rdx),%eax
cmp    $0x6,%eax
jae    113d <readable_form+0x2d>
mov    $0x37,%ecx
bt     %eax,%ecx
jb     116d <readable_form+0x5d>
lea    0x2ee5(%rip),%rbx
lea    0xec4(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    117d <readable_form+0x6d>
mov    %dl,0x2ecc(%rip)
lea    0x2ec5(%rip),%rbx
movb   $0x0,0x2ebf(%rip)
jmp    117d <readable_form+0x6d>
cltq
lea    0xea6(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
@readable_form.rform = internal global [10 x i8] zeroinitializer
@.str = [3 x i8] c"\\n\00"
@.str.1 = [3 x i8] c"\\t\00"
@.str.2 = [3 x i8] c"\\f\00"
@.str.3 = [3 x i8] c"\\r\00"
@.str.4 = [3 x i8] c"\\b\00"
@.str.5 = [6 x i8] c"\\%.3o\00"
@.str.6 = [4 x i8] c"' '\00"
@reltable.readable_form = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.4 to i64), i64 ptrtoint ([6 x i32]* @reltable.readable_form to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([6 x i32]* @reltable.readable_form to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([6 x i32]* @reltable.readable_form to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([6 x i32]* @reltable.readable_form to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([6 x i32]* @reltable.readable_form to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([6 x i32]* @reltable.readable_form to i64)) to i32)]
define i8* @readable_form(i32 %0) {
%2 = icmp ult i32 %0, 32
%3 = icmp sgt i32 %0, 126
%4 = or i1 %2, %3
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = add i32 %0, -8
%7 = icmp ult i32 %6, 6
br i1 %7, label %14, label %8
8: ; preds = %14, %5
%9 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @readable_form.rform, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %0)
br label %23
10: ; preds = %1
%11 = icmp eq i32 %0, 32
br i1 %11, label %23, label %12
12: ; preds = %10
%13 = trunc i32 %0 to i8
store i8 %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @readable_form.rform, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @readable_form.rform, i64 0, i64 1)
br label %23
14: ; preds = %5
%15 = trunc i32 %6 to i8
%16 = lshr i8 55, %15
%17 = and i8 %16, 1
%18 = icmp eq i8 %17, 0
br i1 %18, label %8, label %19
19: ; preds = %14
%20 = sext i32 %6 to i64
%21 = shl i64 %20, 2
%22 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.readable_form to i8*), i64 %21)
br label %23
23: ; preds = %19, %10, %12, %8
%24 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @readable_form.rform, i64 0, i64 0), %8 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @readable_form.rform, i64 0, i64 0), %12 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), %10 ], [ %22, %19 ]
ret i8* %24
}