#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*/ sprintf(char *, char *, int);
void Rename_GEN_NEW_FILE_REF_pad_nbrStr(int _nn, char *_ss) {
  if (_nn < 10) {
    sprintf(_ss, "0000%d", _nn);
  } else if (_nn < 100) {
    sprintf(_ss, "000%d", _nn);
  } else if (_nn < 1000) {
    sprintf(_ss, "00%d", _nn);
  } else if (_nn < 10000) {
    sprintf(_ss, "0%d", _nn);
  } else {
    sprintf(_ss, "%d", _nn);
  }
}


x86 assembly (clang, -O0):
<Rename_GEN_NEW_FILE_REF_pad_nbrStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    1141 <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0x31>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xec9(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11cf <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0xbf>
cmpl   $0x64,-0x4(%rbp)
jge    1163 <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0x53>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xea8(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11ca <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0xba>
cmpl   $0x3e8,-0x4(%rbp)
jge    1188 <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0x78>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe84(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11c5 <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0xb5>
cmpl   $0x2710,-0x4(%rbp)
jge    11ad <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0x9d>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe60(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11c0 <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0xb0>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe49(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11c5 <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0xb5>
jmp    11ca <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0xba>
jmp    11cf <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0xbf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Rename_GEN_NEW_FILE_REF_pad_nbrStr>:
mov    %rsi,%rax
mov    %edi,%edx
cmp    $0xa,%edi
jge    1129 <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0x19>
lea    0xedf(%rip),%rsi
mov    %rax,%rdi
jmp    1030 <sprintf@plt>
cmp    $0x64,%edx
jae    113d <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0x2d>
lea    0xecc(%rip),%rsi
mov    %rax,%rdi
jmp    1030 <sprintf@plt>
cmp    $0x3e8,%edx
jae    1154 <Rename_GEN_NEW_FILE_REF_pad_nbrStr+0x44>
lea    0xeb6(%rip),%rsi
mov    %rax,%rdi
jmp    1030 <sprintf@plt>
cmp    $0x2710,%edx
lea    0xea2(%rip),%rcx
lea    0xe9c(%rip),%rsi
cmovb  %rcx,%rsi
mov    %rax,%rdi
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"0000%d\00"
@.str.1 = [6 x i8] c"000%d\00"
@.str.2 = [5 x i8] c"00%d\00"
@.str.3 = [4 x i8] c"0%d\00"
@.str.4 = [3 x i8] c"%d\00"
define void @Rename_GEN_NEW_FILE_REF_pad_nbrStr(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = load i32, i32* %3
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %39
11: ; preds = %2
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 100
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i8*, i8** %4
%16 = load i32, i32* %3
%17 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %38
18: ; preds = %11
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 1000
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i8*, i8** %4
%23 = load i32, i32* %3
%24 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %37
25: ; preds = %18
%26 = load i32, i32* %3
%27 = icmp slt i32 %26, 10000
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i8*, i8** %4
%30 = load i32, i32* %3
%31 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30)
br label %36
32: ; preds = %25
%33 = load i8*, i8** %4
%34 = load i32, i32* %3
%35 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %32, %28
br label %37
37: ; preds = %36, %21
br label %38
38: ; preds = %37, %14
br label %39
39: ; preds = %38, %7
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"0000%d\00"
@.str.1 = [6 x i8] c"000%d\00"
@.str.2 = [5 x i8] c"00%d\00"
@.str.3 = [4 x i8] c"0%d\00"
@.str.4 = [3 x i8] c"%d\00"
define void @Rename_GEN_NEW_FILE_REF_pad_nbrStr(i32 %0, i8* nocapture writeonly %1) {
%3 = icmp slt i32 %0, 10
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = icmp ult i32 %0, 100
br i1 %5, label %11, label %6
6: ; preds = %4
%7 = icmp ult i32 %0, 1000
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = icmp ult i32 %0, 10000
%10 = select i1 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
br label %11
11: ; preds = %8, %6, %4, %2
%12 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %6 ], [ %10, %8 ]
%13 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) %12, i32 %0)
ret void
}