#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(int);
double exp(double);
double sin(int);
int sqrt(double);
void cmorlet(double *x, int sigInLength, double fb, double fc, double *psir,
             double *psii, int sigOutLength, double ys) {
  int count;
  double con, econ, x2;
  con = 1 / sqrt(3.1415926535897931159980 * fb);
  for (count = 0; count < sigInLength; count++) {
    x2 = x[count] * x[count];
    econ = exp(-x2 / fb);
    psir[count] =
        cos(2 * 3.1415926535897931159980 * fc * x[count]) * econ * con / ys;
    psii[count] =
        sin(2 * 3.1415926535897931159980 * fc * x[count]) * econ * con / ys;
  }
  return;
}


x86 assembly (clang, -O0):
<cmorlet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8d,-0x34(%rbp)
movsd  %xmm2,-0x40(%rbp)
movsd  0xe8e(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1060 <sqrt@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1278 <cmorlet+0x138>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x18(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  0xe14(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <cos@plt>
mulsd  -0x58(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xdd5(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
mulsd  -0x58(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1196 <cmorlet+0x56>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmorlet>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
movsd  %xmm2,0x18(%rsp)
mov    %rcx,%r14
mov    %rdx,%r15
movsd  %xmm1,0x8(%rsp)
movapd %xmm0,%xmm1
mov    %esi,%ebp
mov    %rdi,%rbx
movsd  0xe91(%rip),%xmm0
movsd  %xmm1,0x28(%rsp)
mulsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
lea    0x1(%rax),%edx
xor    %ecx,%ecx
cmp    $0x3,%edx
cmovb  %eax,%ecx
test   %ebp,%ebp
jle    124b <cmorlet+0x10b>
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe5c(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%r12d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%rbp,8),%xmm1
movapd %xmm1,%xmm0
xorpd  0xe3f(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  0x28(%rsp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,0x20(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <cos@plt>
mulsd  0x20(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
divsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%r15,%rbp,8)
movsd  (%rbx,%rbp,8),%xmm0
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
mulsd  0x20(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
divsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r12
jne    11c0 <cmorlet+0x80>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @cmorlet(double* %0, i32 %1, double %2, double %3, double* %4, double* %5, i32 %6, double %7) {
%9 = alloca double*
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca double
%17 = alloca i32
%18 = alloca double
%19 = alloca double
%20 = alloca double
store double* %0, double** %9
store i32 %1, i32* %10
store double %2, double* %11
store double %3, double* %12
store double* %4, double** %13
store double* %5, double** %14
store i32 %6, i32* %15
store double %7, double* %16
%21 = load double, double* %11
%22 = fmul double 0x400921FB54442D18, %21
%23 = call i32 @sqrt(double %22)
%24 = sdiv i32 1, %23
%25 = sitofp i32 %24 to double
store double %25, double* %18
store i32 0, i32* %17
br label %26
26: ; preds = %87, %8
%27 = load i32, i32* %17
%28 = load i32, i32* %10
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %90
30: ; preds = %26
%31 = load double*, double** %9
%32 = load i32, i32* %17
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = load double*, double** %9
%37 = load i32, i32* %17
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
%40 = load double, double* %39
%41 = fmul double %35, %40
store double %41, double* %20
%42 = load double, double* %20
%43 = fneg double %42
%44 = load double, double* %11
%45 = fdiv double %43, %44
%46 = call double @exp(double %45)
store double %46, double* %19
%47 = load double, double* %12
%48 = fmul double 0x401921FB54442D18, %47
%49 = load double*, double** %9
%50 = load i32, i32* %17
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double, double* %52
%54 = fmul double %48, %53
%55 = fptosi double %54 to i32
%56 = call double @cos(i32 %55)
%57 = load double, double* %19
%58 = fmul double %56, %57
%59 = load double, double* %18
%60 = fmul double %58, %59
%61 = load double, double* %16
%62 = fdiv double %60, %61
%63 = load double*, double** %13
%64 = load i32, i32* %17
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
store double %62, double* %66
%67 = load double, double* %12
%68 = fmul double 0x401921FB54442D18, %67
%69 = load double*, double** %9
%70 = load i32, i32* %17
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %69, i64 %71
%73 = load double, double* %72
%74 = fmul double %68, %73
%75 = fptosi double %74 to i32
%76 = call double @sin(i32 %75)
%77 = load double, double* %19
%78 = fmul double %76, %77
%79 = load double, double* %18
%80 = fmul double %78, %79
%81 = load double, double* %16
%82 = fdiv double %80, %81
%83 = load double*, double** %14
%84 = load i32, i32* %17
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %83, i64 %85
store double %82, double* %86
br label %87
87: ; preds = %30
%88 = load i32, i32* %17
%89 = add nsw i32 %88, 1
store i32 %89, i32* %17
br label %26
90: ; preds = %26
ret void
}

LLVM IR (-O2):
define void @cmorlet(double* nocapture %0, i32 %1, double %2, double %3, double* nocapture writeonly %4, double* nocapture writeonly %5, i32 %6, double %7) {
%9 = fmul double %2, 0x400921FB54442D18
%10 = tail call i32 @sqrt(double %9)
%11 = add i32 %10, 1
%12 = icmp ult i32 %11, 3
%13 = select i1 %12, i32 %10, i32 0
%14 = sitofp i32 %13 to double
%15 = icmp sgt i32 %1, 0
br i1 %15, label %16, label %45
16: ; preds = %8
%17 = fmul double %3, 0x401921FB54442D18
%18 = zext i32 %1 to i64
br label %19
19: ; preds = %16, %19
%20 = phi i64 [ 0, %16 ], [ %43, %19 ]
%21 = getelementptr inbounds double, double* %0, i64 %20
%22 = load double, double* %21
%23 = fneg double %22
%24 = fmul double %22, %23
%25 = fdiv double %24, %2
%26 = tail call double @exp(double %25)
%27 = load double, double* %21
%28 = fmul double %17, %27
%29 = fptosi double %28 to i32
%30 = tail call double @cos(i32 %29)
%31 = fmul double %26, %30
%32 = fmul double %31, %14
%33 = fdiv double %32, %7
%34 = getelementptr inbounds double, double* %4, i64 %20
store double %33, double* %34
%35 = load double, double* %21
%36 = fmul double %17, %35
%37 = fptosi double %36 to i32
%38 = tail call double @sin(i32 %37)
%39 = fmul double %26, %38
%40 = fmul double %39, %14
%41 = fdiv double %40, %7
%42 = getelementptr inbounds double, double* %5, i64 %20
store double %41, double* %42
%43 = add nuw nsw i64 %20, 1
%44 = icmp eq i64 %43, %18
br i1 %44, label %45, label %19
45: ; preds = %19, %8
ret void
}