#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 rand();
char *BotRandomWeaponName(void) {
  int rnd;
  rnd = ((rand() & 0x7fff) / ((float)0x7fff)) * 11.9;
  switch (rnd) {
  case 0:
    return "Gauntlet";
  case 1:
    return "Shotgun";
  case 2:
    return "Machinegun";
  case 3:
    return "Grenade Launcher";
  case 4:
    return "Rocket Launcher";
  case 5:
    return "Plasmagun";
  case 6:
    return "Railgun";
  case 7:
    return "Lightning Gun";
  case 8:
    return "Nailgun";
  case 9:
    return "Chaingun";
  case 10:
    return "Proximity Launcher";
  default:
    return "BFG10K";
  }
}


x86 assembly (clang, -O0):
<BotRandomWeaponName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
call   1030 <rand@plt>
and    $0x7fff,%eax
cvtsi2ss %eax,%xmm0
movss  0xed0(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xec8(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0xa,%rax
ja     1220 <BotRandomWeaponName+0x110>
mov    -0x18(%rbp),%rax
lea    0xea9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122b <BotRandomWeaponName+0x11b>
lea    0xebe(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122b <BotRandomWeaponName+0x11b>
lea    0xeb6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122b <BotRandomWeaponName+0x11b>
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122b <BotRandomWeaponName+0x11b>
lea    0xeb2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122b <BotRandomWeaponName+0x11b>
lea    0xeb2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122b <BotRandomWeaponName+0x11b>
lea    0xeac(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122b <BotRandomWeaponName+0x11b>
lea    0xea4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122b <BotRandomWeaponName+0x11b>
lea    0xea2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122b <BotRandomWeaponName+0x11b>
lea    0xe9a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122b <BotRandomWeaponName+0x11b>
lea    0xe93(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122b <BotRandomWeaponName+0x11b>
lea    0xe96(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BotRandomWeaponName>:
push   %rax
xor    %eax,%eax
call   1030 <rand@plt>
and    $0x7fff,%eax
cvtsi2ss %eax,%xmm0
divss  0xed7(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xed3(%rip),%xmm0
cvttsd2si %xmm0,%eax
cmp    $0xa,%eax
ja     1150 <BotRandomWeaponName+0x40>
cltq
lea    0xf51(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret
lea    0xf3a(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Gauntlet\00"
@.str.1 = [8 x i8] c"Shotgun\00"
@.str.2 = [11 x i8] c"Machinegun\00"
@.str.3 = [17 x i8] c"Grenade Launcher\00"
@.str.4 = [16 x i8] c"Rocket Launcher\00"
@.str.5 = [10 x i8] c"Plasmagun\00"
@.str.6 = [8 x i8] c"Railgun\00"
@.str.7 = [14 x i8] c"Lightning Gun\00"
@.str.8 = [8 x i8] c"Nailgun\00"
@.str.9 = [9 x i8] c"Chaingun\00"
@.str.10 = [19 x i8] c"Proximity Launcher\00"
@.str.11 = [7 x i8] c"BFG10K\00"
define i8* @BotRandomWeaponName() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i32 (...) @rand()
%4 = and i32 %3, 32767
%5 = sitofp i32 %4 to float
%6 = fdiv float %5, 3.276700e+04
%7 = fpext float %6 to double
%8 = fmul double %7, 1.190000e+01
%9 = fptosi double %8 to i32
store i32 %9, i32* %2
%10 = load i32, i32* %2
switch i32 %10, label %22 [
i32 0, label %11
i32 1, label %12
i32 2, label %13
i32 3, label %14
i32 4, label %15
i32 5, label %16
i32 6, label %17
i32 7, label %18
i32 8, label %19
i32 9, label %20
i32 10, label %21
]
11: ; preds = %0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %1
br label %23
12: ; preds = %0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %23
13: ; preds = %0
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %23
14: ; preds = %0
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %23
15: ; preds = %0
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8** %1
br label %23
16: ; preds = %0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8** %1
br label %23
17: ; preds = %0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8** %1
br label %23
18: ; preds = %0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8** %1
br label %23
19: ; preds = %0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8** %1
br label %23
20: ; preds = %0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8** %1
br label %23
21: ; preds = %0
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8** %1
br label %23
22: ; preds = %0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8** %1
br label %23
23: ; preds = %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11
%24 = load i8*, i8** %1
ret i8* %24
}

LLVM IR (-O2):
@.str = [9 x i8] c"Gauntlet\00"
@.str.1 = [8 x i8] c"Shotgun\00"
@.str.2 = [11 x i8] c"Machinegun\00"
@.str.3 = [17 x i8] c"Grenade Launcher\00"
@.str.4 = [16 x i8] c"Rocket Launcher\00"
@.str.5 = [10 x i8] c"Plasmagun\00"
@.str.6 = [8 x i8] c"Railgun\00"
@.str.7 = [14 x i8] c"Lightning Gun\00"
@.str.8 = [8 x i8] c"Nailgun\00"
@.str.9 = [9 x i8] c"Chaingun\00"
@.str.10 = [19 x i8] c"Proximity Launcher\00"
@.str.11 = [7 x i8] c"BFG10K\00"
@reltable.BotRandomWeaponName = [11 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str to i64), i64 ptrtoint ([11 x i32]* @reltable.BotRandomWeaponName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([11 x i32]* @reltable.BotRandomWeaponName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.2 to i64), i64 ptrtoint ([11 x i32]* @reltable.BotRandomWeaponName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.3 to i64), i64 ptrtoint ([11 x i32]* @reltable.BotRandomWeaponName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.4 to i64), i64 ptrtoint ([11 x i32]* @reltable.BotRandomWeaponName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.5 to i64), i64 ptrtoint ([11 x i32]* @reltable.BotRandomWeaponName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.6 to i64), i64 ptrtoint ([11 x i32]* @reltable.BotRandomWeaponName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.7 to i64), i64 ptrtoint ([11 x i32]* @reltable.BotRandomWeaponName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.8 to i64), i64 ptrtoint ([11 x i32]* @reltable.BotRandomWeaponName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.9 to i64), i64 ptrtoint ([11 x i32]* @reltable.BotRandomWeaponName to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.10 to i64), i64 ptrtoint ([11 x i32]* @reltable.BotRandomWeaponName to i64)) to i32)]
define i8* @BotRandomWeaponName() {
%1 = tail call i32 (...) @rand()
%2 = and i32 %1, 32767
%3 = sitofp i32 %2 to float
%4 = fdiv float %3, 3.276700e+04
%5 = fpext float %4 to double
%6 = fmul double %5, 1.190000e+01
%7 = fptosi double %6 to i32
%8 = icmp ult i32 %7, 11
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = sext i32 %7 to i64
%11 = shl i64 %10, 2
%12 = call i8* @llvm.load.relative.i64(i8* bitcast ([11 x i32]* @reltable.BotRandomWeaponName to i8*), i64 %11)
br label %13
13: ; preds = %0, %9
%14 = phi i8* [ %12, %9 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), %0 ]
ret i8* %14
}