#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 exp(int);
int log(float);
int /*<<< orphan*/ mk_alphas(int, float *, float, float, float);
int /*<<< orphan*/ mk_bs_cumdist(int, float *, float, float *, float, float,
                                 float, float, int, float *);
void setup_bsprofs(int nrads, float rads[], float maxrad, int ndists,
                   float *cdists[], float z[], float bs, float R, float L,
                   int nalpha, float alpha[]) {
  int i, j;
  mk_alphas(nalpha, alpha, bs, L, R);
  for (i = 0; i < ndists; i++) {
    z[i] = 0.000001 * exp(i * log(bs / 0.000001) / (float)(ndists - 1.0));
    mk_bs_cumdist(nrads, rads, maxrad, cdists[i], z[i], bs, R, L, nalpha,
                  alpha);
  }
}


x86 assembly (clang, -O0):
<setup_bsprofs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movss  %xmm1,-0x2c(%rbp)
movss  %xmm2,-0x30(%rbp)
movss  %xmm3,-0x34(%rbp)
mov    %r9d,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    0x10(%rbp),%rsi
movss  -0x2c(%rbp),%xmm0
movss  -0x34(%rbp),%xmm1
movss  -0x30(%rbp),%xmm2
call   1040 <mk_alphas@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1264 <setup_bsprofs+0x124>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x44(%rbp)
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe45(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1060 <log@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
imul   %ecx,%eax
cvtsi2ss %eax,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xe27(%rip),%xmm2
subsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  0xdff(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movss  -0x14(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
movss  -0x2c(%rbp),%xmm2
movss  -0x30(%rbp),%xmm3
movss  -0x34(%rbp),%xmm4
mov    -0x38(%rbp),%ecx
mov    0x10(%rbp),%r8
call   1050 <mk_bs_cumdist@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1198 <setup_bsprofs+0x58>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_bsprofs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r15d
mov    %r8,0x20(%rsp)
mov    %rcx,%r12
mov    %edx,%r14d
movss  %xmm0,0x14(%rsp)
mov    %rsi,%rbp
mov    %edi,%ebx
mov    0x60(%rsp),%rsi
mov    %r9d,%edi
movss  %xmm1,0x8(%rsp)
movaps %xmm1,%xmm0
movss  %xmm3,0x1c(%rsp)
movaps %xmm3,%xmm1
movss  %xmm2,0x18(%rsp)
call   1040 <mk_alphas@plt>
test   %r14d,%r14d
jle    1258 <setup_bsprofs+0x118>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0xe59(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
addsd  0xe47(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
mov    %r14d,%r13d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  0x10(%rsp),%xmm0
call   1060 <log@plt>
mov    %r14d,%ecx
imul   %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
divss  0xc(%rsp),%xmm0
cvttss2si %xmm0,%edi
call   1030 <exp@plt>
mulsd  0xdf1(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
mov    0x20(%rsp),%rax
movss  %xmm1,(%rax,%r14,4)
mov    (%r12,%r14,8),%rdx
mov    %ebx,%edi
mov    %rbp,%rsi
movss  0x14(%rsp),%xmm0
movss  0x8(%rsp),%xmm2
movss  0x18(%rsp),%xmm3
movss  0x1c(%rsp),%xmm4
mov    %r15d,%ecx
mov    0x60(%rsp),%r8
call   1050 <mk_bs_cumdist@plt>
add    $0x1,%r14
cmp    %r14,%r13
jne    11e0 <setup_bsprofs+0xa0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @setup_bsprofs(i32 %0, float* %1, float %2, i32 %3, float** %4, float* %5, float %6, float %7, float %8, i32 %9, float* %10) {
%12 = alloca i32
%13 = alloca float*
%14 = alloca float
%15 = alloca i32
%16 = alloca float**
%17 = alloca float*
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca i32
%22 = alloca float*
%23 = alloca i32
%24 = alloca i32
store i32 %0, i32* %12
store float* %1, float** %13
store float %2, float* %14
store i32 %3, i32* %15
store float** %4, float*** %16
store float* %5, float** %17
store float %6, float* %18
store float %7, float* %19
store float %8, float* %20
store i32 %9, i32* %21
store float* %10, float** %22
%25 = load i32, i32* %21
%26 = load float*, float** %22
%27 = load float, float* %18
%28 = load float, float* %20
%29 = load float, float* %19
%30 = call i32 @mk_alphas(i32 %25, float* %26, float %27, float %28, float %29)
store i32 0, i32* %23
br label %31
31: ; preds = %76, %11
%32 = load i32, i32* %23
%33 = load i32, i32* %15
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %79
35: ; preds = %31
%36 = load i32, i32* %23
%37 = load float, float* %18
%38 = fpext float %37 to double
%39 = fdiv double %38, 0x3EB0C6F7A0B5ED8D
%40 = fptrunc double %39 to float
%41 = call i32 @log(float %40)
%42 = mul nsw i32 %36, %41
%43 = sitofp i32 %42 to float
%44 = load i32, i32* %15
%45 = sitofp i32 %44 to double
%46 = fsub double %45, 1.000000e+00
%47 = fptrunc double %46 to float
%48 = fdiv float %43, %47
%49 = fptosi float %48 to i32
%50 = call double @exp(i32 %49)
%51 = fmul double 0x3EB0C6F7A0B5ED8D, %50
%52 = fptrunc double %51 to float
%53 = load float*, float** %17
%54 = load i32, i32* %23
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds float, float* %53, i64 %55
store float %52, float* %56
%57 = load i32, i32* %12
%58 = load float*, float** %13
%59 = load float, float* %14
%60 = load float**, float*** %16
%61 = load i32, i32* %23
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds float*, float** %60, i64 %62
%64 = load float*, float** %63
%65 = load float*, float** %17
%66 = load i32, i32* %23
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds float, float* %65, i64 %67
%69 = load float, float* %68
%70 = load float, float* %18
%71 = load float, float* %19
%72 = load float, float* %20
%73 = load i32, i32* %21
%74 = load float*, float** %22
%75 = call i32 @mk_bs_cumdist(i32 %57, float* %58, float %59, float* %64, float %69, float %70, float %71, float %72, i32 %73, float* %74)
br label %76
76: ; preds = %35
%77 = load i32, i32* %23
%78 = add nsw i32 %77, 1
store i32 %78, i32* %23
br label %31
79: ; preds = %31
ret void
}

LLVM IR (-O2):
define void @setup_bsprofs(i32 %0, float* %1, float %2, i32 %3, float** nocapture %4, float* nocapture writeonly %5, float %6, float %7, float %8, i32 %9, float* %10) {
%12 = tail call i32 @mk_alphas(i32 %9, float* %10, float %6, float %8, float %7)
%13 = icmp sgt i32 %3, 0
br i1 %13, label %14, label %39
14: ; preds = %11
%15 = fpext float %6 to double
%16 = fdiv double %15, 0x3EB0C6F7A0B5ED8D
%17 = fptrunc double %16 to float
%18 = sitofp i32 %3 to double
%19 = fadd double %18, -1.000000e+00
%20 = fptrunc double %19 to float
%21 = zext i32 %3 to i64
br label %22
22: ; preds = %14, %22
%23 = phi i64 [ 0, %14 ], [ %37, %22 ]
%24 = tail call i32 @log(float %17)
%25 = trunc i64 %23 to i32
%26 = mul nsw i32 %24, %25
%27 = sitofp i32 %26 to float
%28 = fdiv float %27, %20
%29 = fptosi float %28 to i32
%30 = tail call double @exp(i32 %29)
%31 = fmul double %30, 0x3EB0C6F7A0B5ED8D
%32 = fptrunc double %31 to float
%33 = getelementptr inbounds float, float* %5, i64 %23
store float %32, float* %33
%34 = getelementptr inbounds float*, float** %4, i64 %23
%35 = load float*, float** %34
%36 = tail call i32 @mk_bs_cumdist(i32 %0, float* %1, float %2, float* %35, float %32, float %6, float %7, float %8, i32 %9, float* %10)
%37 = add nuw nsw i64 %23, 1
%38 = icmp eq i64 %37, %21
br i1 %38, label %39, label %22
39: ; preds = %22, %11
ret void
}