char *x_mapout(c)
int c;
{
  static char buf[8];
  char *p = buf;
  if (iscntrl(c)) {
    *p++ = '^';
    *p++ = ((c) == 0x7F ? '?' : (c) | 0x40);
  } else
    *p++ = c;
  *p = 0;
  return buf;
}


x86 assembly (clang, -O0):
<x_mapout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0x2f07(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <iscntrl@plt>
cmp    $0x0,%eax
je     1184 <x_mapout+0x74>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x5e,(%rax)
cmpl   $0x7f,-0x4(%rbp)
jne    1160 <x_mapout+0x50>
mov    $0x3f,%eax
mov    %eax,-0x14(%rbp)
jmp    1169 <x_mapout+0x59>
mov    -0x4(%rbp),%eax
or     $0x40,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    119a <x_mapout+0x8a>
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    0x2e81(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x_mapout>:
push   %rbx
mov    %edi,%ebx
call   1030 <iscntrl@plt>
test   %eax,%eax
je     1144 <x_mapout+0x34>
movb   $0x5e,0x2f06(%rip)
mov    %ebx,%eax
or     $0x40,%al
cmp    $0x7f,%ebx
movzbl %al,%eax
mov    $0x3f,%ecx
cmovne %eax,%ecx
mov    %cl,0x2eef(%rip)
lea    0x2ee9(%rip),%rax
jmp    1151 <x_mapout+0x41>
mov    %bl,0x2edf(%rip)
lea    0x2ed9(%rip),%rax
movb   $0x0,(%rax)
lea    0x2ece(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@x_mapout.buf = internal global [8 x i8] zeroinitializer
define i8* @x_mapout(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @x_mapout.buf, i64 0, i64 0), i8** %3
%4 = load i32, i32* %2
%5 = call i32 @iscntrl(i32 %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %21
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %3
store i8 94, i8* %8
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 127
br i1 %11, label %12, label %13
12: ; preds = %7
br label %16
13: ; preds = %7
%14 = load i32, i32* %2
%15 = or i32 %14, 64
br label %16
16: ; preds = %13, %12
%17 = phi i32 [ 63, %12 ], [ %15, %13 ]
%18 = trunc i32 %17 to i8
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
store i8 %18, i8* %19
br label %26
21: ; preds = %1
%22 = load i32, i32* %2
%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 %26
26: ; preds = %21, %16
%27 = load i8*, i8** %3
store i8 0, i8* %27
ret i8* getelementptr inbounds ([8 x i8], [8 x i8]* @x_mapout.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@x_mapout.buf = internal global [8 x i8] zeroinitializer
define i8* @x_mapout(i32 %0) {
%2 = tail call i32 @iscntrl(i32 %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %9, label %4
4: ; preds = %1
store i8 94, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @x_mapout.buf, i64 0, i64 0)
%5 = icmp eq i32 %0, 127
%6 = trunc i32 %0 to i8
%7 = or i8 %6, 64
%8 = select i1 %5, i8 63, i8 %7
store i8 %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @x_mapout.buf, i64 0, i64 1)
br label %11
9: ; preds = %1
%10 = trunc i32 %0 to i8
store i8 %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @x_mapout.buf, i64 0, i64 0)
br label %11
11: ; preds = %9, %4
%12 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @x_mapout.buf, i64 0, i64 2), %4 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @x_mapout.buf, i64 0, i64 1), %9 ]
store i8 0, i8* %12
ret i8* getelementptr inbounds ([8 x i8], [8 x i8]* @x_mapout.buf, i64 0, i64 0)
}