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


x86 assembly (clang, -O0):
<fgauss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%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
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     126d <fgauss+0x15d>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%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  0xe3e(%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
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%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
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%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    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fgauss>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
movq   $0x0,(%rsi)
cmp    $0x2,%ecx
jl     11dd <fgauss+0xcd>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r13
mov    %ecx,%r12d
mov    $0x1,%ebx
movsd  %xmm0,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movapd %xmm0,%xmm1
subsd  0x8(%r13,%rbx,8),%xmm1
divsd  0x10(%r13,%rbx,8),%xmm1
movapd %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
xorpd  0xe8c(%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  (%r14),%xmm1
movsd  %xmm1,(%r14)
movsd  %xmm0,(%r15,%rbx,8)
movsd  0x8(%rsp),%xmm0
mulsd  %xmm2,%xmm3
divsd  0x10(%r13,%rbx,8),%xmm2
movsd  %xmm2,0x8(%r15,%rbx,8)
divsd  0x10(%r13,%rbx,8),%xmm3
movsd  %xmm3,0x10(%r15,%rbx,8)
add    $0x3,%rbx
cmp    %r12,%rbx
jb     1150 <fgauss+0x40>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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