#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(double);
void get_gauss_weights(int n, double *weights_out) {
  double x;
  int i;
  for (i = 0; i < n + 1; i++) {
    x = (double)i * 1.33 / n;
    weights_out[i] = exp(-x * x * 3.14159);
  }
}


x86 assembly (clang, -O0):
<get_gauss_weights>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11a3 <get_gauss_weights+0x93>
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  0xec4(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1126 <get_gauss_weights+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_gauss_weights>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
js     1175 <get_gauss_weights+0x65>
mov    %rsi,%r14
mov    %edi,%r15d
cvtsi2sd %edi,%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0x1,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xeb1(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm0
mulsd  0xea7(%rip),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <get_gauss_weights+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @get_gauss_weights(i32 %0, double* nocapture writeonly %1) {
%3 = icmp slt i32 %0, 0
br i1 %3, label %21, label %4
4: ; preds = %2
%5 = sitofp i32 %0 to double
%6 = add nuw i32 %0, 1
%7 = zext i32 %6 to i64
br label %8
8: ; preds = %4, %8
%9 = phi i64 [ 0, %4 ], [ %19, %8 ]
%10 = trunc i64 %9 to i32
%11 = sitofp i32 %10 to double
%12 = fmul double %11, 1.330000e+00
%13 = fdiv double %12, %5
%14 = fneg double %13
%15 = fmul double %13, %14
%16 = fmul double %15, 3.141590e+00
%17 = tail call double @exp(double %16)
%18 = getelementptr inbounds double, double* %1, i64 %9
store double %17, double* %18
%19 = add nuw nsw i64 %9, 1
%20 = icmp eq i64 %19, %7
br i1 %20, label %21, label %8
21: ; preds = %8, %2
ret void
}