char *control(c)
register int c;
{
  static char buf[3];
  if (c == 0x7f)
    return ("^?");
  if (c == '\377') {
    return "off";
  }
  if (c >= 0x20) {
    buf[0] = c;
    buf[1] = 0;
  } else {
    buf[0] = '^';
    buf[1] = '@' + c;
    buf[2] = 0;
  }
  return (buf);
}


x86 assembly (clang, -O0):
<control>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
cmpl   $0x7f,-0xc(%rbp)
jne    1121 <control+0x21>
lea    0xee8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117f <control+0x7f>
cmpl   $0xffffffff,-0xc(%rbp)
jne    113b <control+0x3b>
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117f <control+0x7f>
cmpl   $0x20,-0xc(%rbp)
jl     115a <control+0x5a>
mov    -0xc(%rbp),%eax
mov    %al,0x2ed3(%rip)
movb   $0x0,0x2ecd(%rip)
jmp    1174 <control+0x74>
movb   $0x5e,0x2ec0(%rip)
mov    -0xc(%rbp),%eax
add    $0x40,%eax
mov    %al,0x2eb5(%rip)
movb   $0x0,0x2eaf(%rip)
lea    0x2ea6(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<control>:
cmp    $0x7f,%edi
je     1112 <control+0x12>
cmp    $0xffffffff,%edi
jne    111a <control+0x1a>
lea    0xef2(%rip),%rax
ret
lea    0xee7(%rip),%rax
ret
cmp    $0x20,%edi
jl     1135 <control+0x35>
mov    %dil,0x2efb(%rip)
lea    0x2ef4(%rip),%rax
movb   $0x0,0x2eee(%rip)
ret
movb   $0x5e,0x2ee5(%rip)
lea    0x2ede(%rip),%rax
add    $0x40,%dil
mov    %dil,0x2ed4(%rip)
movb   $0x0,0x2ece(%rip)
ret

LLVM IR (-O0):
@control.buf = internal global [3 x i8] zeroinitializer
@.str = [3 x i8] c"^?\00"
@.str.1 = [4 x i8] c"off\00"
define i8* @control(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 127
br i1 %5, label %6, label %7
6: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2
br label %22
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %11
10: ; preds = %7
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %22
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp sge i32 %12, 32
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %3
%16 = trunc i32 %15 to i8
store i8 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @control.buf, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @control.buf, i64 0, i64 1)
br label %21
17: ; preds = %11
store i8 94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @control.buf, i64 0, i64 0)
%18 = load i32, i32* %3
%19 = add nsw i32 64, %18
%20 = trunc i32 %19 to i8
store i8 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @control.buf, i64 0, i64 1)
store i8 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @control.buf, i64 0, i64 2)
br label %21
21: ; preds = %17, %14
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @control.buf, i64 0, i64 0), i8** %2
br label %22
22: ; preds = %21, %10, %6
%23 = load i8*, i8** %2
ret i8* %23
}

LLVM IR (-O2):
@control.buf = internal global [3 x i8] zeroinitializer
@.str = [3 x i8] c"^?\00"
@.str.1 = [4 x i8] c"off\00"
define i8* @control(i32 %0) {
switch i32 %0, label %3 [
i32 127, label %10
i32 -1, label %2
]
2: ; preds = %1
br label %10
3: ; preds = %1
%4 = icmp sgt i32 %0, 31
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = trunc i32 %0 to i8
store i8 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @control.buf, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @control.buf, i64 0, i64 1)
br label %10
7: ; preds = %3
store i8 94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @control.buf, i64 0, i64 0)
%8 = trunc i32 %0 to i8
%9 = add i8 %8, 64
store i8 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @control.buf, i64 0, i64 1)
store i8 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @control.buf, i64 0, i64 2)
br label %10
10: ; preds = %5, %7, %1, %2
%11 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @control.buf, i64 0, i64 0), %7 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @control.buf, i64 0, i64 0), %5 ]
ret i8* %11
}