#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 sin(int);
double sqrt(double);
void shanwavf(double *x, int sigInLength, double fb, double fc, double *psir,
              double *psii, int sigOutLength, double ys) {
  int count;
  double con, econ;
  con = sqrt(fb);
  for (count = 0; count < sigInLength; count++) {
    if (x[count] != 0)
      econ = sin(x[count] * fb * 3.1415926535897931159980) /
             (x[count] * fb * 3.1415926535897931159980);
    else
      econ = 1;
    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):
<shanwavf>:
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  -0x18(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    128d <shanwavf+0x15d>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a1 <shanwavf+0x71>
jp     11a1 <shanwavf+0x71>
jmp    11f4 <shanwavf+0xc4>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe4d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  0xe26(%rip),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1201 <shanwavf+0xd1>
movsd  0xe04(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe07(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <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  0xdc8(%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    1170 <shanwavf+0x40>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shanwavf>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
movsd  %xmm2,0x28(%rsp)
mov    %rcx,%r14
mov    %rdx,%r15
movsd  %xmm1,0x8(%rsp)
mov    %esi,%ebp
mov    %rdi,%rbx
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
movsd  %xmm0,0x20(%rsp)
jb     1169 <shanwavf+0x39>
sqrtsd %xmm0,%xmm0
jmp    116e <shanwavf+0x3e>
call   1050 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
test   %ebp,%ebp
jle    1264 <shanwavf+0x134>
movsd  0x8(%rsp),%xmm0
mulsd  0xe76(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%r12d
xor    %ebp,%ebp
jmp    1238 <shanwavf+0x108>
nopw   0x0(%rax,%rax,1)
mulsd  0x20(%rsp),%xmm2
movsd  0xe62(%rip),%xmm1
mulsd  %xmm1,%xmm2
cvttsd2si %xmm2,%edi
call   1030 <sin@plt>
movsd  (%rbx,%rbp,8),%xmm2
movapd %xmm2,%xmm1
mulsd  0x20(%rsp),%xmm1
mulsd  0xe3e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
mulsd  0x8(%rsp),%xmm2
cvttsd2si %xmm2,%edi
call   1040 <cos@plt>
mulsd  0x18(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
divsd  0x28(%rsp),%xmm0
movsd  %xmm0,(%r15,%rbp,8)
movsd  (%rbx,%rbp,8),%xmm0
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
mulsd  0x18(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
divsd  0x28(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r12
je     1264 <shanwavf+0x134>
movsd  (%rbx,%rbp,8),%xmm2
ucomisd 0xdd3(%rip),%xmm2
jne    11a0 <shanwavf+0x70>
jp     11a0 <shanwavf+0x70>
movsd  0xdaf(%rip),%xmm1
movsd  %xmm1,0x18(%rsp)
jmp    11dc <shanwavf+0xac>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @shanwavf(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
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
%20 = load double, double* %11
%21 = call double @sqrt(double %20)
store double %21, double* %18
store i32 0, i32* %17
br label %22
22: ; preds = %95, %8
%23 = load i32, i32* %17
%24 = load i32, i32* %10
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %98
26: ; preds = %22
%27 = load double*, double** %9
%28 = load i32, i32* %17
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double, double* %30
%32 = fcmp une double %31, 0.000000e+00
br i1 %32, label %33, label %53
33: ; preds = %26
%34 = load double*, double** %9
%35 = load i32, i32* %17
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = load double, double* %11
%40 = fmul double %38, %39
%41 = fmul double %40, 0x400921FB54442D18
%42 = fptosi double %41 to i32
%43 = call double @sin(i32 %42)
%44 = load double*, double** %9
%45 = load i32, i32* %17
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = load double, double* %47
%49 = load double, double* %11
%50 = fmul double %48, %49
%51 = fmul double %50, 0x400921FB54442D18
%52 = fdiv double %43, %51
store double %52, double* %19
br label %54
53: ; preds = %26
store double 1.000000e+00, double* %19
br label %54
54: ; preds = %53, %33
%55 = load double, double* %12
%56 = fmul double 0x401921FB54442D18, %55
%57 = load double*, double** %9
%58 = load i32, i32* %17
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %57, i64 %59
%61 = load double, double* %60
%62 = fmul double %56, %61
%63 = fptosi double %62 to i32
%64 = call double @cos(i32 %63)
%65 = load double, double* %19
%66 = fmul double %64, %65
%67 = load double, double* %18
%68 = fmul double %66, %67
%69 = load double, double* %16
%70 = fdiv double %68, %69
%71 = load double*, double** %13
%72 = load i32, i32* %17
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %71, i64 %73
store double %70, double* %74
%75 = load double, double* %12
%76 = fmul double 0x401921FB54442D18, %75
%77 = load double*, double** %9
%78 = load i32, i32* %17
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %77, i64 %79
%81 = load double, double* %80
%82 = fmul double %76, %81
%83 = fptosi double %82 to i32
%84 = call double @sin(i32 %83)
%85 = load double, double* %19
%86 = fmul double %84, %85
%87 = load double, double* %18
%88 = fmul double %86, %87
%89 = load double, double* %16
%90 = fdiv double %88, %89
%91 = load double*, double** %14
%92 = load i32, i32* %17
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %91, i64 %93
store double %90, double* %94
br label %95
95: ; preds = %54
%96 = load i32, i32* %17
%97 = add nsw i32 %96, 1
store i32 %97, i32* %17
br label %22
98: ; preds = %22
ret void
}

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