#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*/ snprintf(char *, int, char *, int);
const char *_xlat_num(int num, const char *array[], int size) {
  static char buf[64];
  if (num >= size) {
    snprintf(buf, sizeof buf, "%d", num);
    return buf;
  } else
    return array[num];
}


x86 assembly (clang, -O0):
<_xlat_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     1159 <_xlat_num+0x49>
mov    -0xc(%rbp),%ecx
lea    0x2f08(%rip),%rdi
mov    $0x40,%esi
lea    0xebc(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2ef0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1169 <_xlat_num+0x59>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_xlat_num>:
push   %rbx
mov    %edi,%ecx
cmp    %edx,%edi
jge    1120 <_xlat_num+0x10>
movslq %ecx,%rax
mov    (%rsi,%rax,8),%rbx
jmp    113b <_xlat_num+0x2b>
lea    0x2f19(%rip),%rbx
lea    0xed2(%rip),%rdx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@_xlat_num.buf = internal global [64 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define i8* @_xlat_num(i32 %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%8 = load i32, i32* %5
%9 = load i32, i32* %7
%10 = icmp sge i32 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i32, i32* %5
%13 = call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @_xlat_num.buf, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @_xlat_num.buf, i64 0, i64 0), i8** %4
br label %20
14: ; preds = %3
%15 = load i8**, i8*** %6
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
store i8* %19, i8** %4
br label %20
20: ; preds = %14, %11
%21 = load i8*, i8** %4
ret i8* %21
}

LLVM IR (-O2):
@_xlat_num.buf = internal global [64 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define i8* @_xlat_num(i32 %0, i8** nocapture %1, i32 %2) {
%4 = icmp slt i32 %0, %2
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @_xlat_num.buf, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %11
7: ; preds = %3
%8 = sext i32 %0 to i64
%9 = getelementptr inbounds i8*, i8** %1, i64 %8
%10 = load i8*, i8** %9
br label %11
11: ; preds = %7, %5
%12 = phi i8* [ getelementptr inbounds ([64 x i8], [64 x i8]* @_xlat_num.buf, i64 0, i64 0), %5 ], [ %10, %7 ]
ret i8* %12
}