char *getnm(uid)
int uid;
{
  static char namewd[8 + 1];
  register int i;
  i = 8;
  namewd[8] = 0;
  while (i > 1 && uid > 0) {
    namewd[--i] = '0' + uid % 10;
    uid /= 10;
  }
  return &namewd[i];
}


x86 assembly (clang, -O0):
<getnm>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x8,-0x8(%rbp)
movb   $0x0,0x2f14(%rip)
xor    %eax,%eax
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jle    112e <getnm+0x2e>
cmpl   $0x0,-0x4(%rbp)
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    113e <getnm+0x3e>
jmp    1175 <getnm+0x75>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
movslq %eax,%rcx
lea    0x2ec2(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1115 <getnm+0x15>
movslq -0x8(%rbp),%rcx
lea    0x2ea1(%rip),%rax
add    %rcx,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getnm>:
movb   $0x0,0x2f22(%rip)
test   %edi,%edi
jle    1279 <getnm+0x179>
mov    %edi,%r8d
mov    $0xcccccccd,%esi
mov    %r8,%rdx
imul   %rsi,%rdx
shr    $0x23,%rdx
lea    (%rdx,%rdx,1),%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %edi,%eax
sub    %ecx,%eax
or     $0x30,%al
mov    %al,0x2ef4(%rip)
mov    $0x7,%ecx
cmp    $0xa,%edi
jb     127e <getnm+0x17e>
mov    %edx,%eax
imul   %rsi,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edx
or     $0x30,%dl
mov    %dl,0x2ecb(%rip)
mov    $0x6,%ecx
cmp    $0x64,%edi
jb     127e <getnm+0x17e>
imul   $0x51eb851f,%r8,%rax
shr    $0x25,%rax
mov    $0xcccccccd,%edx
mov    %rax,%rcx
imul   %rdx,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
or     $0x30,%al
mov    %al,0x2e92(%rip)
mov    $0x5,%ecx
cmp    $0x3e8,%edi
jb     127e <getnm+0x17e>
imul   $0x10624dd3,%r8,%rax
shr    $0x26,%rax
mov    %rax,%rcx
imul   %rdx,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
or     $0x30,%al
mov    %al,0x2e5b(%rip)
mov    $0x4,%ecx
cmp    $0x2710,%edi
jb     127e <getnm+0x17e>
mov    $0xd1b71759,%eax
imul   %r8,%rax
shr    $0x2d,%rax
mov    $0xcccccccd,%edx
mov    %rax,%rcx
imul   %rdx,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
or     $0x30,%al
mov    %al,0x2e1d(%rip)
mov    $0x3,%ecx
cmp    $0x186a0,%edi
jb     127e <getnm+0x17e>
mov    %edi,%eax
shr    $0x5,%eax
imul   $0xa7c5ac5,%rax,%rax
shr    $0x27,%rax
mov    %rax,%rcx
imul   %rdx,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
or     $0x30,%al
mov    %al,0x2de5(%rip)
mov    $0x2,%ecx
cmp    $0xf4240,%edi
jb     127e <getnm+0x17e>
imul   $0x431bde83,%r8,%rax
shr    $0x32,%rax
mov    $0xcccccccd,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
or     $0x30,%al
mov    %al,0x2db0(%rip)
mov    $0x1,%ecx
jmp    127e <getnm+0x17e>
mov    $0x8,%ecx
lea    0x2d9c(%rip),%rax
add    %rcx,%rax
ret

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

LLVM IR (-O2):
@getnm.namewd = internal global [9 x i8] zeroinitializer
define i8* @getnm(i32 %0) {
store i8 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @getnm.namewd, i64 0, i64 8)
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %43
3: ; preds = %1
%4 = urem i32 %0, 10
%5 = udiv i32 %0, 10
%6 = trunc i32 %4 to i8
%7 = or i8 %6, 48
store i8 %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @getnm.namewd, i64 0, i64 7)
%8 = icmp ugt i32 %0, 9
br i1 %8, label %9, label %43
9: ; preds = %3
%10 = urem i32 %5, 10
%11 = trunc i32 %10 to i8
%12 = or i8 %11, 48
store i8 %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @getnm.namewd, i64 0, i64 6)
%13 = icmp ugt i32 %0, 99
br i1 %13, label %14, label %43
14: ; preds = %9
%15 = udiv i32 %0, 100
%16 = urem i32 %15, 10
%17 = trunc i32 %16 to i8
%18 = or i8 %17, 48
store i8 %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @getnm.namewd, i64 0, i64 5)
%19 = icmp ugt i32 %0, 999
br i1 %19, label %20, label %43
20: ; preds = %14
%21 = udiv i32 %0, 1000
%22 = urem i32 %21, 10
%23 = trunc i32 %22 to i8
%24 = or i8 %23, 48
store i8 %24, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @getnm.namewd, i64 0, i64 4)
%25 = icmp ugt i32 %0, 9999
br i1 %25, label %26, label %43
26: ; preds = %20
%27 = udiv i32 %0, 10000
%28 = urem i32 %27, 10
%29 = trunc i32 %28 to i8
%30 = or i8 %29, 48
store i8 %30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @getnm.namewd, i64 0, i64 3)
%31 = icmp ugt i32 %0, 99999
br i1 %31, label %32, label %43
32: ; preds = %26
%33 = udiv i32 %0, 100000
%34 = urem i32 %33, 10
%35 = trunc i32 %34 to i8
%36 = or i8 %35, 48
store i8 %36, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @getnm.namewd, i64 0, i64 2)
%37 = icmp ugt i32 %0, 999999
br i1 %37, label %38, label %43
38: ; preds = %32
%39 = udiv i32 %0, 1000000
%40 = urem i32 %39, 10
%41 = trunc i32 %40 to i8
%42 = or i8 %41, 48
store i8 %42, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @getnm.namewd, i64 0, i64 1)
br label %43
43: ; preds = %3, %9, %14, %20, %26, %32, %38, %1
%44 = phi i64 [ 8, %1 ], [ 7, %3 ], [ 6, %9 ], [ 5, %14 ], [ 4, %20 ], [ 3, %26 ], [ 2, %32 ], [ 1, %38 ]
%45 = getelementptr inbounds [9 x i8], [9 x i8]* @getnm.namewd, i64 0, i64 %44
ret i8* %45
}