#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 */
scalar_t__ RAND_MAX;
int rand();
float randomVal(void) {
  int selector = rand() % 10;
  switch (selector) {
  case 8:
  case 9:
    return (float)rand() / (float)RAND_MAX * (float)(rand() % 100);
  default:
    return 0.0f;
  }
}


x86 assembly (clang, -O0):
<randomVal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rdx
add    %ecx,%edx
add    %edx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xfffffff8,%eax
sub    $0x1,%eax
ja     119c <randomVal+0x8c>
jmp    1156 <randomVal+0x46>
mov    $0x0,%al
call   1030 <rand@plt>
cvtsi2ss %eax,%xmm0
mov    0x2e80(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
movss  -0xc(%rbp),%xmm0
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11a4 <randomVal+0x94>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomVal>:
push   %rax
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
and    $0xfffffffe,%eax
xorps  %xmm0,%xmm0
cmp    $0x8,%eax
jne    1193 <randomVal+0x83>
xor    %eax,%eax
call   1030 <rand@plt>
cvtsi2ss %eax,%xmm1
mov    0x2e96(%rip),%rax
xorps  %xmm0,%xmm0
cvtsi2ssq (%rax),%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0x4(%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
define float @randomVal() {
%1 = alloca float
%2 = alloca i32
%3 = call i32 (...) @rand()
%4 = srem i32 %3, 10
store i32 %4, i32* %2
%5 = load i32, i32* %2
switch i32 %5, label %16 [
i32 8, label %6
i32 9, label %6
]
6: ; preds = %0, %0
%7 = call i32 (...) @rand()
%8 = sitofp i32 %7 to float
%9 = load i64, i64* @RAND_MAX
%10 = sitofp i64 %9 to float
%11 = fdiv float %8, %10
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 100
%14 = sitofp i32 %13 to float
%15 = fmul float %11, %14
store float %15, float* %1
br label %17
16: ; preds = %0
store float 0.000000e+00, float* %1
br label %17
17: ; preds = %16, %6
%18 = load float, float* %1
ret float %18
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define float @randomVal() {
%1 = tail call i32 (...) @rand()
%2 = srem i32 %1, 10
%3 = and i32 %2, -2
%4 = icmp eq i32 %3, 8
br i1 %4, label %5, label %15
5: ; preds = %0
%6 = tail call i32 (...) @rand()
%7 = sitofp i32 %6 to float
%8 = load i64, i64* @RAND_MAX
%9 = sitofp i64 %8 to float
%10 = fdiv float %7, %9
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 100
%13 = sitofp i32 %12 to float
%14 = fmul float %10, %13
br label %15
15: ; preds = %0, %5
%16 = phi float [ %14, %5 ], [ 0.000000e+00, %0 ]
ret float %16
}