#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 _lomb_scargle(int, double *, double *, double *, double, double, double);
int /*<<< orphan*/ calc_dotprod(int, double *, double *, double *, int,
                                double *, double *);
double do_lomb(int numt, int detrend_order, double cn[], double sinx[],
               double cosx[], double wth[]) {
  int i;
  double st, cst, ct, st0, ct0;
  for (i = 0, ct = 0, st = 0, cst = 0; i <= detrend_order; i++) {
    calc_dotprod(numt, sinx, cosx, wth, i, &st0, &ct0);
    st += st0 * st0;
    ct += ct0 * ct0;
    cst += st0 * ct0;
  }
  return _lomb_scargle(numt, cn, sinx, cosx, st, ct, cst);
}


x86 assembly (clang, -O0):
<do_lomb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11ef <do_lomb+0xcf>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
lea    -0x50(%rbp),%r9
lea    -0x58(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <calc_dotprod@plt>
movsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115d <do_lomb+0x3d>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
movsd  -0x38(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
call   1030 <_lomb_scargle@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_lomb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8,%r14
mov    %rcx,%r12
mov    %edi,%r13d
test   %esi,%esi
js     11da <do_lomb+0xba>
mov    %r9,%rbx
mov    %esi,%ebp
mov    %rdx,0x10(%rsp)
add    $0x1,%ebp
xorpd  %xmm1,%xmm1
xor    %r15d,%r15d
xorpd  %xmm3,%xmm3
nopw   0x0(%rax,%rax,1)
movsd  %xmm3,0x18(%rsp)
movapd %xmm1,0x30(%rsp)
lea    0x20(%rsp),%rax
mov    %rax,(%rsp)
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %r15d,%r8d
lea    0x28(%rsp),%r9
call   1040 <calc_dotprod@plt>
movsd  0x18(%rsp),%xmm3
movsd  0x20(%rsp),%xmm1
movsd  0x28(%rsp),%xmm0
movapd %xmm0,%xmm2
unpcklpd %xmm1,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm1,%xmm3
unpcklpd %xmm2,%xmm2
mulpd  %xmm2,%xmm0
movapd 0x30(%rsp),%xmm2
movapd %xmm0,%xmm1
addpd  %xmm2,%xmm1
add    $0x1,%r15d
cmp    %r15d,%ebp
jne    1160 <do_lomb+0x40>
addpd  %xmm2,%xmm0
mov    0x10(%rsp),%rdx
jmp    11e2 <do_lomb+0xc2>
xorpd  %xmm0,%xmm0
xorpd  %xmm3,%xmm3
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
mov    %r13d,%edi
mov    %rdx,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
movapd %xmm3,%xmm1
call   1030 <_lomb_scargle@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @do_lomb(i32 %0, i32 %1, double* %2, double* %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store i32 %0, i32* %7
store i32 %1, i32* %8
store double* %2, double** %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
store i32 0, i32* %13
store double 0.000000e+00, double* %16
store double 0.000000e+00, double* %14
store double 0.000000e+00, double* %15
br label %19
19: ; preds = %42, %6
%20 = load i32, i32* %13
%21 = load i32, i32* %8
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %45
23: ; preds = %19
%24 = load i32, i32* %7
%25 = load double*, double** %10
%26 = load double*, double** %11
%27 = load double*, double** %12
%28 = load i32, i32* %13
%29 = call i32 @calc_dotprod(i32 %24, double* %25, double* %26, double* %27, i32 %28, double* %17, double* %18)
%30 = load double, double* %17
%31 = load double, double* %17
%32 = load double, double* %14
%33 = call double @llvm.fmuladd.f64(double %30, double %31, double %32)
store double %33, double* %14
%34 = load double, double* %18
%35 = load double, double* %18
%36 = load double, double* %16
%37 = call double @llvm.fmuladd.f64(double %34, double %35, double %36)
store double %37, double* %16
%38 = load double, double* %17
%39 = load double, double* %18
%40 = load double, double* %15
%41 = call double @llvm.fmuladd.f64(double %38, double %39, double %40)
store double %41, double* %15
br label %42
42: ; preds = %23
%43 = load i32, i32* %13
%44 = add nsw i32 %43, 1
store i32 %44, i32* %13
br label %19
45: ; preds = %19
%46 = load i32, i32* %7
%47 = load double*, double** %9
%48 = load double*, double** %10
%49 = load double*, double** %11
%50 = load double, double* %14
%51 = load double, double* %16
%52 = load double, double* %15
%53 = call double @_lomb_scargle(i32 %46, double* %47, double* %48, double* %49, double %50, double %51, double %52)
ret double %53
}

LLVM IR (-O2):
define double @do_lomb(i32 %0, i32 %1, double* %2, double* %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = bitcast double* %7 to i8*
%10 = bitcast double* %8 to i8*
%11 = icmp slt i32 %1, 0
br i1 %11, label %28, label %12
12: ; preds = %6, %12
%13 = phi double [ %19, %12 ], [ 0.000000e+00, %6 ]
%14 = phi i32 [ %24, %12 ], [ 0, %6 ]
%15 = phi <2 x double> [ %23, %12 ], [ zeroinitializer, %6 ]
%16 = call i32 @calc_dotprod(i32 %0, double* %3, double* %4, double* %5, i32 %14, double* %7, double* %8)
%17 = load double, double* %7
%18 = load double, double* %8
%19 = call double @llvm.fmuladd.f64(double %18, double %18, double %13)
%20 = insertelement <2 x double> poison, double %17, i64 0
%21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
%22 = insertelement <2 x double> %20, double %18, i64 1
%23 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %21, <2 x double> %22, <2 x double> %15)
%24 = add nuw i32 %14, 1
%25 = icmp eq i32 %14, %1
br i1 %25, label %26, label %12
26: ; preds = %12
%27 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %21, <2 x double> %22, <2 x double> %15)
br label %28
28: ; preds = %26, %6
%29 = phi double [ 0.000000e+00, %6 ], [ %19, %26 ]
%30 = phi <2 x double> [ zeroinitializer, %6 ], [ %27, %26 ]
%31 = extractelement <2 x double> %30, i64 0
%32 = extractelement <2 x double> %30, i64 1
%33 = call double @_lomb_scargle(i32 %0, double* %2, double* %3, double* %4, double %31, double %29, double %32)
ret double %33
}