#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 */
double RAND_MAX;
scalar_t__ pow(double, double);
scalar_t__ rand();
int blocklength() {
  long L;
  double alpha, beta, u;
  alpha = 5466.8;
  beta = -2.2;
  u = (double)rand() / RAND_MAX;
  while (u < 1e-3)
    u = (double)rand() / RAND_MAX;
  L = (int)pow(u / alpha, 1.0 / beta);
  return L;
}


x86 assembly (clang, -O0):
<blocklength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  0xed8(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xec3(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e93(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeaa(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1192 <blocklength+0x72>
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e64(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    115e <blocklength+0x3e>
movsd  -0x20(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  0xe74(%rip),%xmm1
divsd  -0x18(%rbp),%xmm1
call   1030 <pow@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blocklength>:
push   %rbx
xor    %eax,%eax
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2eb4(%rip),%rbx
divsd  (%rbx),%xmm0
movsd  0xec0(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1171 <blocklength+0x51>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
movsd  0xea1(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%rbx),%xmm0
ucomisd %xmm0,%xmm1
ja     1150 <blocklength+0x30>
divsd  0xe8f(%rip),%xmm0
movsd  0xe8f(%rip),%xmm1
pop    %rbx
jmp    1030 <pow@plt>

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define i32 @blocklength() {
%1 = alloca i64
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double 5.466800e+03, double* %2
store double -2.200000e+00, double* %3
%5 = call i64 (...) @rand()
%6 = sitofp i64 %5 to double
%7 = load double, double* @RAND_MAX
%8 = fdiv double %6, %7
store double %8, double* %4
br label %9
9: ; preds = %12, %0
%10 = load double, double* %4
%11 = fcmp olt double %10, 1.000000e-03
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = call i64 (...) @rand()
%14 = sitofp i64 %13 to double
%15 = load double, double* @RAND_MAX
%16 = fdiv double %14, %15
store double %16, double* %4
br label %9
17: ; preds = %9
%18 = load double, double* %4
%19 = load double, double* %2
%20 = fdiv double %18, %19
%21 = load double, double* %3
%22 = fdiv double 1.000000e+00, %21
%23 = call i64 @pow(double %20, double %22)
%24 = trunc i64 %23 to i32
%25 = sext i32 %24 to i64
store i64 %25, i64* %1
%26 = load i64, i64* %1
%27 = trunc i64 %26 to i32
ret i32 %27
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define i32 @blocklength() {
%1 = tail call i64 (...) @rand()
%2 = sitofp i64 %1 to double
%3 = load double, double* @RAND_MAX
%4 = fdiv double %2, %3
%5 = fcmp olt double %4, 1.000000e-03
br i1 %5, label %6, label %12
6: ; preds = %0, %6
%7 = tail call i64 (...) @rand()
%8 = sitofp i64 %7 to double
%9 = load double, double* @RAND_MAX
%10 = fdiv double %8, %9
%11 = fcmp olt double %10, 1.000000e-03
br i1 %11, label %6, label %12
12: ; preds = %6, %0
%13 = phi double [ %4, %0 ], [ %10, %6 ]
%14 = fdiv double %13, 5.466800e+03
%15 = tail call i64 @pow(double %14, double 0xBFDD1745D1745D17)
%16 = trunc i64 %15 to i32
ret i32 %16
}