char *readable_form(c)
register int c;
{
  static char rform[10];
  if ((c >= 0 && c < 32) || c >= 127) {
    switch (c) {
    case '\b':
      return "\\b";
    case '\f':
      return "\\f";
    case '\n':
      return "\\n";
    case '\r':
      return "\\r";
    case '\t':
      return "\\t";
    case '\a':
      return "\\a";
    case '\v':
      return "\\v";
    default:
      (void)sprintf(rform, "\\%.3o", (unsigned int)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     11fa <readable_form+0xea>
mov    -0xc(%rbp),%eax
add    $0xfffffff9,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x6,%eax
ja     11d2 <readable_form+0xc2>
mov    -0x18(%rbp),%rax
lea    0xea7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122f <readable_form+0x11f>
lea    0xea6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122f <readable_form+0x11f>
lea    0xe99(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122f <readable_form+0x11f>
lea    0xe8c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122f <readable_form+0x11f>
lea    0xe7f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122f <readable_form+0x11f>
lea    0xe72(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122f <readable_form+0x11f>
lea    0xe65(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122f <readable_form+0x11f>
mov    -0xc(%rbp),%edx
lea    0x2e4d(%rip),%rdi
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
lea    0x2e38(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122f <readable_form+0x11f>
cmpl   $0x20,-0xc(%rbp)
jne    1214 <readable_form+0x104>
lea    0xe2c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122f <readable_form+0x11f>
mov    -0xc(%rbp),%eax
mov    %al,0x2e0c(%rip)
movb   $0x0,0x2e06(%rip)
lea    0x2dfe(%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    1145 <readable_form+0x35>
lea    0xef2(%rip),%rbx
jmp    1173 <readable_form+0x63>
lea    -0x7(%rdx),%eax
cmp    $0x7,%eax
jae    115b <readable_form+0x4b>
cltq
lea    0xee4(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    1173 <readable_form+0x63>
mov    %dl,0x2ede(%rip)
lea    0x2ed7(%rip),%rbx
movb   $0x0,0x2ed1(%rip)
jmp    1173 <readable_form+0x63>
lea    0x2ec7(%rip),%rbx
lea    0xeac(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
@readable_form.rform = internal global [10 x i8] zeroinitializer
@.str = [3 x i8] c"\\b\00"
@.str.1 = [3 x i8] c"\\f\00"
@.str.2 = [3 x i8] c"\\n\00"
@.str.3 = [3 x i8] c"\\r\00"
@.str.4 = [3 x i8] c"\\t\00"
@.str.5 = [3 x i8] c"\\a\00"
@.str.6 = [3 x i8] c"\\v\00"
@.str.7 = [6 x i8] c"\\%.3o\00"
@.str.8 = [4 x i8] c"' '\00"
@reltable.readable_form = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.readable_form to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.readable_form to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.readable_form to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.readable_form to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.readable_form to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.readable_form to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([7 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, -7
%7 = icmp ult i32 %6, 7
br i1 %7, label %14, label %8
8: ; preds = %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.7, i64 0, i64 0), i32 %0)
br label %18
10: ; preds = %1
%11 = icmp eq i32 %0, 32
br i1 %11, label %18, 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 %18
14: ; preds = %5
%15 = sext i32 %6 to i64
%16 = shl i64 %15, 2
%17 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.readable_form to i8*), i64 %16)
br label %18
18: ; preds = %14, %10, %12, %8
%19 = 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.8, i64 0, i64 0), %10 ], [ %17, %14 ]
ret i8* %19
}