#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(signed int n, double *weights_out) {
  double x;
  signed int i = 0;
  while (!(i >= 1 + n)) {
    x = ((double)i * 1.330000e+0) / (double)n;
    weights_out[(signed long int)i] = exp(-x * x * 3.141590e+0);
    i = i + 1;
  }
  return;
}


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
setge  %al
xor    $0xff,%al
test   $0x1,%al
jne    1143 <get_gauss_weights+0x33>
jmp    11af <get_gauss_weights+0x9f>
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  0xeb8(%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  0xe75(%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 = %13, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %3
%10 = add nsw i32 1, %9
%11 = icmp sge i32 %8, %10
%12 = xor i1 %11, true
br i1 %12, label %13, label %32
13: ; preds = %7
%14 = load i32, i32* %6
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 1.330000e+00
%17 = load i32, i32* %3
%18 = sitofp i32 %17 to double
%19 = fdiv double %16, %18
store double %19, double* %5
%20 = load double, double* %5
%21 = fneg double %20
%22 = load double, double* %5
%23 = fmul double %21, %22
%24 = fmul double %23, 3.141590e+00
%25 = call double @exp(double %24)
%26 = load double*, double** %4
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
store double %25, double* %29
%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
}