#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);
const char *js_btnname(int btn) {
  static char name[4];
  if (btn < '0')
    return (const char *)0;
  btn -= '0';
  if (btn < 26) {
    name[0] = btn + 'A';
    name[1] = '\0';
  } else
    sprintf(name, "%d", btn);
  return name;
}


x86 assembly (clang, -O0):
<js_btnname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x30,-0xc(%rbp)
jge    1132 <js_btnname+0x22>
movq   $0x0,-0x8(%rbp)
jmp    117e <js_btnname+0x6e>
mov    -0xc(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1a,-0xc(%rbp)
jge    115d <js_btnname+0x4d>
mov    -0xc(%rbp),%eax
add    $0x41,%eax
mov    %al,0x2ed8(%rip)
movb   $0x0,0x2ed2(%rip)
jmp    1173 <js_btnname+0x63>
mov    -0xc(%rbp),%edx
lea    0x2ec2(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2eaf(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<js_btnname>:
push   %rbx
cmp    $0x30,%edi
jge    111a <js_btnname+0xa>
xor    %ebx,%ebx
jmp    1153 <js_btnname+0x43>
mov    %edi,%edx
cmp    $0x49,%edi
ja     113a <js_btnname+0x2a>
add    $0x11,%dl
mov    %dl,0x2eff(%rip)
lea    0x2ef8(%rip),%rbx
movb   $0x0,0x2ef2(%rip)
jmp    1153 <js_btnname+0x43>
add    $0xffffffd0,%edx
lea    0x2ee5(%rip),%rbx
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@js_btnname.name = internal global [4 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define i8* @js_btnname(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 48
br i1 %5, label %6, label %7
6: ; preds = %1
store i8* null, i8** %2
br label %20
7: ; preds = %1
%8 = load i32, i32* %3
%9 = sub nsw i32 %8, 48
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 26
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 65
%15 = trunc i32 %14 to i8
store i8 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @js_btnname.name, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @js_btnname.name, i64 0, i64 1)
br label %19
16: ; preds = %7
%17 = load i32, i32* %3
%18 = call i32 @sprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @js_btnname.name, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %12
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @js_btnname.name, i64 0, i64 0), i8** %2
br label %20
20: ; preds = %19, %6
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@js_btnname.name = internal global [4 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define i8* @js_btnname(i32 %0) {
%2 = icmp slt i32 %0, 48
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 74
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = trunc i32 %0 to i8
%7 = add nuw nsw i8 %6, 17
store i8 %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @js_btnname.name, i64 0, i64 0)
store i8 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @js_btnname.name, i64 0, i64 1)
br label %11
8: ; preds = %3
%9 = add nsw i32 %0, -48
%10 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @js_btnname.name, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %5, %8, %1
%12 = phi i8* [ null, %1 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @js_btnname.name, i64 0, i64 0), %8 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @js_btnname.name, i64 0, i64 0), %5 ]
ret i8* %12
}