#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 fgauss(float x, double a[], double *y, double dyda[], int na) {
  int i;
  double fac, ex, arg, width;
  *y = 0.0;
  for (i = 1; i < na; i += 3) {
    width = a[i + 2] / 1.66510922231539537641;
    arg = (x - a[i + 1]) / width;
    ex = exp(-arg * arg);
    fac = a[i] * ex * 2.0 * arg;
    *y += a[i] * ex;
    dyda[i] = ex;
    dyda[i + 1] = fac / width;
    dyda[i + 2] = fac * arg / width;
  }
}


x86 assembly (clang, -O0):
<fgauss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1268 <fgauss+0x158>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xea4(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x40(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xe29(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x38(%rbp),%xmm2
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x28(%rbp)
jmp    113e <fgauss+0x2e>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fgauss>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
movq   $0x0,(%rsi)
cmp    $0x2,%ecx
jl     11e8 <fgauss+0xd8>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ecx,%r12d
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
movsd  0x10(%r13,%rbx,8),%xmm0
movsd  0x8(%rsp),%xmm1
subsd  0x8(%r13,%rbx,8),%xmm1
divsd  0xe94(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
divsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
xorpd  0xe88(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  0x0(%r13,%rbx,8),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm2
addsd  %xmm1,%xmm2
movapd 0x10(%rsp),%xmm3
mulsd  %xmm3,%xmm2
addsd  (%r15),%xmm1
movsd  %xmm1,(%r15)
movsd  %xmm0,(%r14,%rbx,8)
mulsd  %xmm2,%xmm3
unpcklpd %xmm3,%xmm2
movapd 0x20(%rsp),%xmm0
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm2
movupd %xmm2,0x8(%r14,%rbx,8)
add    $0x3,%rbx
cmp    %r12,%rbx
jb     1150 <fgauss+0x40>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @fgauss(float %0, double* nocapture %1, double* nocapture %2, double* nocapture writeonly %3, i32 %4) {
store double 0.000000e+00, double* %2
%6 = icmp sgt i32 %4, 1
br i1 %6, label %7, label %42
7: ; preds = %5
%8 = fpext float %0 to double
%9 = zext i32 %4 to i64
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 1, %7 ], [ %40, %10 ]
%12 = add nuw nsw i64 %11, 2
%13 = getelementptr inbounds double, double* %1, i64 %12
%14 = load double, double* %13
%15 = fdiv double %14, 0x3FFAA4499161CD47
%16 = add nuw nsw i64 %11, 1
%17 = getelementptr inbounds double, double* %1, i64 %16
%18 = load double, double* %17
%19 = fsub double %8, %18
%20 = fdiv double %19, %15
%21 = fneg double %20
%22 = fmul double %20, %21
%23 = tail call double @exp(double %22)
%24 = getelementptr inbounds double, double* %1, i64 %11
%25 = load double, double* %24
%26 = fmul double %23, %25
%27 = fmul double %26, 2.000000e+00
%28 = fmul double %20, %27
%29 = load double, double* %2
%30 = tail call double @llvm.fmuladd.f64(double %25, double %23, double %29)
store double %30, double* %2
%31 = getelementptr inbounds double, double* %3, i64 %11
store double %23, double* %31
%32 = getelementptr inbounds double, double* %3, i64 %16
%33 = fmul double %20, %28
%34 = insertelement <2 x double> poison, double %28, i64 0
%35 = insertelement <2 x double> %34, double %33, i64 1
%36 = insertelement <2 x double> poison, double %15, i64 0
%37 = shufflevector <2 x double> %36, <2 x double> poison, <2 x i32> zeroinitializer
%38 = fdiv <2 x double> %35, %37
%39 = bitcast double* %32 to <2 x double>*
store <2 x double> %38, <2 x double>* %39
%40 = add nuw nsw i64 %11, 3
%41 = icmp ult i64 %40, %9
br i1 %41, label %10, label %42
42: ; preds = %10, %5
ret void
}