#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 */
int exp(double);
int sqrt(int);
void mexihat(double *x, int sigInLength, double *psi, int sigOutLength,
             double ys) {
  int count;
  double x2, con;
  con = 2 / (sqrt(3) * sqrt(sqrt(3.1415926535897931159980)));
  for (count = 0; count < sigInLength; count++) {
    x2 = x[count] * x[count];
    psi[count] = (1 - x2) * exp(-x2 / 2) * con / ys;
  }
  return;
}


x86 assembly (clang, -O0):
<mexihat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    $0x3,%edi
call   1040 <sqrt@plt>
mov    %eax,-0x44(%rbp)
mov    $0x3,%edi
call   1040 <sqrt@plt>
mov    %eax,%edi
call   1040 <sqrt@plt>
mov    -0x44(%rbp),%ecx
imul   %eax,%ecx
mov    $0x2,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1213 <mexihat+0xf3>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe5e(%rip),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe28(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  -0x50(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x40(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1177 <mexihat+0x57>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mexihat>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%r12
mov    $0x3,%edi
call   1040 <sqrt@plt>
mov    %eax,%ebp
mov    $0x3,%edi
call   1040 <sqrt@plt>
mov    %eax,%edi
call   1040 <sqrt@plt>
mov    %eax,%ecx
imul   %ebp,%ecx
mov    $0x2,%eax
xor    %edx,%edx
idiv   %ecx
test   %r15d,%r15d
jle    11d1 <mexihat+0xb1>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r15d,%ebp
xor    %ebx,%ebx
nopl   (%rax)
movsd  (%r12,%rbx,8),%xmm0
mulsd  %xmm0,%xmm0
movsd  0xe6e(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
mulsd  0xe64(%rip),%xmm0
call   1030 <exp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x18(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1180 <mexihat+0x60>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mexihat(double* %0, i32 %1, double* %2, i32 %3, double %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca double
store double* %0, double** %6
store i32 %1, i32* %7
store double* %2, double** %8
store i32 %3, i32* %9
store double %4, double* %10
%14 = call i32 @sqrt(i32 3)
%15 = call i32 @sqrt(i32 3)
%16 = call i32 @sqrt(i32 %15)
%17 = mul nsw i32 %14, %16
%18 = sdiv i32 2, %17
%19 = sitofp i32 %18 to double
store double %19, double* %13
store i32 0, i32* %11
br label %20
20: ; preds = %52, %5
%21 = load i32, i32* %11
%22 = load i32, i32* %7
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %55
24: ; preds = %20
%25 = load double*, double** %6
%26 = load i32, i32* %11
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = load double*, double** %6
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = fmul double %29, %34
store double %35, double* %12
%36 = load double, double* %12
%37 = fsub double 1.000000e+00, %36
%38 = load double, double* %12
%39 = fneg double %38
%40 = fdiv double %39, 2.000000e+00
%41 = call i32 @exp(double %40)
%42 = sitofp i32 %41 to double
%43 = fmul double %37, %42
%44 = load double, double* %13
%45 = fmul double %43, %44
%46 = load double, double* %10
%47 = fdiv double %45, %46
%48 = load double*, double** %8
%49 = load i32, i32* %11
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
store double %47, double* %51
br label %52
52: ; preds = %24
%53 = load i32, i32* %11
%54 = add nsw i32 %53, 1
store i32 %54, i32* %11
br label %20
55: ; preds = %20
ret void
}

LLVM IR (-O2):
define void @mexihat(double* nocapture %0, i32 %1, double* nocapture writeonly %2, i32 %3, double %4) {
%6 = tail call i32 @sqrt(i32 3)
%7 = tail call i32 @sqrt(i32 3)
%8 = tail call i32 @sqrt(i32 %7)
%9 = mul nsw i32 %8, %6
%10 = sdiv i32 2, %9
%11 = sitofp i32 %10 to double
%12 = icmp sgt i32 %1, 0
br i1 %12, label %13, label %30
13: ; preds = %5
%14 = zext i32 %1 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %28, %15 ]
%17 = getelementptr inbounds double, double* %0, i64 %16
%18 = load double, double* %17
%19 = fmul double %18, %18
%20 = fsub double 1.000000e+00, %19
%21 = fmul double %19, -5.000000e-01
%22 = tail call i32 @exp(double %21)
%23 = sitofp i32 %22 to double
%24 = fmul double %20, %23
%25 = fmul double %24, %11
%26 = fdiv double %25, %4
%27 = getelementptr inbounds double, double* %2, i64 %16
store double %26, double* %27
%28 = add nuw nsw i64 %16, 1
%29 = icmp eq i64 %28, %14
br i1 %29, label %30, label %15
30: ; preds = %15, %5
ret void
}