char *character(c)
int c;
{
  static char string[10];
  char *meta;
  meta = (c & 0x80) ? "M-" : "";
  c &= 0x7F;
  if (c < 32)
    sprintf(string, "%s^%c", meta, (int)c + '@');
  else if (c == 127)
    sprintf(string, "%s^?", meta);
  else
    sprintf(string, "%s%c", meta, c);
  return (string);
}


x86 assembly (clang, -O0):
<character>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edx
and    $0x80,%edx
lea    0xed7(%rip),%rax
lea    0xece(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0x7f,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x20,-0x4(%rbp)
jge    1174 <character+0x64>
mov    -0x10(%rbp),%rdx
mov    -0x4(%rbp),%ecx
add    $0x40,%ecx
lea    0x2ec8(%rip),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    11bd <character+0xad>
cmpl   $0x7f,-0x4(%rbp)
jne    119c <character+0x8c>
mov    -0x10(%rbp),%rdx
lea    0x2ea0(%rip),%rdi
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    11b8 <character+0xa8>
mov    -0x10(%rbp),%rdx
mov    -0x4(%rbp),%ecx
lea    0x2e7f(%rip),%rdi
lea    0xe5d(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    11bd <character+0xad>
lea    0x2e65(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<character>:
push   %rax
mov    %edi,%ecx
test   $0x80,%cl
lea    0xee5(%rip),%rax
lea    0xedc(%rip),%rdx
cmove  %rax,%rdx
and    $0x7f,%ecx
cmp    $0x1f,%ecx
ja     1143 <character+0x33>
add    $0x40,%ecx
lea    0x2eef(%rip),%rdi
lea    0xec2(%rip),%rsi
jmp    1166 <character+0x56>
lea    0x2edf(%rip),%rdi
cmp    $0x7f,%ecx
jne    115f <character+0x4f>
lea    0xeb3(%rip),%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    116d <character+0x5d>
lea    0xea8(%rip),%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
lea    0x2eb5(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@character.string = internal global [10 x i8] zeroinitializer
@.str = [3 x i8] c"M-\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [6 x i8] c"%s^%c\00"
@.str.3 = [5 x i8] c"%s^?\00"
@.str.4 = [5 x i8] c"%s%c\00"
define i8* @character(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = and i32 %4, 128
%6 = icmp ne i32 %5, 0
%7 = zext i1 %6 to i64
%8 = select i1 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
store i8* %8, i8** %3
%9 = load i32, i32* %2
%10 = and i32 %9, 127
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 32
br i1 %12, label %13, label %18
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 64
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @character.string, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32 %16)
br label %29
18: ; preds = %1
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 127
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i8*, i8** %3
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @character.string, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %28
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = load i32, i32* %2
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @character.string, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %25, i32 %26)
br label %28
28: ; preds = %24, %21
br label %29
29: ; preds = %28, %13
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @character.string, i64 0, i64 0)
}

LLVM IR (-O2):
@character.string = internal global [10 x i8] zeroinitializer
@.str = [3 x i8] c"M-\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [6 x i8] c"%s^%c\00"
@.str.3 = [5 x i8] c"%s^?\00"
@.str.4 = [5 x i8] c"%s%c\00"
define i8* @character(i32 %0) {
%2 = and i32 %0, 128
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0)
%5 = and i32 %0, 127
%6 = icmp ult i32 %5, 32
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = add nuw nsw i32 %5, 64
%9 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @character.string, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %4, i32 %8)
br label %16
10: ; preds = %1
%11 = icmp eq i32 %5, 127
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @character.string, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %16
14: ; preds = %10
%15 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @character.string, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %4, i32 %5)
br label %16
16: ; preds = %12, %14, %7
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @character.string, i64 0, i64 0)
}