#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;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
float rand();
int generate_priority(float length) {
  float high_low_choice = rand();
  high_low_choice /= RAND_MAX;
  if (length <= 20) {
    if (high_low_choice < 0.3) {
      return 0;
    } else {
      return 1;
    }
  }
  if (length >= 100) {
    if (high_low_choice < 0.9) {
      return 3;
    } else {
      return 2;
    }
  }
  assert(0);
}


x86 assembly (clang, -O0):
<generate_priority>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
movss  %xmm0,-0xc(%rbp)
mov    0x2ea8(%rip),%rax
movss  (%rax),%xmm1
movss  -0xc(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xea6(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     1197 <generate_priority+0x77>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe9b(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    118b <generate_priority+0x6b>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <generate_priority+0xc7>
movl   $0x1,-0x4(%rbp)
jmp    11e7 <generate_priority+0xc7>
movss  -0x8(%rbp),%xmm0
movss  0xe60(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     11e0 <generate_priority+0xc0>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe4a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11d4 <generate_priority+0xb4>
movl   $0x3,-0x4(%rbp)
jmp    11e7 <generate_priority+0xc7>
movl   $0x2,-0x4(%rbp)
jmp    11e7 <generate_priority+0xc7>
xor    %edi,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_priority>:
push   %rax
movss  %xmm0,0x4(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
mov    0x2eb3(%rip),%rax
divss  (%rax),%xmm0
movss  0xebf(%rip),%xmm1
movss  0x4(%rsp),%xmm2
ucomiss %xmm2,%xmm1
jae    1161 <generate_priority+0x41>
movaps %xmm2,%xmm1
ucomiss 0xeae(%rip),%xmm2
jae    1178 <generate_priority+0x58>
xor    %edi,%edi
call   1030 <assert@plt>
pop    %rcx
ret
cvtss2sd %xmm0,%xmm0
movsd  0xe9b(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
setbe  %al
pop    %rcx
ret
cvtss2sd %xmm0,%xmm0
movsd  0xe8c(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
seta   %al
or     $0x2,%eax
pop    %rcx
ret

LLVM IR (-O0):
@RAND_MAX = global float 0.000000e+00
define i32 @generate_priority(float %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca float
store float %0, float* %3
%5 = call float (...) @rand()
store float %5, float* %4
%6 = load float, float* @RAND_MAX
%7 = load float, float* %4
%8 = fdiv float %7, %6
store float %8, float* %4
%9 = load float, float* %3
%10 = fcmp ole float %9, 2.000000e+01
br i1 %10, label %11, label %17
11: ; preds = %1
%12 = load float, float* %4
%13 = fpext float %12 to double
%14 = fcmp olt double %13, 3.000000e-01
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 0, i32* %2
br label %28
16: ; preds = %11
store i32 1, i32* %2
br label %28
17: ; preds = %1
%18 = load float, float* %3
%19 = fcmp oge float %18, 1.000000e+02
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load float, float* %4
%22 = fpext float %21 to double
%23 = fcmp olt double %22, 9.000000e-01
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 3, i32* %2
br label %28
25: ; preds = %20
store i32 2, i32* %2
br label %28
26: ; preds = %17
%27 = call i32 @assert(i32 0)
br label %28
28: ; preds = %26, %25, %24, %16, %15
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@RAND_MAX = global float 0.000000e+00
define i32 @generate_priority(float %0) {
%2 = tail call float (...) @rand()
%3 = load float, float* @RAND_MAX
%4 = fdiv float %2, %3
%5 = fcmp ugt float %0, 2.000000e+01
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = fpext float %4 to double
%8 = fcmp uge double %7, 3.000000e-01
%9 = zext i1 %8 to i32
br label %18
10: ; preds = %1
%11 = fcmp ult float %0, 1.000000e+02
br i1 %11, label %16, label %12
12: ; preds = %10
%13 = fpext float %4 to double
%14 = fcmp olt double %13, 9.000000e-01
%15 = select i1 %14, i32 3, i32 2
br label %18
16: ; preds = %10
%17 = tail call i32 @assert(i32 0)
br label %18
18: ; preds = %12, %6, %16
%19 = phi i32 [ undef, %16 ], [ %9, %6 ], [ %15, %12 ]
ret i32 %19
}