#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 pow(double, int);
double reb_random_uniform(int, int);
double reb_random_powerlaw(double min, double max, double slope) {
  double y = reb_random_uniform(0., 1.);
  return pow((pow(max, slope + 1.) - pow(min, slope + 1.)) * y +
                 pow(min, slope + 1.),
             1. / (slope + 1.));
}


x86 assembly (clang, -O0):
<reb_random_powerlaw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <reb_random_uniform@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeab(%rip),%xmm1
addsd  -0x18(%rbp),%xmm1
cvttsd2si %xmm1,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe8b(%rip),%xmm1
addsd  -0x18(%rbp),%xmm1
cvttsd2si %xmm1,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe55(%rip),%xmm1
addsd  -0x18(%rbp),%xmm1
cvttsd2si %xmm1,%edi
call   1030 <pow@plt>
movsd  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe2a(%rip),%xmm2
addsd  -0x18(%rbp),%xmm2
movsd  0xe1d(%rip),%xmm1
divsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <pow@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reb_random_powerlaw>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x10(%rsp)
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <reb_random_uniform@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0xeaa(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
cvttsd2si %xmm0,%ebx
movsd  (%rsp),%xmm0
mov    %ebx,%edi
call   1030 <pow@plt>
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    %ebx,%edi
call   1030 <pow@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
mov    %ebx,%edi
call   1030 <pow@plt>
movsd  (%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe50(%rip),%xmm1
divsd  0x8(%rsp),%xmm1
cvttsd2si %xmm1,%edi
add    $0x20,%rsp
pop    %rbx
jmp    1030 <pow@plt>

LLVM IR (-O0):
define double @reb_random_powerlaw(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%8 = call double @reb_random_uniform(i32 0, i32 1)
store double %8, double* %7
%9 = load double, double* %5
%10 = load double, double* %6
%11 = fadd double %10, 1.000000e+00
%12 = fptosi double %11 to i32
%13 = call double @pow(double %9, i32 %12)
%14 = load double, double* %4
%15 = load double, double* %6
%16 = fadd double %15, 1.000000e+00
%17 = fptosi double %16 to i32
%18 = call double @pow(double %14, i32 %17)
%19 = fsub double %13, %18
%20 = load double, double* %7
%21 = load double, double* %4
%22 = load double, double* %6
%23 = fadd double %22, 1.000000e+00
%24 = fptosi double %23 to i32
%25 = call double @pow(double %21, i32 %24)
%26 = call double @llvm.fmuladd.f64(double %19, double %20, double %25)
%27 = load double, double* %6
%28 = fadd double %27, 1.000000e+00
%29 = fdiv double 1.000000e+00, %28
%30 = fptosi double %29 to i32
%31 = call double @pow(double %26, i32 %30)
ret double %31
}

LLVM IR (-O2):
define double @reb_random_powerlaw(double %0, double %1, double %2) {
%4 = tail call double @reb_random_uniform(i32 0, i32 1)
%5 = fadd double %2, 1.000000e+00
%6 = fptosi double %5 to i32
%7 = tail call double @pow(double %1, i32 %6)
%8 = tail call double @pow(double %0, i32 %6)
%9 = fsub double %7, %8
%10 = tail call double @pow(double %0, i32 %6)
%11 = tail call double @llvm.fmuladd.f64(double %9, double %4, double %10)
%12 = fdiv double 1.000000e+00, %5
%13 = fptosi double %12 to i32
%14 = tail call double @pow(double %11, i32 %13)
ret double %14
}