#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*/ assert(int);
int ti_ao_start(double const *);
int ti_ao(int size, double const *const *inputs, double const *options,
          double *const *outputs) {
  const double *high = inputs[0];
  const double *low = inputs[1];
  const int period = 34;
  double *output = outputs[0];
  if (size <= ti_ao_start(options))
    return 0;
  double sum34 = 0;
  double sum5 = 0;
  const double per34 = 1.0 / 34.0;
  const double per5 = 1.0 / 5.0;
  int i;
  for (i = 0; i < 34; ++i) {
    double hl = 0.5 * (high[i] + low[i]);
    sum34 += hl;
    if (i >= 29)
      sum5 += hl;
  }
  *output++ = (per5 * sum5 - per34 * sum34);
  for (i = period; i < size; ++i) {
    double hl = 0.5 * (high[i] + low[i]);
    sum34 += hl;
    sum5 += hl;
    sum34 -= 0.5 * (high[i - 34] + low[i - 34]);
    sum5 -= 0.5 * (high[i - 5] + low[i - 5]);
    *output++ = (per5 * sum5 - per34 * sum34);
  }
  assert(output - outputs[0] == size - ti_ao_start(options));
  return 0;
}


x86 assembly (clang, -O0):
<ti_ao>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
movl   $0x22,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <ti_ao_start@plt>
mov    %eax,%ecx
mov    -0x7c(%rbp),%eax
cmp    %ecx,%eax
jg     118b <ti_ao+0x6b>
movl   $0x0,-0x4(%rbp)
jmp    1400 <ti_ao+0x2e0>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe65(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe50(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x22,-0x64(%rbp)
jge    122c <ti_ao+0x10c>
mov    -0x28(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x30(%rbp),%rax
movslq -0x64(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm1
movsd  0xe30(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
cmpl   $0x1d,-0x64(%rbp)
jl     1219 <ti_ao+0xf9>
movsd  -0x70(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    121e <ti_ao+0xfe>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11bc <ti_ao+0x9c>
movsd  -0x50(%rbp),%xmm0
movsd  0xdcf(%rip),%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xda3(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x40(%rbp)
movsd  %xmm0,(%rax)
movl   $0x22,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13aa <ti_ao+0x28a>
mov    -0x28(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x30(%rbp),%rax
movslq -0x64(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm1
movsd  0xd6b(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x78(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x64(%rbp),%ecx
sub    $0x22,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x64(%rbp),%ecx
sub    $0x22,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xd0b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x64(%rbp),%ecx
sub    $0x5,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x64(%rbp),%ecx
sub    $0x5,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  0xccd(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  0xcab(%rip),%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xc7f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x40(%rbp)
movsd  %xmm0,(%rax)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    127f <ti_ao+0x15f>
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
sar    $0x3,%rax
mov    %rax,-0x88(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <ti_ao_start@plt>
mov    -0x8c(%rbp),%ecx
mov    %eax,%edx
mov    -0x88(%rbp),%rax
sub    %edx,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ti_ao>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r14
mov    %edi,%r12d
mov    (%rsi),%rbp
mov    0x8(%rsi),%rbx
mov    (%rcx),%r13
mov    %rdx,%rdi
call   1040 <ti_ao_start@plt>
cmp    %r12d,%eax
jge    12c5 <ti_ao+0x1a5>
xorpd  %xmm1,%xmm1
xor    %eax,%eax
movsd  0xea3(%rip),%xmm0
movsd  0xea3(%rip),%xmm2
jmp    1192 <ti_ao+0x72>
nopw   0x0(%rax,%rax,1)
unpcklpd %xmm5,%xmm3
movapd %xmm1,%xmm5
addpd  %xmm3,%xmm5
unpcklpd %xmm6,%xmm4
movapd %xmm4,%xmm1
addpd  %xmm5,%xmm1
add    $0x2,%rax
cmp    $0x22,%rax
je     11cf <ti_ao+0xaf>
movsd  0x0(%rbp,%rax,8),%xmm3
addsd  (%rbx,%rax,8),%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm3,%xmm5
cmp    $0x1d,%rax
jae    11af <ti_ao+0x8f>
movapd %xmm2,%xmm5
movsd  0x8(%rbp,%rax,8),%xmm4
addsd  0x8(%rbx,%rax,8),%xmm4
mulsd  %xmm0,%xmm4
movapd %xmm4,%xmm6
cmp    $0x1c,%rax
jae    1170 <ti_ao+0x50>
movapd %xmm2,%xmm6
jmp    1170 <ti_ao+0x50>
movsd  0xe39(%rip),%xmm2
mulsd  %xmm1,%xmm2
movapd %xmm1,%xmm3
unpckhpd %xmm1,%xmm3
mulsd  0xe2d(%rip),%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,0x0(%r13)
add    $0x8,%r13
cmp    $0x23,%r12d
jl     12a2 <ti_ao+0x182>
mov    %r12d,%eax
lea    -0x110(,%rax,8),%rcx
ff
xor    %eax,%eax
movapd 0xe08(%rip),%xmm2
movsd  0xdf0(%rip),%xmm3
movsd  0xdf0(%rip),%xmm4
nopl   0x0(%rax,%rax,1)
movsd  0x110(%rbp,%rax,1),%xmm5
addsd  0x110(%rbx,%rax,1),%xmm5
mulsd  %xmm0,%xmm5
unpcklpd %xmm5,%xmm5
addpd  %xmm1,%xmm5
movsd  0x0(%rbp,%rax,1),%xmm6
movhpd 0xe8(%rbp,%rax,1),%xmm6
movsd  (%rbx,%rax,1),%xmm1
movhpd 0xe8(%rbx,%rax,1),%xmm1
addpd  %xmm6,%xmm1
mulpd  %xmm2,%xmm1
addpd  %xmm5,%xmm1
movapd %xmm1,%xmm5
mulsd  %xmm3,%xmm5
movapd %xmm1,%xmm6
unpckhpd %xmm1,%xmm6
mulsd  %xmm4,%xmm6
addsd  %xmm5,%xmm6
movsd  %xmm6,0x0(%r13,%rax,1)
add    $0x8,%rax
cmp    %rax,%rcx
jne    1230 <ti_ao+0x110>
add    %rax,%r13
sub    (%r15),%r13
sar    $0x3,%r13
mov    %r14,%rdi
call   1040 <ti_ao_start@plt>
sub    %eax,%r12d
movslq %r12d,%rax
xor    %edi,%edi
cmp    %rax,%r13
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ti_ao(i32 %0, double** %1, double* %2, double** %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double**
%8 = alloca double*
%9 = alloca double**
%10 = alloca double*
%11 = alloca double*
%12 = alloca i32
%13 = alloca double*
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca i32
%19 = alloca double
%20 = alloca double
store i32 %0, i32* %6
store double** %1, double*** %7
store double* %2, double** %8
store double** %3, double*** %9
%21 = load double**, double*** %7
%22 = getelementptr inbounds double*, double** %21, i64 0
%23 = load double*, double** %22
store double* %23, double** %10
%24 = load double**, double*** %7
%25 = getelementptr inbounds double*, double** %24, i64 1
%26 = load double*, double** %25
store double* %26, double** %11
store i32 34, i32* %12
%27 = load double**, double*** %9
%28 = getelementptr inbounds double*, double** %27, i64 0
%29 = load double*, double** %28
store double* %29, double** %13
%30 = load i32, i32* %6
%31 = load double*, double** %8
%32 = call i32 @ti_ao_start(double* %31)
%33 = icmp sle i32 %30, %32
br i1 %33, label %34, label %35
34: ; preds = %4
store i32 0, i32* %5
br label %153
35: ; preds = %4
store double 0.000000e+00, double* %14
store double 0.000000e+00, double* %15
store double 0x3F9E1E1E1E1E1E1E, double* %16
store double 2.000000e-01, double* %17
store i32 0, i32* %18
br label %36
36: ; preds = %62, %35
%37 = load i32, i32* %18
%38 = icmp slt i32 %37, 34
br i1 %38, label %39, label %65
39: ; preds = %36
%40 = load double*, double** %10
%41 = load i32, i32* %18
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = load double, double* %43
%45 = load double*, double** %11
%46 = load i32, i32* %18
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
%49 = load double, double* %48
%50 = fadd double %44, %49
%51 = fmul double 5.000000e-01, %50
store double %51, double* %19
%52 = load double, double* %19
%53 = load double, double* %14
%54 = fadd double %53, %52
store double %54, double* %14
%55 = load i32, i32* %18
%56 = icmp sge i32 %55, 29
br i1 %56, label %57, label %61
57: ; preds = %39
%58 = load double, double* %19
%59 = load double, double* %15
%60 = fadd double %59, %58
store double %60, double* %15
br label %61
61: ; preds = %57, %39
br label %62
62: ; preds = %61
%63 = load i32, i32* %18
%64 = add nsw i32 %63, 1
store i32 %64, i32* %18
br label %36
65: ; preds = %36
%66 = load double, double* %15
%67 = load double, double* %14
%68 = fmul double 0x3F9E1E1E1E1E1E1E, %67
%69 = fneg double %68
%70 = call double @llvm.fmuladd.f64(double 2.000000e-01, double %66, double %69)
%71 = load double*, double** %13
%72 = getelementptr inbounds double, double* %71, i32 1
store double* %72, double** %13
store double %70, double* %71
store i32 34, i32* %18
br label %73
73: ; preds = %133, %65
%74 = load i32, i32* %18
%75 = load i32, i32* %6
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %136
77: ; preds = %73
%78 = load double*, double** %10
%79 = load i32, i32* %18
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %78, i64 %80
%82 = load double, double* %81
%83 = load double*, double** %11
%84 = load i32, i32* %18
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %83, i64 %85
%87 = load double, double* %86
%88 = fadd double %82, %87
%89 = fmul double 5.000000e-01, %88
store double %89, double* %20
%90 = load double, double* %20
%91 = load double, double* %14
%92 = fadd double %91, %90
store double %92, double* %14
%93 = load double, double* %20
%94 = load double, double* %15
%95 = fadd double %94, %93
store double %95, double* %15
%96 = load double*, double** %10
%97 = load i32, i32* %18
%98 = sub nsw i32 %97, 34
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double, double* %96, i64 %99
%101 = load double, double* %100
%102 = load double*, double** %11
%103 = load i32, i32* %18
%104 = sub nsw i32 %103, 34
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds double, double* %102, i64 %105
%107 = load double, double* %106
%108 = fadd double %101, %107
%109 = load double, double* %14
%110 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %108, double %109)
store double %110, double* %14
%111 = load double*, double** %10
%112 = load i32, i32* %18
%113 = sub nsw i32 %112, 5
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %111, i64 %114
%116 = load double, double* %115
%117 = load double*, double** %11
%118 = load i32, i32* %18
%119 = sub nsw i32 %118, 5
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds double, double* %117, i64 %120
%122 = load double, double* %121
%123 = fadd double %116, %122
%124 = load double, double* %15
%125 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %123, double %124)
store double %125, double* %15
%126 = load double, double* %15
%127 = load double, double* %14
%128 = fmul double 0x3F9E1E1E1E1E1E1E, %127
%129 = fneg double %128
%130 = call double @llvm.fmuladd.f64(double 2.000000e-01, double %126, double %129)
%131 = load double*, double** %13
%132 = getelementptr inbounds double, double* %131, i32 1
store double* %132, double** %13
store double %130, double* %131
br label %133
133: ; preds = %77
%134 = load i32, i32* %18
%135 = add nsw i32 %134, 1
store i32 %135, i32* %18
br label %73
136: ; preds = %73
%137 = load double*, double** %13
%138 = load double**, double*** %9
%139 = getelementptr inbounds double*, double** %138, i64 0
%140 = load double*, double** %139
%141 = ptrtoint double* %137 to i64
%142 = ptrtoint double* %140 to i64
%143 = sub i64 %141, %142
%144 = sdiv exact i64 %143, 8
%145 = load i32, i32* %6
%146 = load double*, double** %8
%147 = call i32 @ti_ao_start(double* %146)
%148 = sub nsw i32 %145, %147
%149 = sext i32 %148 to i64
%150 = icmp eq i64 %144, %149
%151 = zext i1 %150 to i32
%152 = call i32 @assert(i32 %151)
store i32 0, i32* %5
br label %153
153: ; preds = %136, %34
%154 = load i32, i32* %5
ret i32 %154
}

LLVM IR (-O2):
define i32 @ti_ao(i32 %0, double** nocapture %1, double* %2, double** nocapture %3) {
%5 = load double*, double** %1
%6 = getelementptr inbounds double*, double** %1, i64 1
%7 = load double*, double** %6
%8 = load double*, double** %3
%9 = tail call i32 @ti_ao_start(double* %2)
%10 = icmp slt i32 %9, %0
br i1 %10, label %11, label %97
11: ; preds = %4, %11
%12 = phi i64 [ %37, %11 ], [ 0, %4 ]
%13 = phi <2 x double> [ %36, %11 ], [ zeroinitializer, %4 ]
%14 = getelementptr inbounds double, double* %5, i64 %12
%15 = load double, double* %14
%16 = getelementptr inbounds double, double* %7, i64 %12
%17 = load double, double* %16
%18 = fadd double %15, %17
%19 = fmul double %18, 5.000000e-01
%20 = icmp ugt i64 %12, 28
%21 = select i1 %20, double %19, double -0.000000e+00
%22 = insertelement <2 x double> poison, double %19, i64 0
%23 = insertelement <2 x double> %22, double %21, i64 1
%24 = fadd <2 x double> %13, %23
%25 = or i64 %12, 1
%26 = getelementptr inbounds double, double* %5, i64 %25
%27 = load double, double* %26
%28 = getelementptr inbounds double, double* %7, i64 %25
%29 = load double, double* %28
%30 = fadd double %27, %29
%31 = fmul double %30, 5.000000e-01
%32 = icmp ugt i64 %12, 27
%33 = select i1 %32, double %31, double -0.000000e+00
%34 = insertelement <2 x double> poison, double %31, i64 0
%35 = insertelement <2 x double> %34, double %33, i64 1
%36 = fadd <2 x double> %24, %35
%37 = add nuw nsw i64 %12, 2
%38 = icmp eq i64 %37, 34
br i1 %38, label %39, label %11
39: ; preds = %11
%40 = extractelement <2 x double> %36, i64 0
%41 = fmul double %40, 0xBF9E1E1E1E1E1E1E
%42 = extractelement <2 x double> %36, i64 1
%43 = tail call double @llvm.fmuladd.f64(double %42, double 2.000000e-01, double %41)
store double %43, double* %8
%44 = getelementptr inbounds double, double* %8, i64 1
%45 = icmp sgt i32 %0, 34
br i1 %45, label %46, label %84
46: ; preds = %39
%47 = zext i32 %0 to i64
br label %48
48: ; preds = %46, %48
%49 = phi i64 [ 34, %46 ], [ %81, %48 ]
%50 = phi double* [ %44, %46 ], [ %82, %48 ]
%51 = phi <2 x double> [ %36, %46 ], [ %76, %48 ]
%52 = getelementptr inbounds double, double* %5, i64 %49
%53 = load double, double* %52
%54 = getelementptr inbounds double, double* %7, i64 %49
%55 = load double, double* %54
%56 = fadd double %53, %55
%57 = fmul double %56, 5.000000e-01
%58 = insertelement <2 x double> poison, double %57, i64 0
%59 = shufflevector <2 x double> %58, <2 x double> poison, <2 x i32> zeroinitializer
%60 = fadd <2 x double> %51, %59
%61 = add nsw i64 %49, -34
%62 = getelementptr inbounds double, double* %5, i64 %61
%63 = load double, double* %62
%64 = getelementptr inbounds double, double* %7, i64 %61
%65 = load double, double* %64
%66 = add nsw i64 %49, -5
%67 = getelementptr inbounds double, double* %5, i64 %66
%68 = load double, double* %67
%69 = getelementptr inbounds double, double* %7, i64 %66
%70 = load double, double* %69
%71 = insertelement <2 x double> poison, double %63, i64 0
%72 = insertelement <2 x double> %71, double %68, i64 1
%73 = insertelement <2 x double> poison, double %65, i64 0
%74 = insertelement <2 x double> %73, double %70, i64 1
%75 = fadd <2 x double> %72, %74
%76 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %75, <2 x double> <double -5.000000e-01, double -5.000000e-01>, <2 x double> %60)
%77 = extractelement <2 x double> %76, i64 0
%78 = fmul double %77, 0xBF9E1E1E1E1E1E1E
%79 = extractelement <2 x double> %76, i64 1
%80 = tail call double @llvm.fmuladd.f64(double %79, double 2.000000e-01, double %78)
store double %80, double* %50
%81 = add nuw nsw i64 %49, 1
%82 = getelementptr inbounds double, double* %50, i64 1
%83 = icmp eq i64 %81, %47
br i1 %83, label %84, label %48
84: ; preds = %48, %39
%85 = phi double* [ %44, %39 ], [ %82, %48 ]
%86 = load double*, double** %3
%87 = ptrtoint double* %85 to i64
%88 = ptrtoint double* %86 to i64
%89 = sub i64 %87, %88
%90 = ashr exact i64 %89, 3
%91 = tail call i32 @ti_ao_start(double* %2)
%92 = sub nsw i32 %0, %91
%93 = sext i32 %92 to i64
%94 = icmp eq i64 %90, %93
%95 = zext i1 %94 to i32
%96 = tail call i32 @assert(i32 %95)
br label %97
97: ; preds = %4, %84
ret i32 0
}