char *charep(c)
register int c;
{
  static char chrbuf[10];
  register char *cp;
  cp = chrbuf;
  if (c & 0400) {
    *cp++ = 'X';
    *cp++ = '-';
    c &= ~0400;
  }
  if (c & 0200) {
    *cp++ = 'M';
    *cp++ = '-';
    c &= ~0200;
  }
  if (c <= 037) {
    *cp++ = '^';
    c += 0100;
  }
  if (c == 0177) {
    *cp++ = 'D';
    *cp++ = 'E';
    *cp++ = 'L';
  } else
    *cp++ = c;
  *cp = 0;
  return (chrbuf);
}


x86 assembly (clang, -O0):
<charep>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
lea    0x2f13(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
je     1152 <charep+0x52>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x58,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x2d,(%rax)
mov    -0x4(%rbp),%eax
and    $0xfffffeff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1192 <charep+0x92>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x4d,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x2d,(%rax)
mov    -0x4(%rbp),%eax
and    $0xffffff7f,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x1f,-0x4(%rbp)
jg     11b7 <charep+0xb7>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x5e,(%rax)
mov    -0x4(%rbp),%eax
add    $0x40,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x7f,-0x4(%rbp)
jne    11fc <charep+0xfc>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x44,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x45,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x4c,(%rax)
jmp    1212 <charep+0x112>
mov    -0x4(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e01(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<charep>:
test   $0x100,%edi
jne    1117 <charep+0x17>
lea    0x2f12(%rip),%rax
test   $0x80,%dil
jne    1133 <charep+0x33>
jmp    1142 <charep+0x42>
movw   $0x2d58,0x2f01(%rip)
58 2d
and    $0xfffffeff,%edi
lea    0x2ef6(%rip),%rax
test   $0x80,%dil
je     1142 <charep+0x42>
movw   $0x2d4d,(%rax)
add    $0x2,%rax
and    $0xffffff7f,%edi
cmp    $0x1f,%edi
jg     1153 <charep+0x53>
movb   $0x5e,(%rax)
add    $0x1,%rax
add    $0x40,%edi
jmp    1167 <charep+0x67>
cmp    $0x7f,%edi
jne    1167 <charep+0x67>
movw   $0x4544,(%rax)
movb   $0x4c,0x2(%rax)
add    $0x3,%rax
jmp    116e <charep+0x6e>
mov    %dil,(%rax)
add    $0x1,%rax
movb   $0x0,(%rax)
lea    0x2ea9(%rip),%rax
ret

LLVM IR (-O0):
@charep.chrbuf = internal global [10 x i8] zeroinitializer
define i8* @charep(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @charep.chrbuf, i64 0, i64 0), i8** %3
%4 = load i32, i32* %2
%5 = and i32 %4, 256
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %3
store i8 88, i8* %8
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %3
store i8 45, i8* %10
%12 = load i32, i32* %2
%13 = and i32 %12, -257
store i32 %13, i32* %2
br label %14
14: ; preds = %7, %1
%15 = load i32, i32* %2
%16 = and i32 %15, 128
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
store i8 77, i8* %19
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
store i8 45, i8* %21
%23 = load i32, i32* %2
%24 = and i32 %23, -129
store i32 %24, i32* %2
br label %25
25: ; preds = %18, %14
%26 = load i32, i32* %2
%27 = icmp sle i32 %26, 31
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %3
store i8 94, i8* %29
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 64
store i32 %32, i32* %2
br label %33
33: ; preds = %28, %25
%34 = load i32, i32* %2
%35 = icmp eq i32 %34, 127
br i1 %35, label %36, label %43
36: ; preds = %33
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %3
store i8 68, i8* %37
%39 = load i8*, i8** %3
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %3
store i8 69, i8* %39
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %3
store i8 76, i8* %41
br label %48
43: ; preds = %33
%44 = load i32, i32* %2
%45 = trunc i32 %44 to i8
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %3
store i8 %45, i8* %46
br label %48
48: ; preds = %43, %36
%49 = load i8*, i8** %3
store i8 0, i8* %49
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @charep.chrbuf, i64 0, i64 0)
}

LLVM IR (-O2):
@charep.chrbuf = internal global [10 x i8] zeroinitializer
define i8* @charep(i32 %0) {
%2 = and i32 %0, 256
%3 = icmp eq i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
store i8 88, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @charep.chrbuf, i64 0, i64 0)
store i8 45, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @charep.chrbuf, i64 0, i64 1)
%5 = and i32 %0, -257
br label %6
6: ; preds = %4, %1
%7 = phi i32 [ %5, %4 ], [ %0, %1 ]
%8 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @charep.chrbuf, i64 0, i64 2), %4 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @charep.chrbuf, i64 0, i64 0), %1 ]
%9 = and i32 %7, 128
%10 = icmp eq i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %8, i64 1
store i8 77, i8* %8
%13 = getelementptr inbounds i8, i8* %8, i64 2
store i8 45, i8* %12
%14 = and i32 %7, -129
br label %15
15: ; preds = %11, %6
%16 = phi i32 [ %14, %11 ], [ %7, %6 ]
%17 = phi i8* [ %13, %11 ], [ %8, %6 ]
%18 = icmp slt i32 %16, 32
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = getelementptr inbounds i8, i8* %17, i64 1
store i8 94, i8* %17
%21 = add nsw i32 %16, 64
br label %28
22: ; preds = %15
%23 = icmp eq i32 %16, 127
br i1 %23, label %24, label %28
24: ; preds = %22
%25 = getelementptr inbounds i8, i8* %17, i64 1
store i8 68, i8* %17
%26 = getelementptr inbounds i8, i8* %17, i64 2
store i8 69, i8* %25
%27 = getelementptr inbounds i8, i8* %17, i64 3
store i8 76, i8* %26
br label %33
28: ; preds = %19, %22
%29 = phi i8* [ %20, %19 ], [ %17, %22 ]
%30 = phi i32 [ %21, %19 ], [ %16, %22 ]
%31 = trunc i32 %30 to i8
%32 = getelementptr inbounds i8, i8* %29, i64 1
store i8 %31, i8* %29
br label %33
33: ; preds = %28, %24
%34 = phi i8* [ %27, %24 ], [ %32, %28 ]
store i8 0, i8* %34
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @charep.chrbuf, i64 0, i64 0)
}