#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 *);
char *reg_string(unsigned short r) {
  static char str[6];
  switch (r) {
  case 32768:
    sprintf(str, "r0");
    break;
  case 32769:
    sprintf(str, "r1");
    break;
  case 32770:
    sprintf(str, "r2");
    break;
  case 32771:
    sprintf(str, "r3");
    break;
  case 32772:
    sprintf(str, "r4");
    break;
  case 32773:
    sprintf(str, "r5");
    break;
  case 32774:
    sprintf(str, "r6");
    break;
  case 32775:
    sprintf(str, "r7");
    break;
  default:
    sprintf(str, "");
    break;
  }
  return str;
}


x86 assembly (clang, -O0):
<reg_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
add    $0xffff8000,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x7,%eax
ja     120b <reg_string+0xfb>
mov    -0x10(%rbp),%rax
lea    0xebe(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x2ed7(%rip),%rdi
lea    0xec7(%rip),%rsi
call   1030 <sprintf@plt>
jmp    121e <reg_string+0x10e>
lea    0x2ebf(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1030 <sprintf@plt>
jmp    121e <reg_string+0x10e>
lea    0x2ea7(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1030 <sprintf@plt>
jmp    121e <reg_string+0x10e>
lea    0x2e8f(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1030 <sprintf@plt>
jmp    121e <reg_string+0x10e>
lea    0x2e77(%rip),%rdi
lea    0xe73(%rip),%rsi
call   1030 <sprintf@plt>
jmp    121e <reg_string+0x10e>
lea    0x2e5f(%rip),%rdi
lea    0xe5e(%rip),%rsi
call   1030 <sprintf@plt>
jmp    121e <reg_string+0x10e>
lea    0x2e47(%rip),%rdi
lea    0xe49(%rip),%rsi
call   1030 <sprintf@plt>
jmp    121e <reg_string+0x10e>
lea    0x2e2f(%rip),%rdi
lea    0xe34(%rip),%rsi
call   1030 <sprintf@plt>
jmp    121e <reg_string+0x10e>
lea    0x2e17(%rip),%rdi
lea    0xe09(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2e04(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reg_string>:
add    $0xffff8000,%edi
cmp    $0x7,%di
ja     1137 <reg_string+0x37>
movzwl %di,%eax
lea    0xeea(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x0,0x2efd(%rip)
movw   $0x3072,0x2ef2(%rip)
72 30
lea    0x2eeb(%rip),%rax
ret
movb   $0x0,0x2ee3(%rip)
lea    0x2edc(%rip),%rax
ret
movb   $0x0,0x2ed6(%rip)
movw   $0x3172,0x2ecb(%rip)
72 31
lea    0x2ec4(%rip),%rax
ret
movb   $0x0,0x2ebe(%rip)
movw   $0x3272,0x2eb3(%rip)
72 32
lea    0x2eac(%rip),%rax
ret
movb   $0x0,0x2ea6(%rip)
movw   $0x3372,0x2e9b(%rip)
72 33
lea    0x2e94(%rip),%rax
ret
movb   $0x0,0x2e8e(%rip)
movw   $0x3472,0x2e83(%rip)
72 34
lea    0x2e7c(%rip),%rax
ret
movb   $0x0,0x2e76(%rip)
movw   $0x3572,0x2e6b(%rip)
72 35
lea    0x2e64(%rip),%rax
ret
movb   $0x0,0x2e5e(%rip)
movw   $0x3672,0x2e53(%rip)
72 36
lea    0x2e4c(%rip),%rax
ret
movb   $0x0,0x2e46(%rip)
movw   $0x3772,0x2e3b(%rip)
72 37
lea    0x2e34(%rip),%rax
ret

LLVM IR (-O0):
@reg_string.str = internal global [6 x i8] zeroinitializer
@.str = [3 x i8] c"r0\00"
@.str.1 = [3 x i8] c"r1\00"
@.str.2 = [3 x i8] c"r2\00"
@.str.3 = [3 x i8] c"r3\00"
@.str.4 = [3 x i8] c"r4\00"
@.str.5 = [3 x i8] c"r5\00"
@.str.6 = [3 x i8] c"r6\00"
@.str.7 = [3 x i8] c"r7\00"
@.str.8 = [1 x i8] zeroinitializer
define i8* @reg_string(i16 zeroext %0) {
%2 = alloca i16
store i16 %0, i16* %2
%3 = load i16, i16* %2
%4 = zext i16 %3 to i32
switch i32 %4, label %21 [
i32 32768, label %5
i32 32769, label %7
i32 32770, label %9
i32 32771, label %11
i32 32772, label %13
i32 32773, label %15
i32 32774, label %17
i32 32775, label %19
]
5: ; preds = %1
%6 = call i32 @sprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %23
7: ; preds = %1
%8 = call i32 @sprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %23
9: ; preds = %1
%10 = call i32 @sprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %23
11: ; preds = %1
%12 = call i32 @sprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %23
13: ; preds = %1
%14 = call i32 @sprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %23
15: ; preds = %1
%16 = call i32 @sprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %23
17: ; preds = %1
%18 = call i32 @sprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %23
19: ; preds = %1
%20 = call i32 @sprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %23
21: ; preds = %1
%22 = call i32 @sprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0))
br label %23
23: ; preds = %21, %19, %17, %15, %13, %11, %9, %7, %5
ret i8* getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0)
}

LLVM IR (-O2):
@reg_string.str = internal global [6 x i8] zeroinitializer
@.str = [3 x i8] c"r0\00"
@.str.1 = [3 x i8] c"r1\00"
@.str.2 = [3 x i8] c"r2\00"
@.str.3 = [3 x i8] c"r3\00"
@.str.4 = [3 x i8] c"r4\00"
@.str.5 = [3 x i8] c"r5\00"
@.str.6 = [3 x i8] c"r6\00"
@.str.7 = [3 x i8] c"r7\00"
define i8* @reg_string(i16 zeroext %0) {
switch i16 %0, label %10 [
i16 -32768, label %2
i16 -32767, label %3
i16 -32766, label %4
i16 -32765, label %5
i16 -32764, label %6
i16 -32763, label %7
i16 -32762, label %8
i16 -32761, label %9
]
2: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 3, i1 false)
br label %11
3: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 3, i1 false)
br label %11
4: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 3, i1 false)
br label %11
5: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 3, i1 false)
br label %11
6: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64 3, i1 false)
br label %11
7: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i64 3, i1 false)
br label %11
8: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i64 3, i1 false)
br label %11
9: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0), i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i64 3, i1 false)
br label %11
10: ; preds = %1
store i8 0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0)
br label %11
11: ; preds = %10, %9, %8, %7, %6, %5, %4, %3, %2
ret i8* getelementptr inbounds ([6 x i8], [6 x i8]* @reg_string.str, i64 0, i64 0)
}