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


x86 assembly (clang, -O0):
<MorletFun_real>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  0xeb3(%rip),%xmm0
call   1050 <sqrt@plt>
cvtsi2sd %eax,%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    $0x1,%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  0xe71(%rip),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x48(%rbp)
xor    %eax,%eax
sub    -0x48(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    -0x48(%rbp),%ecx
cmp    %ecx,%eax
jge    1250 <MorletFun_real+0x120>
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x44(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xdf7(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
movsd  %xmm0,(%rax)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11aa <MorletFun_real+0x7a>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MorletFun_real>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
movsd  %xmm1,(%rsp)
mov    %edx,%r15d
movsd  %xmm0,0x18(%rsp)
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  0xeaa(%rip),%xmm0
call   1050 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
call   1050 <sqrt@plt>
lea    0x1(%rax),%edx
xor    %ecx,%ecx
cmp    $0x3,%edx
cmovb  %eax,%ecx
mov    %r15d,%ebp
shr    %ebp
mov    %ebp,(%r14)
test   %r15d,%r15d
jle    1209 <MorletFun_real+0xd9>
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xe6b(%rip),%xmm0
divsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
sub    %ebp,%r15d
neg    %ebp
nopl   (%rax)
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
mulsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm0
mulsd  0x18(%rsp),%xmm0
mulsd  %xmm1,%xmm1
movsd  %xmm1,0x20(%rsp)
call   1040 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x20(%rsp),%xmm0
mulsd  0xe21(%rip),%xmm0
call   1030 <exp@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
add    $0x8,%rbx
add    $0x1,%ebp
cmp    %r15d,%ebp
jl     11b0 <MorletFun_real+0x80>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @MorletFun_real(double* nocapture writeonly %0, i32* nocapture writeonly %1, double %2, i32 %3, double %4) {
%6 = tail call i32 @sqrt(double 0x400921FB54442D18)
%7 = sitofp i32 %6 to double
%8 = fmul double %7, %4
%9 = tail call i32 @sqrt(double %8)
%10 = add i32 %9, 1
%11 = icmp ult i32 %10, 3
%12 = select i1 %11, i32 %9, i32 0
%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 %35
18: ; preds = %5
%19 = sub nsw i32 0, %14
br label %20
20: ; preds = %18, %20
%21 = phi double* [ %32, %20 ], [ %0, %18 ]
%22 = phi i32 [ %33, %20 ], [ %19, %18 ]
%23 = sitofp i32 %22 to double
%24 = fmul double %15, %23
%25 = fmul double %24, %2
%26 = fmul double %24, %24
%27 = tail call double @cos(double %25)
%28 = fmul double %27, %13
%29 = fmul double %26, -5.000000e-01
%30 = tail call double @exp(double %29)
%31 = fmul double %28, %30
%32 = getelementptr inbounds double, double* %21, i64 1
store double %31, double* %21
%33 = add nsw i32 %22, 1
%34 = icmp slt i32 %33, %16
br i1 %34, label %20, label %35
35: ; preds = %20, %5
ret void
}