#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;
float rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int randomlyChoosePit() {
  double result = -1;
  float factor = ((float)RAND_MAX + 1) / 3;
  int choice = -1;
  int i = 0;
  srand((unsigned int)time(NULL));
  result = rand() / factor;
  choice = (int)(result * 100.0);
  choice = choice % 3;
  return choice;
}


x86 assembly (clang, -O0):
<randomlyChoosePit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  0xec8(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    0x2e9c(%rip),%rax
cvtsi2ssq (%rax),%xmm0
movss  0xebb(%rip),%xmm1
addss  %xmm1,%xmm0
movss  0xeab(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0xffffffff,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    $0x0,%al
call   1050 <rand@plt>
divss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xe57(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomlyChoosePit>:
push   %rax
mov    0x2eb0(%rip),%rax
cvtsi2ssq (%rax),%xmm0
addss  0xebb(%rip),%xmm0
divss  0xeb7(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1050 <rand@plt>
divss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe8e(%rip),%xmm0
cvttsd2si %xmm0,%eax
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
define i32 @randomlyChoosePit() {
%1 = alloca double
%2 = alloca float
%3 = alloca i32
%4 = alloca i32
store double -1.000000e+00, double* %1
%5 = load i64, i64* @RAND_MAX
%6 = sitofp i64 %5 to float
%7 = fadd float %6, 1.000000e+00
%8 = fdiv float %7, 3.000000e+00
store float %8, float* %2
store i32 -1, i32* %3
store i32 0, i32* %4
%9 = call i64 @time(i32* null)
%10 = trunc i64 %9 to i32
%11 = call i32 @srand(i32 %10)
%12 = call float (...) @rand()
%13 = load float, float* %2
%14 = fdiv float %12, %13
%15 = fpext float %14 to double
store double %15, double* %1
%16 = load double, double* %1
%17 = fmul double %16, 1.000000e+02
%18 = fptosi double %17 to i32
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = srem i32 %19, 3
store i32 %20, i32* %3
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define i32 @randomlyChoosePit() {
%1 = load i64, i64* @RAND_MAX
%2 = sitofp i64 %1 to float
%3 = fadd float %2, 1.000000e+00
%4 = fdiv float %3, 3.000000e+00
%5 = tail call i64 @time(i32* null)
%6 = trunc i64 %5 to i32
%7 = tail call i32 @srand(i32 %6)
%8 = tail call float (...) @rand()
%9 = fdiv float %8, %4
%10 = fpext float %9 to double
%11 = fmul double %10, 1.000000e+02
%12 = fptosi double %11 to i32
%13 = srem i32 %12, 3
ret i32 %13
}