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


x86 assembly (clang, -O0):
<cmorlet_packet>:
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)
movsd  0xe9d(%rip),%xmm0
call   1060 <sqrt@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    125a <cmorlet_packet+0x11a>
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,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  0xe25(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <cos@plt>
mulsd  -0x40(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  0xdeb(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
mulsd  -0x40(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    -0xc(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1182 <cmorlet_packet+0x42>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmorlet_packet>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
movsd  0xe9e(%rip),%xmm0
call   1060 <sqrt@plt>
lea    0x1(%rax),%edx
xor    %ecx,%ecx
cmp    $0x3,%edx
cmovb  %eax,%ecx
test   %ebp,%ebp
jle    121d <cmorlet_packet+0xdd>
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%r12d
lea    (%r14,%r12,8),%r15
xor    %ebp,%ebp
movsd  (%rbx,%rbp,8),%xmm1
movapd %xmm1,%xmm0
xorpd  0xe6f(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
movsd  0xe4b(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <cos@plt>
mulsd  0x18(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbp,8)
movsd  (%rbx,%rbp,8),%xmm0
mulsd  0xe19(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
mulsd  0x18(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r15,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1190 <cmorlet_packet+0x50>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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