#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);
int sqrt(int);
void MexicanHatFun_real(double *w, int *center, double dump, unsigned int Ls,
                        double scale) {
  double k, daux;
  int u, u0;
  k = 2 / sqrt(3 * sqrt(3.14159265358979328) * scale);
  *center = Ls / 2;
  scale = 1 / scale;
  u0 = Ls / 2;
  for (u = -u0; u < (signed)Ls - u0; u++) {
    daux = scale * u;
    daux *= daux;
    *w++ = k * (daux - 1) * exp(-daux / 2);
  }
}


x86 assembly (clang, -O0):
<MexicanHatFun_real>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  %xmm1,-0x28(%rbp)
mov    $0x3,%edi
call   1040 <sqrt@plt>
imul   $0x3,%eax,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%ecx
shr    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movsd  0xe7d(%rip),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x40(%rbp)
xor    %eax,%eax
sub    -0x40(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    -0x40(%rbp),%ecx
cmp    %ecx,%eax
jge    124a <MexicanHatFun_real+0x12a>
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x3c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  0xe1d(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xdf4(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
movsd  %xmm0,(%rax)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    119e <MexicanHatFun_real+0x7e>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MexicanHatFun_real>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,(%rsp)
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x3,%edi
call   1040 <sqrt@plt>
lea    (%rax,%rax,2),%eax
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
mov    %eax,%ecx
mov    $0x2,%eax
xor    %edx,%edx
idiv   %ecx
mov    %r15d,%ebp
shr    %ebp
mov    %ebp,(%r14)
test   %r15d,%r15d
jle    11ea <MexicanHatFun_real+0xca>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xe7c(%rip),%xmm0
divsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
sub    %ebp,%r15d
neg    %ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm0
movapd %xmm0,%xmm1
addsd  0xe4b(%rip),%xmm1
mulsd  0x10(%rsp),%xmm1
movsd  %xmm1,(%rsp)
mulsd  0xe40(%rip),%xmm0
call   1030 <exp@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
add    $0x8,%rbx
add    $0x1,%ebp
cmp    %r15d,%ebp
jl     11a0 <MexicanHatFun_real+0x80>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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