char *m_name(num) {
  static char name[4];
  register char *cp;
  register int i;
  name[0] = 0;
  name[1] = 0;
  name[2] = 0;
  name[3] = 0;
  i = num;
  cp = &name[3];
  if (i > 0 && i < 1000)
    do {
      *--cp = (i % 10) + '0';
      i /= 10;
    } while (i);
  else
    *--cp = '?';
  return (cp);
}


x86 assembly (clang, -O0):
<m_name>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movb   $0x0,0x2f13(%rip)
movb   $0x0,0x2f0d(%rip)
movb   $0x0,0x2f07(%rip)
movb   $0x0,0x2f01(%rip)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    0x2ef1(%rip),%rax
add    $0x3,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1193 <m_name+0x93>
cmpl   $0x3e8,-0x14(%rbp)
jge    1193 <m_name+0x93>
jmp    1154 <m_name+0x54>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1154 <m_name+0x54>
jmp    11a6 <m_name+0xa6>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x3f,-0x1(%rax)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<m_name>:
lea    -0x1(%rdi),%eax
movl   $0x0,0x2f17(%rip)
cmp    $0x3e6,%eax
ja     1156 <m_name+0x56>
lea    0x2f0c(%rip),%rax
nopl   0x0(%rax,%rax,1)
movslq %edi,%rcx
imul   $0x66666667,%rcx,%rdi
mov    %rdi,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rdi
add    %edx,%edi
lea    (%rdi,%rdi,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ecx,%esi
sub    %edx,%esi
add    $0x30,%sil
mov    %sil,-0x1(%rax)
add    $0xffffffffffffffff,%rax
add    $0x9,%ecx
cmp    $0x13,%ecx
jae    1120 <m_name+0x20>
ret
movb   $0x3f,0x2ec9(%rip)
lea    0x2ec2(%rip),%rax
ret

LLVM IR (-O0):
@m_name.name = internal global [4 x i8] zeroinitializer
define i8* @m_name(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i32 %0, i32* %2
store i8 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @m_name.name, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @m_name.name, i64 0, i64 1)
store i8 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @m_name.name, i64 0, i64 2)
store i8 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @m_name.name, i64 0, i64 3)
%5 = load i32, i32* %2
store i32 %5, i32* %4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @m_name.name, i64 0, i64 3), i8** %3
%6 = load i32, i32* %4
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %25
8: ; preds = %1
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 1000
br i1 %10, label %11, label %25
11: ; preds = %8
br label %12
12: ; preds = %21, %11
%13 = load i32, i32* %4
%14 = srem i32 %13, 10
%15 = add nsw i32 %14, 48
%16 = trunc i32 %15 to i8
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 -1
store i8* %18, i8** %3
store i8 %16, i8* %18
%19 = load i32, i32* %4
%20 = sdiv i32 %19, 10
store i32 %20, i32* %4
br label %21
21: ; preds = %12
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 0
br i1 %23, label %12, label %24
24: ; preds = %21
br label %28
25: ; preds = %8, %1
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i32 -1
store i8* %27, i8** %3
store i8 63, i8* %27
br label %28
28: ; preds = %25, %24
%29 = load i8*, i8** %3
ret i8* %29
}

LLVM IR (-O2):
@m_name.name = internal global [4 x i8] zeroinitializer
define i8* @m_name(i32 %0) {
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 999
store i32 0, i32* bitcast ([4 x i8]* @m_name.name to i32*)
br i1 %3, label %4, label %14
4: ; preds = %1, %4
%5 = phi i8* [ %10, %4 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @m_name.name, i64 0, i64 3), %1 ]
%6 = phi i32 [ %11, %4 ], [ %0, %1 ]
%7 = srem i32 %6, 10
%8 = trunc i32 %7 to i8
%9 = add nsw i8 %8, 48
%10 = getelementptr inbounds i8, i8* %5, i64 -1
store i8 %9, i8* %10
%11 = sdiv i32 %6, 10
%12 = add i32 %6, 9
%13 = icmp ult i32 %12, 19
br i1 %13, label %15, label %4
14: ; preds = %1
store i8 63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @m_name.name, i64 0, i64 2)
br label %15
15: ; preds = %4, %14
%16 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @m_name.name, i64 0, i64 2), %14 ], [ %10, %4 ]
ret i8* %16
}