char *dbchr(c)
int c;
{
  static char s[8];
  char *cp = s;
  c &= 0xff;
  if (c & 0x80) {
    *cp++ = '~';
    c &= 0x7f;
  }
  if (c < 32) {
    *cp++ = '^';
    *cp++ = (char)(((c) ^ 64) & 0xFF);
  } else if (c == 127) {
    *cp++ = '^';
    *cp++ = '?';
  } else {
    *cp++ = (char)c;
  }
  *cp = '\0';
  cp = s;
  return (cp);
}


x86 assembly (clang, -O0):
<dbchr>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
lea    0x2f13(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1149 <dbchr+0x49>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x7e,(%rax)
mov    -0x4(%rbp),%eax
and    $0x7f,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x20,-0x4(%rbp)
jge    1188 <dbchr+0x88>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x5e,(%rax)
mov    -0x4(%rbp),%eax
xor    $0x40,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    11d6 <dbchr+0xd6>
cmpl   $0x7f,-0x4(%rbp)
jne    11bb <dbchr+0xbb>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x5e,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x3f,(%rax)
jmp    11d1 <dbchr+0xd1>
mov    -0x4(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    11d6 <dbchr+0xd6>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e3d(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<dbchr>:
test   $0x80,%dil
jne    1126 <dbchr+0x26>
movzbl %dil,%edi
lea    0x2f10(%rip),%rax
cmp    $0x1f,%edi
jbe    113c <dbchr+0x3c>
cmp    $0x7f,%edi
jne    114d <dbchr+0x4d>
movw   $0x3f5e,(%rax)
add    $0x2,%rax
jmp    1154 <dbchr+0x54>
movb   $0x7e,0x2ef4(%rip)
and    $0x7f,%edi
lea    0x2eeb(%rip),%rax
cmp    $0x1f,%edi
ja     1116 <dbchr+0x16>
movb   $0x5e,(%rax)
xor    $0x40,%dil
mov    %dil,0x1(%rax)
add    $0x2,%rax
jmp    1154 <dbchr+0x54>
mov    %dil,(%rax)
add    $0x1,%rax
movb   $0x0,(%rax)
lea    0x2ec3(%rip),%rax
ret

LLVM IR (-O0):
@dbchr.s = internal global [8 x i8] zeroinitializer
define i8* @dbchr(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @dbchr.s, i64 0, i64 0), i8** %3
%4 = load i32, i32* %2
%5 = and i32 %4, 255
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = and i32 %6, 128
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %3
store i8 126, i8* %10
%12 = load i32, i32* %2
%13 = and i32 %12, 127
store i32 %13, i32* %2
br label %14
14: ; preds = %9, %1
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 32
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
store i8 94, i8* %18
%20 = load i32, i32* %2
%21 = xor i32 %20, 64
%22 = and i32 %21, 255
%23 = trunc i32 %22 to i8
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %3
store i8 %23, i8* %24
br label %40
26: ; preds = %14
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 127
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %3
store i8 94, i8* %30
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %3
store i8 63, i8* %32
br label %39
34: ; preds = %26
%35 = load i32, i32* %2
%36 = trunc i32 %35 to i8
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %3
store i8 %36, i8* %37
br label %39
39: ; preds = %34, %29
br label %40
40: ; preds = %39, %17
%41 = load i8*, i8** %3
store i8 0, i8* %41
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @dbchr.s, i64 0, i64 0), i8** %3
%42 = load i8*, i8** %3
ret i8* %42
}

LLVM IR (-O2):
@dbchr.s = internal global [8 x i8] zeroinitializer
define i8* @dbchr(i32 %0) {
%2 = and i32 %0, 255
%3 = and i32 %0, 128
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
store i8 126, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @dbchr.s, i64 0, i64 0)
%6 = and i32 %0, 127
br label %7
7: ; preds = %5, %1
%8 = phi i32 [ %6, %5 ], [ %2, %1 ]
%9 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @dbchr.s, i64 0, i64 1), %5 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @dbchr.s, i64 0, i64 0), %1 ]
%10 = icmp ult i32 %8, 32
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %9, i64 1
store i8 94, i8* %9
%13 = trunc i32 %8 to i8
%14 = xor i8 %13, 64
%15 = getelementptr inbounds i8, i8* %9, i64 2
store i8 %14, i8* %12
br label %24
16: ; preds = %7
%17 = icmp eq i32 %8, 127
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = getelementptr inbounds i8, i8* %9, i64 1
store i8 94, i8* %9
%20 = getelementptr inbounds i8, i8* %9, i64 2
store i8 63, i8* %19
br label %24
21: ; preds = %16
%22 = trunc i32 %8 to i8
%23 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %22, i8* %9
br label %24
24: ; preds = %18, %21, %11
%25 = phi i8* [ %15, %11 ], [ %20, %18 ], [ %23, %21 ]
store i8 0, i8* %25
ret i8* getelementptr inbounds ([8 x i8], [8 x i8]* @dbchr.s, i64 0, i64 0)
}