printchar(c, mode) {
  if (mode == 0 ||
      (((unsigned short)((c) - (' ')) <= (('~') - (' '))) && c != '\\')) {
    putchar(c);
    return (1);
  } else {
    putchar('\\');
    switch (c) {
    case '\0':
      putchar('0');
      break;
    case '\b':
      putchar('b');
      break;
    case '\n':
      putchar('n');
      break;
    case '\r':
      putchar('r');
      break;
    case '\t':
      putchar('t');
      break;
    case '\f':
      putchar('f');
      break;
    case '\\':
      putchar('\\');
      break;
    default:
      printnum((long)(c & 0xFF), 8, 0, 3, '0');
      return (4);
    }
    return (2);
  }
}


x86 assembly (clang, -O0):
<printchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1154 <printchar+0x34>
mov    -0x8(%rbp),%eax
sub    $0x20,%eax
movzwl %ax,%eax
cmp    $0x5e,%eax
jg     116a <printchar+0x4a>
cmpl   $0x5c,-0x8(%rbp)
je     116a <printchar+0x4a>
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1030 <putchar@plt>
movl   $0x1,-0x4(%rbp)
jmp    129d <printchar+0x17d>
xor    %eax,%eax
mov    $0x5c,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     11ef <printchar+0xcf>
jmp    1189 <printchar+0x69>
mov    -0x10(%rbp),%eax
sub    $0x8,%eax
je     1200 <printchar+0xe0>
jmp    119a <printchar+0x7a>
mov    -0x10(%rbp),%eax
sub    $0x9,%eax
je     1233 <printchar+0x113>
jmp    11ab <printchar+0x8b>
mov    -0x10(%rbp),%eax
sub    $0xa,%eax
je     1211 <printchar+0xf1>
jmp    11bc <printchar+0x9c>
mov    -0x10(%rbp),%eax
sub    $0xc,%eax
je     1244 <printchar+0x124>
jmp    11cd <printchar+0xad>
mov    -0x10(%rbp),%eax
sub    $0xd,%eax
je     1222 <printchar+0x102>
jmp    11de <printchar+0xbe>
mov    -0x10(%rbp),%eax
sub    $0x5c,%eax
je     1255 <printchar+0x135>
jmp    1266 <printchar+0x146>
mov    $0x30,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1296 <printchar+0x176>
mov    $0x62,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1296 <printchar+0x176>
mov    $0x6e,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1296 <printchar+0x176>
mov    $0x72,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1296 <printchar+0x176>
mov    $0x74,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1296 <printchar+0x176>
mov    $0x66,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1296 <printchar+0x176>
mov    $0x5c,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    1296 <printchar+0x176>
mov    -0x8(%rbp),%eax
and    $0xff,%eax
movslq %eax,%rdi
mov    $0x8,%esi
xor    %edx,%edx
mov    $0x3,%ecx
mov    $0x30,%r8d
mov    $0x0,%al
call   1040 <printnum@plt>
movl   $0x4,-0x4(%rbp)
jmp    129d <printchar+0x17d>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printchar>:
push   %rbx
mov    %edi,%ebx
test   %esi,%esi
je     113a <printchar+0x1a>
cmp    $0x5c,%ebx
je     114a <printchar+0x2a>
lea    0xffe0(%rbx),%eax
movzwl %ax,%eax
cmp    $0x5e,%eax
ja     114a <printchar+0x2a>
mov    %ebx,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x5c,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
cmp    $0xd,%ebx
ja     1174 <printchar+0x54>
mov    %ebx,%eax
lea    0xe9c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x30,%edi
jmp    11c4 <printchar+0xa4>
cmp    $0x5c,%ebx
jne    1180 <printchar+0x60>
mov    $0x5c,%edi
jmp    11c4 <printchar+0xa4>
movzbl %bl,%edi
mov    $0x8,%esi
xor    %edx,%edx
mov    $0x3,%ecx
mov    $0x30,%r8d
xor    %eax,%eax
call   1040 <printnum@plt>
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x62,%edi
jmp    11c4 <printchar+0xa4>
mov    $0x74,%edi
jmp    11c4 <printchar+0xa4>
mov    $0x6e,%edi
jmp    11c4 <printchar+0xa4>
mov    $0x66,%edi
jmp    11c4 <printchar+0xa4>
mov    $0x72,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
mov    $0x2,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @printchar(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %2
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 32
%11 = trunc i32 %10 to i16
%12 = zext i16 %11 to i32
%13 = icmp sle i32 %12, 94
br i1 %13, label %14, label %20
14: ; preds = %8
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 92
br i1 %16, label %17, label %20
17: ; preds = %14, %2
%18 = load i32, i32* %4
%19 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %18)
store i32 1, i32* %3
br label %43
20: ; preds = %14, %8
%21 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 92)
%22 = load i32, i32* %4
switch i32 %22, label %37 [
i32 0, label %23
i32 8, label %25
i32 10, label %27
i32 13, label %29
i32 9, label %31
i32 12, label %33
i32 92, label %35
]
23: ; preds = %20
%24 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 48)
br label %42
25: ; preds = %20
%26 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 98)
br label %42
27: ; preds = %20
%28 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 110)
br label %42
29: ; preds = %20
%30 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 114)
br label %42
31: ; preds = %20
%32 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 116)
br label %42
33: ; preds = %20
%34 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 102)
br label %42
35: ; preds = %20
%36 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 92)
br label %42
37: ; preds = %20
%38 = load i32, i32* %4
%39 = and i32 %38, 255
%40 = sext i32 %39 to i64
%41 = call i32 (i64, i32, i32, i32, i32, ...) bitcast (i32 (...)* @printnum to i32 (i64, i32, i32, i32, i32, ...)*)(i64 %40, i32 8, i32 0, i32 3, i32 48)
store i32 4, i32* %3
br label %43
42: ; preds = %35, %33, %31, %29, %27, %25, %23
store i32 2, i32* %3
br label %43
43: ; preds = %42, %37, %17
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
define i32 @printchar(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = add i32 %0, 65504
%6 = and i32 %5, 65535
%7 = icmp ult i32 %6, 95
%8 = icmp ne i32 %0, 92
%9 = and i1 %8, %7
br i1 %9, label %10, label %12
10: ; preds = %4, %2
%11 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %0)
br label %32
12: ; preds = %4
%13 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 92)
switch i32 %0, label %28 [
i32 0, label %14
i32 8, label %16
i32 10, label %18
i32 13, label %20
i32 9, label %22
i32 12, label %24
i32 92, label %26
]
14: ; preds = %12
%15 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 48)
br label %32
16: ; preds = %12
%17 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 98)
br label %32
18: ; preds = %12
%19 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 110)
br label %32
20: ; preds = %12
%21 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 114)
br label %32
22: ; preds = %12
%23 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 116)
br label %32
24: ; preds = %12
%25 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 102)
br label %32
26: ; preds = %12
%27 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 92)
br label %32
28: ; preds = %12
%29 = and i32 %0, 255
%30 = zext i32 %29 to i64
%31 = tail call i32 (i64, i32, i32, i32, i32, ...) bitcast (i32 (...)* @printnum to i32 (i64, i32, i32, i32, i32, ...)*)(i64 %30, i32 8, i32 0, i32 3, i32 48)
br label %32
32: ; preds = %14, %16, %18, %20, %22, %24, %26, %28, %10
%33 = phi i32 [ 1, %10 ], [ 4, %28 ], [ 2, %26 ], [ 2, %24 ], [ 2, %22 ], [ 2, %20 ], [ 2, %18 ], [ 2, %16 ], [ 2, %14 ]
ret i32 %33
}