#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 */
int rand();
int determine_size(double median_size, double max_size) {
  int nr_random, granularity_reducer;
  double size, double_nr_random;
  nr_random = rand();
  median_size++;
  if (max_size / median_size < 1024)
    granularity_reducer = 1024 * 1024;
  else
    granularity_reducer = 1;
  nr_random = nr_random % ((int)(granularity_reducer *
                                 (((double)max_size) / ((double)median_size))));
  double_nr_random = ((double)nr_random) / (granularity_reducer);
  size = median_size * (1 / (1 - (double_nr_random) / (((double)max_size) /
                                                       ((double)median_size))) -
                        1);
  return ((int)size);
}


x86 assembly (clang, -O0):
<determine_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,-0x14(%rbp)
movsd  0xed4(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm1
divsd  -0x8(%rbp),%xmm1
movsd  0xeb0(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1166 <determine_size+0x56>
movl   $0x100000,-0x18(%rbp)
jmp    116d <determine_size+0x5d>
movl   $0x1,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
divsd  -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
divsd  -0x8(%rbp),%xmm2
divsd  %xmm2,%xmm1
movsd  0xe48(%rip),%xmm2
subsd  %xmm1,%xmm2
movsd  0xe3c(%rip),%xmm1
divsd  %xmm2,%xmm1
movsd  0xe30(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvttsd2si -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<determine_size>:
sub    $0x18,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
movsd  0xed1(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm4
divsd  %xmm1,%xmm4
movapd %xmm1,%xmm3
movsd  0xeb9(%rip),%xmm1
xor    %ecx,%ecx
ucomisd %xmm4,%xmm1
seta   %cl
lea    0xeb9(%rip),%rdx
movsd  (%rdx,%rcx,8),%xmm1
movapd %xmm4,%xmm2
mulsd  %xmm1,%xmm2
cvttsd2si %xmm2,%ecx
cltd
idiv   %ecx
xorps  %xmm2,%xmm2
cvtsi2sd %edx,%xmm2
divsd  %xmm1,%xmm2
divsd  %xmm4,%xmm2
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
addsd  0xe7a(%rip),%xmm0
mulsd  %xmm3,%xmm0
cvttsd2si %xmm0,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @determine_size(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store double %0, double* %3
store double %1, double* %4
%9 = call i32 (...) @rand()
store i32 %9, i32* %5
%10 = load double, double* %3
%11 = fadd double %10, 1.000000e+00
store double %11, double* %3
%12 = load double, double* %4
%13 = load double, double* %3
%14 = fdiv double %12, %13
%15 = fcmp olt double %14, 1.024000e+03
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 1048576, i32* %6
br label %18
17: ; preds = %2
store i32 1, i32* %6
br label %18
18: ; preds = %17, %16
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = sitofp i32 %20 to double
%22 = load double, double* %4
%23 = load double, double* %3
%24 = fdiv double %22, %23
%25 = fmul double %21, %24
%26 = fptosi double %25 to i32
%27 = srem i32 %19, %26
store i32 %27, i32* %5
%28 = load i32, i32* %5
%29 = sitofp i32 %28 to double
%30 = load i32, i32* %6
%31 = sitofp i32 %30 to double
%32 = fdiv double %29, %31
store double %32, double* %8
%33 = load double, double* %3
%34 = load double, double* %8
%35 = load double, double* %4
%36 = load double, double* %3
%37 = fdiv double %35, %36
%38 = fdiv double %34, %37
%39 = fsub double 1.000000e+00, %38
%40 = fdiv double 1.000000e+00, %39
%41 = fsub double %40, 1.000000e+00
%42 = fmul double %33, %41
store double %42, double* %7
%43 = load double, double* %7
%44 = fptosi double %43 to i32
ret i32 %44
}

LLVM IR (-O2):
define i32 @determine_size(double %0, double %1) {
%3 = tail call i32 (...) @rand()
%4 = fadd double %0, 1.000000e+00
%5 = fdiv double %1, %4
%6 = fcmp olt double %5, 1.024000e+03
%7 = select i1 %6, double 0x4130000000000000, double 1.000000e+00
%8 = fmul double %5, %7
%9 = fptosi double %8 to i32
%10 = srem i32 %3, %9
%11 = sitofp i32 %10 to double
%12 = fdiv double %11, %7
%13 = fdiv double %12, %5
%14 = fsub double 1.000000e+00, %13
%15 = fdiv double 1.000000e+00, %14
%16 = fadd double %15, -1.000000e+00
%17 = fmul double %4, %16
%18 = fptosi double %17 to i32
ret i32 %18
}