char *catfil(num)
int num;
{
  static char catdir[] = {"/catalog/catdir.cat"};
  static char catent[] = {"/catalog/c000000.cat"};
  char *cfield;
  int k, iq;
  if (num == 0)
    return catdir;
  cfield = &catent[16];
  for (k = 0; k < 6; ++k) {
    iq = num;
    num = num / 10;
    --cfield;
    *cfield = (char)('0' + (iq - num * 10));
  }
  return catent;
}


x86 assembly (clang, -O0):
<catfil>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1121 <catfil+0x21>
lea    0x2f18(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118e <catfil+0x8e>
lea    0x2f28(%rip),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x6,-0x1c(%rbp)
jge    1183 <catfil+0x83>
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
imul   $0xa,-0xc(%rbp),%ecx
sub    %ecx,%eax
add    $0x30,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <catfil+0x37>
lea    0x2ec6(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<catfil>:
test   %edi,%edi
je     11f6 <catfil+0xf6>
movslq %edi,%rcx
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x22,%rdx
add    %eax,%edx
lea    (%rdx,%rdx,1),%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
add    $0x30,%dil
mov    %dil,0x2f2d(%rip)
lea    0x2f17(%rip),%rax
imul   $0x51eb851f,%rcx,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x25,%rsi
add    %edi,%esi
lea    (%rsi,%rsi,1),%edi
lea    (%rdi,%rdi,4),%edi
sub    %edi,%edx
add    $0x30,%dl
mov    %dl,0x2f00(%rip)
imul   $0x10624dd3,%rcx,%rdx
mov    %rdx,%rdi
shr    $0x3f,%rdi
sar    $0x26,%rdx
add    %edi,%edx
lea    (%rdx,%rdx,1),%edi
lea    (%rdi,%rdi,4),%edi
sub    %edi,%esi
add    $0x30,%sil
mov    %sil,0x2ed8(%rip)
imul   $0x68db8bad,%rcx,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x2c,%rsi
add    %edi,%esi
lea    (%rsi,%rsi,1),%edi
lea    (%rdi,%rdi,4),%edi
sub    %edi,%edx
add    $0x30,%dl
mov    %dl,0x2eb2(%rip)
imul   $0x14f8b589,%rcx,%rdx
mov    %rdx,%rdi
shr    $0x3f,%rdi
sar    $0x2d,%rdx
add    %edi,%edx
lea    (%rdx,%rdx,1),%edi
lea    (%rdi,%rdi,4),%edi
sub    %edi,%esi
add    $0x30,%sil
mov    %sil,0x2e8a(%rip)
imul   $0x431bde83,%rcx,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
shr    $0x32,%rcx
add    %esi,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%edx
add    $0x30,%dl
mov    %dl,0x2e65(%rip)
ret
lea    0x2e33(%rip),%rax
ret

LLVM IR (-O0):
@catfil.catdir = internal global [20 x i8] c"/catalog/catdir.cat\00"
@catfil.catent = internal global [21 x i8] c"/catalog/c000000.cat\00"
define i8* @catfil(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @catfil.catdir, i64 0, i64 0), i8** %2
br label %31
10: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @catfil.catent, i64 0, i64 16), i8** %4
store i32 0, i32* %5
br label %11
11: ; preds = %27, %10
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 6
br i1 %13, label %14, label %30
14: ; preds = %11
%15 = load i32, i32* %3
store i32 %15, i32* %6
%16 = load i32, i32* %3
%17 = sdiv i32 %16, 10
store i32 %17, i32* %3
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i32 -1
store i8* %19, i8** %4
%20 = load i32, i32* %6
%21 = load i32, i32* %3
%22 = mul nsw i32 %21, 10
%23 = sub nsw i32 %20, %22
%24 = add nsw i32 48, %23
%25 = trunc i32 %24 to i8
%26 = load i8*, i8** %4
store i8 %25, i8* %26
br label %27
27: ; preds = %14
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %11
30: ; preds = %11
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @catfil.catent, i64 0, i64 0), i8** %2
br label %31
31: ; preds = %30, %9
%32 = load i8*, i8** %2
ret i8* %32
}

LLVM IR (-O2):
@catfil.catdir = internal global [20 x i8] c"/catalog/catdir.cat\00"
@catfil.catent = internal global [21 x i8] c"/catalog/c000000.cat\00"
define i8* @catfil(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %34, label %3
3: ; preds = %1
%4 = sdiv i32 %0, 10
%5 = mul nsw i32 %4, -10
%6 = add i32 %5, %0
%7 = trunc i32 %6 to i8
%8 = add i8 %7, 48
store i8 %8, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @catfil.catent, i64 0, i64 15)
%9 = sdiv i32 %0, 100
%10 = mul nsw i32 %9, -10
%11 = add nsw i32 %10, %4
%12 = trunc i32 %11 to i8
%13 = add i8 %12, 48
store i8 %13, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @catfil.catent, i64 0, i64 14)
%14 = sdiv i32 %0, 1000
%15 = mul nsw i32 %14, -10
%16 = add nsw i32 %15, %9
%17 = trunc i32 %16 to i8
%18 = add i8 %17, 48
store i8 %18, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @catfil.catent, i64 0, i64 13)
%19 = sdiv i32 %0, 10000
%20 = mul nsw i32 %19, -10
%21 = add nsw i32 %20, %14
%22 = trunc i32 %21 to i8
%23 = add i8 %22, 48
store i8 %23, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @catfil.catent, i64 0, i64 12)
%24 = sdiv i32 %0, 100000
%25 = mul nsw i32 %24, -10
%26 = add nsw i32 %25, %19
%27 = trunc i32 %26 to i8
%28 = add i8 %27, 48
store i8 %28, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @catfil.catent, i64 0, i64 11)
%29 = sdiv i32 %0, 1000000
%30 = mul nsw i32 %29, -10
%31 = add nsw i32 %30, %24
%32 = trunc i32 %31 to i8
%33 = add i8 %32, 48
store i8 %33, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @catfil.catent, i64 0, i64 10)
br label %34
34: ; preds = %3, %1
%35 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @catfil.catdir, i64 0, i64 0), %1 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @catfil.catent, i64 0, i64 0), %3 ]
ret i8* %35
}