#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 */
float RAND_MAX;
float rand();
int generate_arrival_interval() {
  float large_small_choice = rand();
  large_small_choice /= RAND_MAX;
  float length = rand();
  if (large_small_choice < 0.5) {
    return (int)(length / RAND_MAX * (5 - 1) + 1);
  } else {
    return (int)(length / RAND_MAX * (15 - 1) + 1);
  }
}


x86 assembly (clang, -O0):
<generate_arrival_interval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <rand@plt>
movss  %xmm0,-0x8(%rbp)
mov    0x2ebd(%rip),%rax
movss  (%rax),%xmm1
movss  -0x8(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xea6(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1198 <generate_arrival_interval+0x88>
movss  -0xc(%rbp),%xmm0
mov    0x2e78(%rip),%rax
divss  (%rax),%xmm0
movss  0xe94(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe84(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <generate_arrival_interval+0xb7>
movss  -0xc(%rbp),%xmm0
mov    0x2e44(%rip),%rax
divss  (%rax),%xmm0
movss  0xe58(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe50(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_arrival_interval>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <rand@plt>
mov    0x2ec6(%rip),%r14
divss  (%r14),%xmm0
movss  0xed1(%rip),%xmm1
xor    %ebx,%ebx
ucomiss %xmm0,%xmm1
seta   %bl
xor    %eax,%eax
call   1030 <rand@plt>
divss  (%r14),%xmm0
lea    0xebe(%rip),%rax
mulss  (%rax,%rbx,4),%xmm0
addss  0xead(%rip),%xmm0
cvttss2si %xmm0,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@RAND_MAX = global float 0.000000e+00
define i32 @generate_arrival_interval() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = call float (...) @rand()
store float %4, float* %2
%5 = load float, float* @RAND_MAX
%6 = load float, float* %2
%7 = fdiv float %6, %5
store float %7, float* %2
%8 = call float (...) @rand()
store float %8, float* %3
%9 = load float, float* %2
%10 = fpext float %9 to double
%11 = fcmp olt double %10, 5.000000e-01
br i1 %11, label %12, label %18
12: ; preds = %0
%13 = load float, float* %3
%14 = load float, float* @RAND_MAX
%15 = fdiv float %13, %14
%16 = call float @llvm.fmuladd.f32(float %15, float 4.000000e+00, float 1.000000e+00)
%17 = fptosi float %16 to i32
store i32 %17, i32* %1
br label %24
18: ; preds = %0
%19 = load float, float* %3
%20 = load float, float* @RAND_MAX
%21 = fdiv float %19, %20
%22 = call float @llvm.fmuladd.f32(float %21, float 1.400000e+01, float 1.000000e+00)
%23 = fptosi float %22 to i32
store i32 %23, i32* %1
br label %24
24: ; preds = %18, %12
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@RAND_MAX = global float 0.000000e+00
define i32 @generate_arrival_interval() {
%1 = tail call float (...) @rand()
%2 = load float, float* @RAND_MAX
%3 = fdiv float %1, %2
%4 = tail call float (...) @rand()
%5 = fcmp olt float %3, 5.000000e-01
%6 = load float, float* @RAND_MAX
%7 = fdiv float %4, %6
%8 = tail call float @llvm.fmuladd.f32(float %7, float 4.000000e+00, float 1.000000e+00)
%9 = tail call float @llvm.fmuladd.f32(float %7, float 1.400000e+01, float 1.000000e+00)
%10 = select i1 %5, float %8, float %9
%11 = fptosi float %10 to i32
ret i32 %11
}