#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 qexp(double, double const);
void exponential_discretize(const double lambda, double *bins,
                            const int count) {
  double s = 1. / (double)count;
  double q = s * 0.5;
  for (int i = 0; i < count; i++) {
    bins[i] = qexp(q, lambda);
    q += s;
  }
}


x86 assembly (clang, -O0):
<exponential_discretize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xed7(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xebe(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1198 <exponential_discretize+0x88>
movsd  -0x28(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1030 <qexp@plt>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1153 <exponential_discretize+0x43>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exponential_discretize>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
test   %esi,%esi
jle    1192 <exponential_discretize+0x82>
mov    %rdi,%r14
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
movsd  0xece(%rip),%xmm2
divsd  %xmm0,%xmm2
movsd  0xeca(%rip),%xmm0
movsd  %xmm2,0x10(%rsp)
mulsd  %xmm2,%xmm0
mov    %esi,%r15d
xor    %ebx,%ebx
movsd  %xmm1,0x18(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1030 <qexp@plt>
movsd  %xmm0,(%r14,%rbx,8)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <exponential_discretize+0x50>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @exponential_discretize(double %0, double* %1, i32 %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store double %0, double* %4
store double* %1, double** %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = sitofp i32 %10 to double
%12 = fdiv double 1.000000e+00, %11
store double %12, double* %7
%13 = load double, double* %7
%14 = fmul double %13, 5.000000e-01
store double %14, double* %8
store i32 0, i32* %9
br label %15
15: ; preds = %30, %3
%16 = load i32, i32* %9
%17 = load i32, i32* %6
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %33
19: ; preds = %15
%20 = load double, double* %8
%21 = load double, double* %4
%22 = call double @qexp(double %20, double %21)
%23 = load double*, double** %5
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
store double %22, double* %26
%27 = load double, double* %7
%28 = load double, double* %8
%29 = fadd double %28, %27
store double %29, double* %8
br label %30
30: ; preds = %19
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 1
store i32 %32, i32* %9
br label %15
33: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @exponential_discretize(double %0, double* nocapture writeonly %1, i32 %2) {
%4 = sitofp i32 %2 to double
%5 = fdiv double 1.000000e+00, %4
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = fmul double %5, 5.000000e-01
%9 = zext i32 %2 to i64
br label %11
10: ; preds = %11, %3
ret void
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %17, %11 ]
%13 = phi double [ %8, %7 ], [ %16, %11 ]
%14 = tail call double @qexp(double %13, double %0)
%15 = getelementptr inbounds double, double* %1, i64 %12
store double %14, double* %15
%16 = fadd double %5, %13
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, %9
br i1 %18, label %10, label %11
}