#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *numFilename(char *fname, int num, int ofnum) {
  static char fnamenum[256];
  int len;
  int offset = 1;
  strcpy(fnamenum, fname);
  len = strlen(fnamenum);
  do {
    fnamenum[len - offset] = '0' + (num % 10);
    num /= 10;
    ofnum /= 10;
    offset++;
  } while (ofnum >= 1 && offset < 4);
  return fnamenum;
}


x86 assembly (clang, -O0):
<numFilename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0x2efc(%rip),%rdi
call   1030 <strcpy@plt>
lea    0x2ef0(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
movslq %eax,%rcx
lea    0x2eca(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x10(%rbp)
mov    %al,-0x19(%rbp)
jl     11b7 <numFilename+0x97>
cmpl   $0x4,-0x18(%rbp)
setl   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1158 <numFilename+0x38>
lea    0x2e77(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numFilename>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%rsi
lea    0x2f0e(%rip),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movslq %ebx,%rcx
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
add    %esi,%edx
lea    (%rdx,%rdx,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %ecx,%edi
sub    %esi,%edi
add    $0x30,%dil
mov    %dil,-0x1(%rax,%r14,1)
cmp    $0xa,%ebp
jl     11d8 <numFilename+0xb8>
movslq %edx,%rsi
imul   $0x66666667,%rsi,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rsi
add    %edi,%esi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
sub    %esi,%edx
add    $0x30,%dl
mov    %dl,-0x2(%rax,%r14,1)
cmp    $0x64,%ebp
jl     11d8 <numFilename+0xb8>
imul   $0x51eb851f,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
shr    $0x22,%rdx
add    %esi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%ecx
add    $0x30,%cl
mov    %cl,-0x3(%rax,%r14,1)
lea    0x2e61(%rip),%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@numFilename.fnamenum = internal global [256 x i8] zeroinitializer
define i8* @numFilename(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 1, i32* %8
%9 = load i8*, i8** %4
%10 = call i32 @strcpy(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @numFilename.fnamenum, i64 0, i64 0), i8* %9)
%11 = call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @numFilename.fnamenum, i64 0, i64 0))
store i32 %11, i32* %7
br label %12
12: ; preds = %34, %3
%13 = load i32, i32* %5
%14 = srem i32 %13, 10
%15 = add nsw i32 48, %14
%16 = trunc i32 %15 to i8
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = sub nsw i32 %17, %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [256 x i8], [256 x i8]* @numFilename.fnamenum, i64 0, i64 %20
store i8 %16, i8* %21
%22 = load i32, i32* %5
%23 = sdiv i32 %22, 10
store i32 %23, i32* %5
%24 = load i32, i32* %6
%25 = sdiv i32 %24, 10
store i32 %25, i32* %6
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %28
28: ; preds = %12
%29 = load i32, i32* %6
%30 = icmp sge i32 %29, 1
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %8
%33 = icmp slt i32 %32, 4
br label %34
34: ; preds = %31, %28
%35 = phi i1 [ false, %28 ], [ %33, %31 ]
br i1 %35, label %12, label %36
36: ; preds = %34
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @numFilename.fnamenum, i64 0, i64 0)
}

LLVM IR (-O2):
@numFilename.fnamenum = internal global [256 x i8] zeroinitializer
define i8* @numFilename(i8* %0, i32 %1, i32 %2) {
%4 = tail call i32 @strcpy(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @numFilename.fnamenum, i64 0, i64 0), i8* %0)
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @numFilename.fnamenum, i64 0, i64 0))
%6 = sext i32 %5 to i64
%7 = srem i32 %1, 10
%8 = sdiv i32 %1, 10
%9 = trunc i32 %7 to i8
%10 = add nsw i8 %9, 48
%11 = add nsw i64 %6, -1
%12 = getelementptr inbounds [256 x i8], [256 x i8]* @numFilename.fnamenum, i64 0, i64 %11
store i8 %10, i8* %12
%13 = icmp sgt i32 %2, 9
br i1 %13, label %14, label %28
14: ; preds = %3
%15 = srem i32 %8, 10
%16 = trunc i32 %15 to i8
%17 = add nsw i8 %16, 48
%18 = add nsw i64 %6, -2
%19 = getelementptr inbounds [256 x i8], [256 x i8]* @numFilename.fnamenum, i64 0, i64 %18
store i8 %17, i8* %19
%20 = icmp sgt i32 %2, 99
br i1 %20, label %21, label %28
21: ; preds = %14
%22 = sdiv i32 %1, 100
%23 = srem i32 %22, 10
%24 = trunc i32 %23 to i8
%25 = add nsw i8 %24, 48
%26 = add nsw i64 %6, -3
%27 = getelementptr inbounds [256 x i8], [256 x i8]* @numFilename.fnamenum, i64 0, i64 %26
store i8 %25, i8* %27
br label %28
28: ; preds = %21, %14, %3
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @numFilename.fnamenum, i64 0, i64 0)
}