void shods(s) char *s;
{
  char c;
  if (s == 0L || !(*s)) {
    printf("(none)\n");
  } else {
    while ((c = *s++))
      if (c == '\\')
        printf("\\\\");
      else if (c > 31 && c < 127) {
        putchar(c);
      } else
        printf("\\{%d}", c);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<shods>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1144 <shods+0x24>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1157 <shods+0x37>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ec <shods+0xcc>
jmp    115c <shods+0x3c>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x9(%rbp)
cmp    $0x0,%al
je     11de <shods+0xbe>
movsbl -0x9(%rbp),%eax
cmp    $0x5c,%eax
jne    1198 <shods+0x78>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d9 <shods+0xb9>
movsbl -0x9(%rbp),%eax
cmp    $0x1f,%eax
jle    11c2 <shods+0xa2>
movsbl -0x9(%rbp),%eax
cmp    $0x7f,%eax
jge    11c2 <shods+0xa2>
movsbl -0x9(%rbp),%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    11d4 <shods+0xb4>
movsbl -0x9(%rbp),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d9 <shods+0xb9>
jmp    115c <shods+0x3c>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shods>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     119c <shods+0x6c>
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     119c <shods+0x6c>
add    $0x1,%rbx
lea    0xeb2(%rip),%r14
lea    0xeae(%rip),%r15
jmp    1175 <shods+0x45>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11ad <shods+0x7d>
cmp    $0x5c,%al
je     1160 <shods+0x30>
movsbl %al,%esi
add    $0xe0,%al
cmp    $0x5e,%al
ja     1190 <shods+0x60>
mov    %esi,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
jmp    116a <shods+0x3a>
nopl   (%rax)
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    116a <shods+0x3a>
lea    0xe66(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <puts@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"(none)\0A\00"
@.str.1 = [3 x i8] c"\\\\\00"
@.str.2 = [6 x i8] c"\\{%d}\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @shods(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6, %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %44
12: ; preds = %6
br label %13
13: ; preds = %41, %12
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %2
%16 = load i8, i8* %14
store i8 %16, i8* %3
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %42
18: ; preds = %13
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 92
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %41
24: ; preds = %18
%25 = load i8, i8* %3
%26 = sext i8 %25 to i32
%27 = icmp sgt i32 %26, 31
br i1 %27, label %28, label %36
28: ; preds = %24
%29 = load i8, i8* %3
%30 = sext i8 %29 to i32
%31 = icmp slt i32 %30, 127
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i8, i8* %3
%34 = sext i8 %33 to i32
%35 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %34)
br label %40
36: ; preds = %28, %24
%37 = load i8, i8* %3
%38 = sext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %36, %32
br label %41
41: ; preds = %40, %22
br label %13
42: ; preds = %13
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %44
44: ; preds = %42, %10
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"\\\\\00"
@.str.2 = [6 x i8] c"\\{%d}\00"
@str = [7 x i8] c"(none)\00"
define void @shods(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3, %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %28
8: ; preds = %3, %23
%9 = phi i8* [ %11, %23 ], [ %0, %3 ]
%10 = phi i8 [ %24, %23 ], [ %4, %3 ]
%11 = getelementptr inbounds i8, i8* %9, i64 1
%12 = sext i8 %10 to i32
%13 = icmp eq i8 %10, 92
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %23
16: ; preds = %8
%17 = add i8 %10, -32
%18 = icmp ult i8 %17, 95
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %12)
br label %23
21: ; preds = %16
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br label %23
23: ; preds = %19, %21, %14
%24 = load i8, i8* %11
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %8
26: ; preds = %23
%27 = tail call i32 bitcast (i32 (...)* @putchar to i32 (i32)*)(i32 10)
br label %28
28: ; preds = %26, %6
ret void
}