#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);
int /*<<< orphan*/ strcpy(char *, char *);
char *dispCacheIndex(int idx) {
  static char wk[32];
  if (idx < 0) {
    strcpy(wk, "---");
  } else if (idx >= 999) {
    strcpy(wk, "999");
  } else {
    sprintf(wk, "%03d", idx);
  }
  return wk;
}


x86 assembly (clang, -O0):
<dispCacheIndex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    114d <dispCacheIndex+0x2d>
lea    0x2f04(%rip),%rdi
lea    0xebd(%rip),%rsi
call   1030 <strcpy@plt>
jmp    118d <dispCacheIndex+0x6d>
cmpl   $0x3e7,-0x4(%rbp)
jl     1172 <dispCacheIndex+0x52>
lea    0x2edf(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1188 <dispCacheIndex+0x68>
mov    -0x4(%rbp),%edx
lea    0x2ec4(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1040 <sprintf@plt>
jmp    118d <dispCacheIndex+0x6d>
lea    0x2eac(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dispCacheIndex>:
push   %rax
test   %edi,%edi
js     1144 <dispCacheIndex+0x24>
mov    %edi,%edx
lea    0x2f12(%rip),%rdi
cmp    $0x3e7,%edx
jb     1159 <dispCacheIndex+0x39>
lea    0xec7(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1165 <dispCacheIndex+0x45>
lea    0x2ef5(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1165 <dispCacheIndex+0x45>
lea    0xea8(%rip),%rsi
call   1040 <sprintf@plt>
lea    0x2ed4(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@dispCacheIndex.wk = internal global [32 x i8] zeroinitializer
@.str = [4 x i8] c"---\00"
@.str.1 = [4 x i8] c"999\00"
@.str.2 = [5 x i8] c"%03d\00"
define i8* @dispCacheIndex(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 @strcpy(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dispCacheIndex.wk, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %16
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp sge i32 %8, 999
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @strcpy(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dispCacheIndex.wk, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %15
12: ; preds = %7
%13 = load i32, i32* %2
%14 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dispCacheIndex.wk, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %12, %10
br label %16
16: ; preds = %15, %5
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dispCacheIndex.wk, i64 0, i64 0)
}

LLVM IR (-O2):
@dispCacheIndex.wk = internal global [32 x i8] zeroinitializer
@.str = [4 x i8] c"---\00"
@.str.1 = [4 x i8] c"999\00"
@.str.2 = [5 x i8] c"%03d\00"
define i8* @dispCacheIndex(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @strcpy(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dispCacheIndex.wk, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %11
5: ; preds = %1
%6 = icmp ugt i32 %0, 998
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 @strcpy(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dispCacheIndex.wk, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %11
9: ; preds = %5
%10 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @dispCacheIndex.wk, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %11
11: ; preds = %7, %9, %3
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @dispCacheIndex.wk, i64 0, i64 0)
}