#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_gc_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 trigger ");
    break;
  case 5:
    sprintf(buf, "L button  ");
    break;
  case 6:
    sprintf(buf, "R trigger ");
    break;
  case 7:
    sprintf(buf, "R button  ");
    break;
  case 8:
    sprintf(buf, "Z button ");
    break;
  case 9:
    sprintf(buf, "start btn ");
    break;
  case 10:
    sprintf(buf, "main stick");
    break;
  case 11:
    sprintf(buf, "d-pad     ");
    break;
  case 12:
    sprintf(buf, "c stick   ");
    break;
  default:
    sprintf(buf, "gc err %d", index);
    break;
  }
}


x86 assembly (clang, -O0):
<get_gc_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_gc_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_gc_name+0x19>
movsbl -0x1(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xc,%eax
ja     129f <get_gc_name+0x18f>
mov    -0x20(%rbp),%rax
lea    0xe95(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b5 <get_gc_name+0x1a5>
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b5 <get_gc_name+0x1a5>
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b5 <get_gc_name+0x1a5>
mov    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b5 <get_gc_name+0x1a5>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b5 <get_gc_name+0x1a5>
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b5 <get_gc_name+0x1a5>
mov    -0x10(%rbp),%rdi
lea    0xe6d(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b5 <get_gc_name+0x1a5>
mov    -0x10(%rbp),%rdi
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b5 <get_gc_name+0x1a5>
mov    -0x10(%rbp),%rdi
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b5 <get_gc_name+0x1a5>
mov    -0x10(%rbp),%rdi
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b5 <get_gc_name+0x1a5>
mov    -0x10(%rbp),%rdi
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b5 <get_gc_name+0x1a5>
mov    -0x10(%rbp),%rdi
lea    0xe30(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b5 <get_gc_name+0x1a5>
mov    -0x10(%rbp),%rdi
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12b5 <get_gc_name+0x1a5>
mov    -0x10(%rbp),%rdi
movsbl -0x1(%rbp),%edx
lea    0xe14(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_gc_name>:
mov    %edi,%edx
movq   $0x0,0x5(%rsi)
movq   $0x0,(%rsi)
cmp    $0xc,%edi
ja     1144 <get_gc_name+0x34>
mov    %edx,%eax
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movabs $0x6e6f747475622041,%rax
74 6f 6e
jmp    11b3 <get_gc_name+0xa3>
lea    0xf77(%rip),%rax
mov    %rsi,%rdi
mov    %rax,%rsi
xor    %eax,%eax
jmp    1030 <sprintf@plt>
movabs $0x6e6f747475622042,%rax
74 6f 6e
jmp    11b3 <get_gc_name+0xa3>
movabs $0x6e6f747475622058,%rax
74 6f 6e
jmp    11b3 <get_gc_name+0xa3>
movabs $0x6e6f747475622059,%rax
74 6f 6e
jmp    11b3 <get_gc_name+0xa3>
movabs $0x656767697274204c,%rax
67 67 65
jmp    119e <get_gc_name+0x8e>
movabs $0x6e6f74747562204c,%rax
74 6f 6e
jmp    11b3 <get_gc_name+0xa3>
movabs $0x6567676972742052,%rax
67 67 65
mov    %rax,(%rsi)
movl   $0x207265,0x7(%rsi)
ret
movabs $0x6e6f747475622052,%rax
74 6f 6e
mov    %rax,(%rsi)
movl   $0x20206e,0x7(%rsi)
ret
movabs $0x6e6f74747562205a,%rax
74 6f 6e
mov    %rax,(%rsi)
movw   $0x20,0x8(%rsi)
ret
movabs $0x7462207472617473,%rax
20 62 74
mov    %rax,(%rsi)
movl   $0x206e74,0x7(%rsi)
ret
movabs $0x697473206e69616d,%rax
73 74 69
mov    %rax,(%rsi)
movl   $0x6b6369,0x7(%rsi)
ret
movabs $0x2020206461702d64,%rax
20 20 20
jmp    1212 <get_gc_name+0x102>
movabs $0x206b636974732063,%rax
63 6b 20
mov    %rax,(%rsi)
movl   $0x202020,0x7(%rsi)
ret

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 trigger \00"
@.str.5 = [11 x i8] c"L button \00"
@.str.6 = [11 x i8] c"R trigger \00"
@.str.7 = [11 x i8] c"R button \00"
@.str.8 = [10 x i8] c"Z button \00"
@.str.9 = [11 x i8] c"start btn \00"
@.str.10 = [11 x i8] c"main stick\00"
@.str.11 = [11 x i8] c"d-pad \00"
@.str.12 = [11 x i8] c"c stick \00"
@.str.13 = [10 x i8] c"gc err %d\00"
define void @get_gc_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 %59 [
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 10, label %50
i32 11, label %53
i32 12, label %56
]
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 %64
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 %64
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 %64
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 %64
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 %64
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 %64
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 %64
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 %64
44: ; preds = %17
%45 = load i8*, i8** %4
%46 = call i32 (i8*, i8*, ...) @sprintf(i8* %45, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %64
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 %64
50: ; preds = %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 %64
53: ; preds = %17
%54 = load i8*, i8** %4
%55 = call i32 (i8*, i8*, ...) @sprintf(i8* %54, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
br label %64
56: ; preds = %17
%57 = load i8*, i8** %4
%58 = call i32 (i8*, i8*, ...) @sprintf(i8* %57, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
br label %64
59: ; preds = %17
%60 = load i8*, i8** %4
%61 = load i8, i8* %3
%62 = sext i8 %61 to i32
%63 = call i32 (i8*, i8*, ...) @sprintf(i8* %60, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %59, %56, %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 trigger \00"
@.str.5 = [11 x i8] c"L button \00"
@.str.6 = [11 x i8] c"R trigger \00"
@.str.7 = [11 x i8] c"R button \00"
@.str.8 = [10 x i8] c"Z button \00"
@.str.9 = [11 x i8] c"start btn \00"
@.str.10 = [11 x i8] c"main stick\00"
@.str.11 = [11 x i8] c"d-pad \00"
@.str.12 = [11 x i8] c"c stick \00"
@.str.13 = [10 x i8] c"gc err %d\00"
define void @get_gc_name(i8 signext %0, i8* nocapture writeonly %1) {
%3 = sext i8 %0 to i32
switch i32 %3, label %17 [
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 10, label %14
i32 11, label %15
i32 12, label %16
]
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 %19
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 %19
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 %19
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 %19
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 %19
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 %19
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 %19
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 %19
12: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(10) %1, i8* align 1 dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i64 10, i1 false)
br label %19
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 %19
14: ; 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.10, i64 0, i64 0), i64 11, i1 false)
br label %19
15: ; 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.11, i64 0, i64 0), i64 11, i1 false)
br label %19
16: ; 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.12, i64 0, i64 0), i64 11, i1 false)
br label %19
17: ; preds = %2
%18 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i32 %3)
br label %19
19: ; preds = %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4
ret void
}