#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 *, ...);
void get_ds_name(char index, char *buf) {
  for (int i = 0; i < 13; i++)
    buf[i] = 0;
  switch (index) {
  case 0:
    sprintf(buf, "A button  ");
    break;
  case 1:
    sprintf(buf, "B button  ");
    break;
  case 2:
    sprintf(buf, "X button  ");
    break;
  case 3:
    sprintf(buf, "Y button  ");
    break;
  case 4:
    sprintf(buf, "L button  ");
    break;
  case 5:
    sprintf(buf, "R button  ");
    break;
  case 6:
    sprintf(buf, "start btn ");
    break;
  case 7:
    sprintf(buf, "selct btn ");
    break;
  case 8:
    sprintf(buf, "circlePad ");
    break;
  case 9:
    sprintf(buf, "d-pad     ");
    break;
  case -1:
  case 127:
    sprintf(buf, "unmapped  ");
    break;
  default:
    sprintf(buf, "ds err %d", index);
    break;
  }
}


x86 assembly (clang, -O0):
<get_ds_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xd,-0x14(%rbp)
jge    114d <get_ds_name+0x3d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <get_ds_name+0x19>
movsbl -0x1(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0xffffffff,%eax
je     1302 <get_ds_name+0x1f2>
jmp    1162 <get_ds_name+0x52>
mov    -0x18(%rbp),%eax
test   %eax,%eax
je     121c <get_ds_name+0x10c>
jmp    1172 <get_ds_name+0x62>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     1233 <get_ds_name+0x123>
jmp    1183 <get_ds_name+0x73>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     124a <get_ds_name+0x13a>
jmp    1194 <get_ds_name+0x84>
mov    -0x18(%rbp),%eax
sub    $0x3,%eax
je     1261 <get_ds_name+0x151>
jmp    11a5 <get_ds_name+0x95>
mov    -0x18(%rbp),%eax
sub    $0x4,%eax
je     1278 <get_ds_name+0x168>
jmp    11b6 <get_ds_name+0xa6>
mov    -0x18(%rbp),%eax
sub    $0x5,%eax
je     128f <get_ds_name+0x17f>
jmp    11c7 <get_ds_name+0xb7>
mov    -0x18(%rbp),%eax
sub    $0x6,%eax
je     12a6 <get_ds_name+0x196>
jmp    11d8 <get_ds_name+0xc8>
mov    -0x18(%rbp),%eax
sub    $0x7,%eax
je     12bd <get_ds_name+0x1ad>
jmp    11e9 <get_ds_name+0xd9>
mov    -0x18(%rbp),%eax
sub    $0x8,%eax
je     12d4 <get_ds_name+0x1c4>
jmp    11fa <get_ds_name+0xea>
mov    -0x18(%rbp),%eax
sub    $0x9,%eax
je     12eb <get_ds_name+0x1db>
jmp    120b <get_ds_name+0xfb>
mov    -0x18(%rbp),%eax
sub    $0x7f,%eax
je     1302 <get_ds_name+0x1f2>
jmp    1319 <get_ds_name+0x209>
mov    -0x10(%rbp),%rdi
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    132f <get_ds_name+0x21f>
mov    -0x10(%rbp),%rdi
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    132f <get_ds_name+0x21f>
mov    -0x10(%rbp),%rdi
lea    0xdc1(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    132f <get_ds_name+0x21f>
mov    -0x10(%rbp),%rdi
lea    0xdb5(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    132f <get_ds_name+0x21f>
mov    -0x10(%rbp),%rdi
lea    0xda9(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    132f <get_ds_name+0x21f>
mov    -0x10(%rbp),%rdi
lea    0xd9d(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    132f <get_ds_name+0x21f>
mov    -0x10(%rbp),%rdi
lea    0xd91(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    132f <get_ds_name+0x21f>
mov    -0x10(%rbp),%rdi
lea    0xd85(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    132f <get_ds_name+0x21f>
mov    -0x10(%rbp),%rdi
lea    0xd79(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    132f <get_ds_name+0x21f>
mov    -0x10(%rbp),%rdi
lea    0xd6d(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    132f <get_ds_name+0x21f>
mov    -0x10(%rbp),%rdi
lea    0xd61(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    132f <get_ds_name+0x21f>
mov    -0x10(%rbp),%rdi
movsbl -0x1(%rbp),%edx
lea    0xd51(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_ds_name>:
mov    %edi,%edx
movq   $0x0,0x5(%rsi)
movq   $0x0,(%rsi)
lea    0x1(%rdx),%eax
cmp    $0xa,%eax
ja     1145 <get_ds_name+0x35>
lea    0xed0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movabs $0x6e6f747475622041,%rax
74 6f 6e
jmp    119d <get_ds_name+0x8d>
cmp    $0x7f,%edx
jne    11f3 <get_ds_name+0xe3>
movabs $0x64657070616d6e75,%rax
70 65 64
mov    %rax,(%rsi)
movl   $0x202064,0x7(%rsi)
ret
movabs $0x6e6f747475622042,%rax
74 6f 6e
jmp    119d <get_ds_name+0x8d>
movabs $0x6e6f747475622058,%rax
74 6f 6e
jmp    119d <get_ds_name+0x8d>
movabs $0x6e6f747475622059,%rax
74 6f 6e
jmp    119d <get_ds_name+0x8d>
movabs $0x6e6f74747562204c,%rax
74 6f 6e
jmp    119d <get_ds_name+0x8d>
movabs $0x6e6f747475622052,%rax
74 6f 6e
mov    %rax,(%rsi)
movl   $0x20206e,0x7(%rsi)
ret
movabs $0x7462207472617473,%rax
20 62 74
jmp    11be <get_ds_name+0xae>
movabs $0x74622074636c6573,%rax
20 62 74
mov    %rax,(%rsi)
movl   $0x206e74,0x7(%rsi)
ret
movabs $0x6150656c63726963,%rax
65 50 61
mov    %rax,(%rsi)
movl   $0x206461,0x7(%rsi)
ret
movabs $0x2020206461702d64,%rax
20 20 20
mov    %rax,(%rsi)
movl   $0x202020,0x7(%rsi)
ret
lea    0xeab(%rip),%rax
mov    %rsi,%rdi
mov    %rax,%rsi
xor    %eax,%eax
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"A button \00"
@.str.1 = [11 x i8] c"B button \00"
@.str.2 = [11 x i8] c"X button \00"
@.str.3 = [11 x i8] c"Y button \00"
@.str.4 = [11 x i8] c"L button \00"
@.str.5 = [11 x i8] c"R button \00"
@.str.6 = [11 x i8] c"start btn \00"
@.str.7 = [11 x i8] c"selct btn \00"
@.str.8 = [11 x i8] c"circlePad \00"
@.str.9 = [11 x i8] c"d-pad \00"
@.str.10 = [11 x i8] c"unmapped \00"
@.str.11 = [10 x i8] c"ds err %d\00"
define void @get_ds_name(i8 signext %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i32
store i8 %0, i8* %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %14, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 13
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
store i8 0, i8* %13
br label %14
14: ; preds = %9
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 1
store i32 %16, i32* %5
br label %6
17: ; preds = %6
%18 = load i8, i8* %3
%19 = sext i8 %18 to i32
switch i32 %19, label %53 [
i32 0, label %20
i32 1, label %23
i32 2, label %26
i32 3, label %29
i32 4, label %32
i32 5, label %35
i32 6, label %38
i32 7, label %41
i32 8, label %44
i32 9, label %47
i32 -1, label %50
i32 127, label %50
]
20: ; preds = %17
%21 = load i8*, i8** %4
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %58
23: ; preds = %17
%24 = load i8*, i8** %4
%25 = call i32 (i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %58
26: ; preds = %17
%27 = load i8*, i8** %4
%28 = call i32 (i8*, i8*, ...) @sprintf(i8* %27, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %58
29: ; preds = %17
%30 = load i8*, i8** %4
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %30, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %58
32: ; preds = %17
%33 = load i8*, i8** %4
%34 = call i32 (i8*, i8*, ...) @sprintf(i8* %33, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %58
35: ; preds = %17
%36 = load i8*, i8** %4
%37 = call i32 (i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %58
38: ; preds = %17
%39 = load i8*, i8** %4
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
br label %58
41: ; preds = %17
%42 = load i8*, i8** %4
%43 = call i32 (i8*, i8*, ...) @sprintf(i8* %42, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
br label %58
44: ; preds = %17
%45 = load i8*, i8** %4
%46 = call i32 (i8*, i8*, ...) @sprintf(i8* %45, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
br label %58
47: ; preds = %17
%48 = load i8*, i8** %4
%49 = call i32 (i8*, i8*, ...) @sprintf(i8* %48, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
br label %58
50: ; preds = %17, %17
%51 = load i8*, i8** %4
%52 = call i32 (i8*, i8*, ...) @sprintf(i8* %51, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
br label %58
53: ; preds = %17
%54 = load i8*, i8** %4
%55 = load i8, i8* %3
%56 = sext i8 %55 to i32
%57 = call i32 (i8*, i8*, ...) @sprintf(i8* %54, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %53, %50, %47, %44, %41, %38, %35, %32, %29, %26, %23, %20
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"A button \00"
@.str.1 = [11 x i8] c"B button \00"
@.str.2 = [11 x i8] c"X button \00"
@.str.3 = [11 x i8] c"Y button \00"
@.str.4 = [11 x i8] c"L button \00"
@.str.5 = [11 x i8] c"R button \00"
@.str.6 = [11 x i8] c"start btn \00"
@.str.7 = [11 x i8] c"selct btn \00"
@.str.8 = [11 x i8] c"circlePad \00"
@.str.9 = [11 x i8] c"d-pad \00"
@.str.10 = [11 x i8] c"unmapped \00"
@.str.11 = [10 x i8] c"ds err %d\00"
define void @get_ds_name(i8 signext %0, i8* nocapture writeonly %1) {
%3 = sext i8 %0 to i32
switch i32 %3, label %15 [
i32 0, label %4
i32 1, label %5
i32 2, label %6
i32 3, label %7
i32 4, label %8
i32 5, label %9
i32 6, label %10
i32 7, label %11
i32 8, label %12
i32 9, label %13
i32 -1, label %14
i32 127, label %14
]
4: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %1, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 11, i1 false)
br label %17
5: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %1, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 11, i1 false)
br label %17
6: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %1, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 11, i1 false)
br label %17
7: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %1, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i64 11, i1 false)
br label %17
8: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %1, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i64 11, i1 false)
br label %17
9: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %1, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i64 11, i1 false)
br label %17
10: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %1, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i64 11, i1 false)
br label %17
11: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %1, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i64 11, i1 false)
br label %17
12: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %1, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i64 11, i1 false)
br label %17
13: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %1, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i64 11, i1 false)
br label %17
14: ; preds = %2, %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %1, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i64 11, i1 false)
br label %17
15: ; preds = %2
%16 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 %3)
br label %17
17: ; preds = %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4
ret void
}