#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 const cos(double);
double exp(double);
int sqrt(double);
void Complete_MorletFun_real(double *w, int *center, double w0, unsigned int Ls,
                             double scale) {
  const double ze = exp((-w0 * w0) / 2);
  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) - ze) * exp(-0.5 * daux);
  }
}


x86 assembly (clang, -O0):
<Complete_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  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe9a(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe7c(%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,-0x38(%rbp)
mov    -0x1c(%rbp),%ecx
shr    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movsd  0xe3a(%rip),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x50(%rbp)
xor    %eax,%eax
sub    -0x50(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    -0x50(%rbp),%ecx
cmp    %ecx,%eax
jge    128c <Complete_MorletFun_real+0x15c>
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x4c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xdc3(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
movsd  %xmm0,(%rax)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11e1 <Complete_MorletFun_real+0xb1>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Complete_MorletFun_real>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
movsd  %xmm1,0x8(%rsp)
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm0,0x28(%rsp)
mulsd  %xmm0,%xmm0
mulsd  0xea5(%rip),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0xe9a(%rip),%xmm0
call   1050 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%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    1231 <Complete_MorletFun_real+0x101>
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0xe5a(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
sub    %ebp,%r15d
neg    %ebp
nopw   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
mulsd  0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
mulsd  0x28(%rsp),%xmm0
mulsd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1040 <cos@plt>
subsd  0x20(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xdea(%rip),%xmm0
call   1030 <exp@plt>
mulsd  0x30(%rsp),%xmm0
movsd  %xmm0,(%rbx)
add    $0x8,%rbx
add    $0x1,%ebp
cmp    %r15d,%ebp
jl     11d0 <Complete_MorletFun_real+0xa0>
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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