#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 */
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ lowpass(double *, double *, double *, size_t, double, double,
                           double, double, double *, int, int);
double *malloc(size_t);
void highpass(double time[], double flux[], double weight[], size_t N,
              double fhigh, double low, double high, double rate,
              double result[], int useweight, int quiet) {
  double *temp = malloc(N * sizeof(double));
  lowpass(time, flux, weight, N, fhigh, low, high, rate, temp, useweight,
          quiet);
  for (size_t i = 0; i < N; ++i) {
    result[i] = flux[i] - temp[i];
  }
  free(temp);
}


x86 assembly (clang, -O0):
<highpass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
movsd  %xmm1,-0x30(%rbp)
movsd  %xmm2,-0x38(%rbp)
movsd  %xmm3,-0x40(%rbp)
mov    %r8,-0x48(%rbp)
mov    %r9d,-0x4c(%rbp)
mov    -0x20(%rbp),%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
mov    -0x58(%rbp),%r8
mov    -0x4c(%rbp),%r9d
mov    0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <lowpass@plt>
movq   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11fd <highpass+0xcd>
mov    -0x10(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x58(%rbp),%rax
mov    -0x60(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    11b7 <highpass+0x87>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<highpass>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,0xc(%rsp)
mov    %r8,%r15
movsd  %xmm3,0x30(%rsp)
movsd  %xmm2,0x28(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    %rcx,%r14
mov    %rdx,0x10(%rsp)
mov    %rsi,%r12
mov    %rdi,%r13
mov    0x70(%rsp),%ebp
lea    0x0(,%rcx,8),%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,(%rsp)
mov    %r13,%rdi
mov    %r12,%rsi
mov    0x10(%rsp),%rdx
mov    %r14,%rcx
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
movsd  0x30(%rsp),%xmm3
mov    %rax,%r8
mov    0xc(%rsp),%r9d
call   1040 <lowpass@plt>
test   %r14,%r14
je     1362 <highpass+0x232>
cmp    $0x4,%r14
jb     11df <highpass+0xaf>
lea    (%r12,%r14,8),%rax
cmp    %r15,%rax
jbe    128b <highpass+0x15b>
lea    (%r15,%r14,8),%rax
cmp    %r12,%rax
jbe    128b <highpass+0x15b>
xor    %eax,%eax
mov    %rax,%rcx
not    %rcx
add    %r14,%rcx
mov    %r14,%rdx
and    $0x3,%rdx
je     121b <highpass+0xeb>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%r12,%rax,8),%xmm0
subsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,(%r15,%rax,8)
add    $0x1,%rax
add    $0xffffffffffffffff,%rdx
jne    1200 <highpass+0xd0>
cmp    $0x3,%rcx
jb     1362 <highpass+0x232>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%r12,%rax,8),%xmm0
subsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,(%r15,%rax,8)
movsd  0x8(%r12,%rax,8),%xmm0
subsd  0x8(%rbx,%rax,8),%xmm0
movsd  %xmm0,0x8(%r15,%rax,8)
movsd  0x10(%r12,%rax,8),%xmm0
subsd  0x10(%rbx,%rax,8),%xmm0
movsd  %xmm0,0x10(%r15,%rax,8)
movsd  0x18(%r12,%rax,8),%xmm0
subsd  0x18(%rbx,%rax,8),%xmm0
movsd  %xmm0,0x18(%r15,%rax,8)
add    $0x4,%rax
cmp    %rax,%r14
jne    1230 <highpass+0x100>
jmp    1362 <highpass+0x232>
mov    %r14,%rax
and    $0xfffffffffffffffc,%rax
lea    -0x4(%rax),%rcx
mov    %rcx,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
test   %rcx,%rcx
je     1378 <highpass+0x248>
mov    %rdx,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movupd (%r12,%rcx,8),%xmm0
movupd 0x10(%r12,%rcx,8),%xmm1
movupd (%rbx,%rcx,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%rbx,%rcx,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,(%r15,%rcx,8)
movupd %xmm1,0x10(%r15,%rcx,8)
movupd 0x20(%r12,%rcx,8),%xmm0
movupd 0x30(%r12,%rcx,8),%xmm1
movupd 0x20(%rbx,%rcx,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x30(%rbx,%rcx,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,0x20(%r15,%rcx,8)
movupd %xmm1,0x30(%r15,%rcx,8)
add    $0x8,%rcx
add    $0xfffffffffffffffe,%rsi
jne    12c0 <highpass+0x190>
test   $0x1,%dl
je     1359 <highpass+0x229>
movupd (%r12,%rcx,8),%xmm0
movupd 0x10(%r12,%rcx,8),%xmm1
movupd (%rbx,%rcx,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%rbx,%rcx,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,(%r15,%rcx,8)
movupd %xmm1,0x10(%r15,%rcx,8)
cmp    %r14,%rax
jne    11e1 <highpass+0xb1>
mov    %rbx,%rdi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
xor    %ecx,%ecx
test   $0x1,%dl
jne    132c <highpass+0x1fc>
jmp    1359 <highpass+0x229>

LLVM IR (-O0):
define void @highpass(double* %0, double* %1, double* %2, i64 %3, double %4, double %5, double %6, double %7, double* %8, i32 %9, i32 %10) {
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca i64
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double*
%21 = alloca i32
%22 = alloca i32
%23 = alloca double*
%24 = alloca i64
store double* %0, double** %12
store double* %1, double** %13
store double* %2, double** %14
store i64 %3, i64* %15
store double %4, double* %16
store double %5, double* %17
store double %6, double* %18
store double %7, double* %19
store double* %8, double** %20
store i32 %9, i32* %21
store i32 %10, i32* %22
%25 = load i64, i64* %15
%26 = mul i64 %25, 8
%27 = call double* @malloc(i64 %26)
store double* %27, double** %23
%28 = load double*, double** %12
%29 = load double*, double** %13
%30 = load double*, double** %14
%31 = load i64, i64* %15
%32 = load double, double* %16
%33 = load double, double* %17
%34 = load double, double* %18
%35 = load double, double* %19
%36 = load double*, double** %23
%37 = load i32, i32* %21
%38 = load i32, i32* %22
%39 = call i32 @lowpass(double* %28, double* %29, double* %30, i64 %31, double %32, double %33, double %34, double %35, double* %36, i32 %37, i32 %38)
store i64 0, i64* %24
br label %40
40: ; preds = %57, %11
%41 = load i64, i64* %24
%42 = load i64, i64* %15
%43 = icmp ult i64 %41, %42
br i1 %43, label %44, label %60
44: ; preds = %40
%45 = load double*, double** %13
%46 = load i64, i64* %24
%47 = getelementptr inbounds double, double* %45, i64 %46
%48 = load double, double* %47
%49 = load double*, double** %23
%50 = load i64, i64* %24
%51 = getelementptr inbounds double, double* %49, i64 %50
%52 = load double, double* %51
%53 = fsub double %48, %52
%54 = load double*, double** %20
%55 = load i64, i64* %24
%56 = getelementptr inbounds double, double* %54, i64 %55
store double %53, double* %56
br label %57
57: ; preds = %44
%58 = load i64, i64* %24
%59 = add i64 %58, 1
store i64 %59, i64* %24
br label %40
60: ; preds = %40
%61 = load double*, double** %23
%62 = call i32 @free(double* %61)
ret void
}

LLVM IR (-O2):
define void @highpass(double* %0, double* %1, double* %2, i64 %3, double %4, double %5, double %6, double %7, double* nocapture writeonly %8, i32 %9, i32 %10) {
%12 = shl i64 %3, 3
%13 = tail call double* @malloc(i64 %12)
%14 = tail call i32 @lowpass(double* %0, double* %1, double* %2, i64 %3, double %4, double %5, double %6, double %7, double* %13, i32 %9, i32 %10)
%15 = icmp eq i64 %3, 0
br i1 %15, label %121, label %16
16: ; preds = %11
%17 = icmp ult i64 %3, 4
br i1 %17, label %100, label %18
18: ; preds = %16
%19 = getelementptr double, double* %8, i64 %3
%20 = getelementptr double, double* %1, i64 %3
%21 = icmp ugt double* %20, %8
%22 = icmp ugt double* %19, %1
%23 = and i1 %21, %22
br i1 %23, label %100, label %24
24: ; preds = %18
%25 = and i64 %3, -4
%26 = add i64 %25, -4
%27 = lshr exact i64 %26, 2
%28 = add nuw nsw i64 %27, 1
%29 = and i64 %28, 1
%30 = icmp eq i64 %26, 0
br i1 %30, label %76, label %31
31: ; preds = %24
%32 = and i64 %28, 9223372036854775806
br label %33
33: ; preds = %33, %31
%34 = phi i64 [ 0, %31 ], [ %73, %33 ]
%35 = phi i64 [ 0, %31 ], [ %74, %33 ]
%36 = getelementptr inbounds double, double* %1, i64 %34
%37 = bitcast double* %36 to <2 x double>*
%38 = load <2 x double>, <2 x double>* %37
%39 = getelementptr inbounds double, double* %36, i64 2
%40 = bitcast double* %39 to <2 x double>*
%41 = load <2 x double>, <2 x double>* %40
%42 = getelementptr inbounds double, double* %13, i64 %34
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = getelementptr inbounds double, double* %42, i64 2
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = fsub <2 x double> %38, %44
%49 = fsub <2 x double> %41, %47
%50 = getelementptr inbounds double, double* %8, i64 %34
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> %48, <2 x double>* %51
%52 = getelementptr inbounds double, double* %50, i64 2
%53 = bitcast double* %52 to <2 x double>*
store <2 x double> %49, <2 x double>* %53
%54 = or i64 %34, 4
%55 = getelementptr inbounds double, double* %1, i64 %54
%56 = bitcast double* %55 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = getelementptr inbounds double, double* %55, i64 2
%59 = bitcast double* %58 to <2 x double>*
%60 = load <2 x double>, <2 x double>* %59
%61 = getelementptr inbounds double, double* %13, i64 %54
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = getelementptr inbounds double, double* %61, i64 2
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = fsub <2 x double> %57, %63
%68 = fsub <2 x double> %60, %66
%69 = getelementptr inbounds double, double* %8, i64 %54
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> %67, <2 x double>* %70
%71 = getelementptr inbounds double, double* %69, i64 2
%72 = bitcast double* %71 to <2 x double>*
store <2 x double> %68, <2 x double>* %72
%73 = add nuw i64 %34, 8
%74 = add i64 %35, 2
%75 = icmp eq i64 %74, %32
br i1 %75, label %76, label %33
76: ; preds = %33, %24
%77 = phi i64 [ 0, %24 ], [ %73, %33 ]
%78 = icmp eq i64 %29, 0
br i1 %78, label %98, label %79
79: ; preds = %76
%80 = getelementptr inbounds double, double* %1, i64 %77
%81 = bitcast double* %80 to <2 x double>*
%82 = load <2 x double>, <2 x double>* %81
%83 = getelementptr inbounds double, double* %80, i64 2
%84 = bitcast double* %83 to <2 x double>*
%85 = load <2 x double>, <2 x double>* %84
%86 = getelementptr inbounds double, double* %13, i64 %77
%87 = bitcast double* %86 to <2 x double>*
%88 = load <2 x double>, <2 x double>* %87
%89 = getelementptr inbounds double, double* %86, i64 2
%90 = bitcast double* %89 to <2 x double>*
%91 = load <2 x double>, <2 x double>* %90
%92 = fsub <2 x double> %82, %88
%93 = fsub <2 x double> %85, %91
%94 = getelementptr inbounds double, double* %8, i64 %77
%95 = bitcast double* %94 to <2 x double>*
store <2 x double> %92, <2 x double>* %95
%96 = getelementptr inbounds double, double* %94, i64 2
%97 = bitcast double* %96 to <2 x double>*
store <2 x double> %93, <2 x double>* %97
br label %98
98: ; preds = %76, %79
%99 = icmp eq i64 %25, %3
br i1 %99, label %121, label %100
100: ; preds = %18, %16, %98
%101 = phi i64 [ 0, %18 ], [ 0, %16 ], [ %25, %98 ]
%102 = xor i64 %101, -1
%103 = add i64 %102, %3
%104 = and i64 %3, 3
%105 = icmp eq i64 %104, 0
br i1 %105, label %118, label %106
106: ; preds = %100, %106
%107 = phi i64 [ %115, %106 ], [ %101, %100 ]
%108 = phi i64 [ %116, %106 ], [ 0, %100 ]
%109 = getelementptr inbounds double, double* %1, i64 %107
%110 = load double, double* %109
%111 = getelementptr inbounds double, double* %13, i64 %107
%112 = load double, double* %111
%113 = fsub double %110, %112
%114 = getelementptr inbounds double, double* %8, i64 %107
store double %113, double* %114
%115 = add nuw i64 %107, 1
%116 = add i64 %108, 1
%117 = icmp eq i64 %116, %104
br i1 %117, label %118, label %106
118: ; preds = %106, %100
%119 = phi i64 [ %101, %100 ], [ %115, %106 ]
%120 = icmp ult i64 %103, 3
br i1 %120, label %121, label %123
121: ; preds = %118, %123, %98, %11
%122 = tail call i32 @free(double* %13)
ret void
123: ; preds = %118, %123
%124 = phi i64 [ %152, %123 ], [ %119, %118 ]
%125 = getelementptr inbounds double, double* %1, i64 %124
%126 = load double, double* %125
%127 = getelementptr inbounds double, double* %13, i64 %124
%128 = load double, double* %127
%129 = fsub double %126, %128
%130 = getelementptr inbounds double, double* %8, i64 %124
store double %129, double* %130
%131 = add nuw i64 %124, 1
%132 = getelementptr inbounds double, double* %1, i64 %131
%133 = load double, double* %132
%134 = getelementptr inbounds double, double* %13, i64 %131
%135 = load double, double* %134
%136 = fsub double %133, %135
%137 = getelementptr inbounds double, double* %8, i64 %131
store double %136, double* %137
%138 = add nuw i64 %124, 2
%139 = getelementptr inbounds double, double* %1, i64 %138
%140 = load double, double* %139
%141 = getelementptr inbounds double, double* %13, i64 %138
%142 = load double, double* %141
%143 = fsub double %140, %142
%144 = getelementptr inbounds double, double* %8, i64 %138
store double %143, double* %144
%145 = add nuw i64 %124, 3
%146 = getelementptr inbounds double, double* %1, i64 %145
%147 = load double, double* %146
%148 = getelementptr inbounds double, double* %13, i64 %145
%149 = load double, double* %148
%150 = fsub double %147, %149
%151 = getelementptr inbounds double, double* %8, i64 %145
store double %150, double* %151
%152 = add nuw i64 %124, 4
%153 = icmp eq i64 %152, %3
br i1 %153, label %121, label %123
}