#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(int);
int pow(double, int);
void gaussMF(double *x, int xlen, double sigma, double C) {
  int i;
  for (i = 0; i < xlen; i++) {
    x[i] = exp((-1) * pow(-(x[i] - C), 2) / (2 * pow(sigma, 2)));
  }
}


x86 assembly (clang, -O0):
<gaussMF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c4 <gaussMF+0xa4>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
imul   $0xffffffff,%eax,%eax
mov    %eax,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
shl    $0x1,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <exp@plt>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1140 <gaussMF+0x20>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gaussMF>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
test   %esi,%esi
jle    11a5 <gaussMF+0x85>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
movsd  %xmm1,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%r15,%rbx,8),%xmm0
subsd  %xmm1,%xmm0
xorpd  0xe9e(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %eax,%ebp
movsd  0x10(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %eax,%ecx
add    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
neg    %eax
mov    %eax,%edi
call   1030 <exp@plt>
movsd  0x8(%rsp),%xmm1
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1150 <gaussMF+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @gaussMF(double* %0, i32 %1, double %2, double %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store double %2, double* %7
store double %3, double* %8
store i32 0, i32* %9
br label %10
10: ; preds = %34, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %37
14: ; preds = %10
%15 = load double*, double** %5
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %15, i64 %17
%19 = load double, double* %18
%20 = load double, double* %8
%21 = fsub double %19, %20
%22 = fneg double %21
%23 = call i32 @pow(double %22, i32 2)
%24 = mul nsw i32 -1, %23
%25 = load double, double* %7
%26 = call i32 @pow(double %25, i32 2)
%27 = mul nsw i32 2, %26
%28 = sdiv i32 %24, %27
%29 = call double @exp(i32 %28)
%30 = load double*, double** %5
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
store double %29, double* %33
br label %34
34: ; preds = %14
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %10
37: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @gaussMF(double* nocapture %0, i32 %1, double %2, double %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %22
6: ; preds = %4
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %20, %8 ]
%10 = getelementptr inbounds double, double* %0, i64 %9
%11 = load double, double* %10
%12 = fsub double %11, %3
%13 = fneg double %12
%14 = tail call i32 @pow(double %13, i32 2)
%15 = tail call i32 @pow(double %2, i32 2)
%16 = shl nsw i32 %15, 1
%17 = sdiv i32 %14, %16
%18 = sub nsw i32 0, %17
%19 = tail call double @exp(i32 %18)
store double %19, double* %10
%20 = add nuw nsw i64 %9, 1
%21 = icmp eq i64 %20, %7
br i1 %21, label %22, label %8
22: ; preds = %8, %4
ret void
}