#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);
double sqrt(double);
int ti_bbands_start(double const *);
int ti_bbands(int size, double const *const *inputs, double const *options,
              double *const *outputs) {
  const double *input = inputs[0];
  double *lower = outputs[0];
  double *middle = outputs[1];
  double *upper = outputs[2];
  const int period = (int)options[0];
  const double stddev = options[1];
  const double scale = 1.0 / period;
  if (period < 1)
    return 1;
  if (size <= ti_bbands_start(options))
    return 0;
  double sum = 0;
  double sum2 = 0;
  int i;
  for (i = 0; i < period; ++i) {
    sum += input[i];
    sum2 += input[i] * input[i];
  }
  double sd = sqrt(sum2 * scale - (sum * scale) * (sum * scale));
  *middle = sum * scale;
  *lower++ = *middle - stddev * sd;
  *upper++ = *middle + stddev * sd;
  ++middle;
  for (i = period; i < size; ++i) {
    sum += input[i];
    sum2 += input[i] * input[i];
    sum -= input[i - period];
    sum2 -= input[i - period] * input[i - period];
    sd = sqrt(sum2 * scale - (sum * scale) * (sum * scale));
    *middle = sum * scale;
    *upper++ = *middle + stddev * sd;
    *lower++ = *middle - stddev * sd;
    ++middle;
  }
  assert(lower - outputs[0] == size - ti_bbands_start(options));
  assert(middle - outputs[1] == size - ti_bbands_start(options));
  assert(upper - outputs[2] == size - ti_bbands_start(options));
  return 0;
}


x86 assembly (clang, -O0):
<ti_bbands>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%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    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
cvttsd2si (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdl -0x44(%rbp),%xmm1
movsd  0xe62(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
cmpl   $0x1,-0x44(%rbp)
jge    11bd <ti_bbands+0x8d>
movl   $0x1,-0x4(%rbp)
jmp    15d3 <ti_bbands+0x4a3>
mov    -0x8(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <ti_bbands_start@plt>
mov    %eax,%ecx
mov    -0x7c(%rbp),%eax
cmp    %ecx,%eax
jg     11e5 <ti_bbands+0xb5>
movl   $0x0,-0x4(%rbp)
jmp    15d3 <ti_bbands+0x4a3>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1259 <ti_bbands+0x129>
mov    -0x28(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    11fc <ti_bbands+0xcc>
movsd  -0x68(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm3
mulsd  -0x58(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x60(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x30(%rbp)
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x78(%rbp),%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    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14dd <ti_bbands+0x3ad>
mov    -0x28(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x6c(%rbp),%ecx
sub    -0x44(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x60(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x6c(%rbp),%ecx
sub    -0x44(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x6c(%rbp),%ecx
sub    -0x44(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x68(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm3
mulsd  -0x58(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x60(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x78(%rbp),%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    -0x38(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x30(%rbp)
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1339 <ti_bbands+0x209>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
sar    $0x3,%rax
mov    %rax,-0xa8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <ti_bbands_start@plt>
mov    -0xac(%rbp),%ecx
mov    %eax,%edx
mov    -0xa8(%rbp),%rax
sub    %edx,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    0x8(%rcx),%rcx
sub    %rcx,%rax
sar    $0x3,%rax
mov    %rax,-0x98(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <ti_bbands_start@plt>
mov    -0x9c(%rbp),%ecx
mov    %eax,%edx
mov    -0x98(%rbp),%rax
sub    %edx,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    0x10(%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_bbands_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    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ti_bbands>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
movsd  (%rdx),%xmm0
cvttsd2si %xmm0,%ebp
test   %ebp,%ebp
jle    11bc <ti_bbands+0x8c>
mov    %rdx,%r13
mov    %edi,%ebx
movapd %xmm0,0x20(%rsp)
mov    (%rsi),%r14
mov    (%rcx),%r12
mov    0x8(%rcx),%r15
mov    %rcx,0x68(%rsp)
mov    0x10(%rcx),%rax
mov    %rax,0x8(%rsp)
movsd  0x8(%rdx),%xmm0
movapd %xmm0,0x50(%rsp)
mov    %rdx,%rdi
call   1040 <ti_bbands_start@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ebx,%ecx
jge    14ba <ti_bbands+0x38a>
cvttpd2dq 0x20(%rsp),%xmm0
cvtdq2pd %xmm0,%xmm0
movsd  0xe61(%rip),%xmm8
mov    %ebp,%edx
lea    -0x1(%rdx),%rcx
mov    %edx,%eax
and    $0x3,%eax
cmp    $0x3,%rcx
jae    11c6 <ti_bbands+0x96>
xorpd  %xmm5,%xmm5
xor    %ecx,%ecx
xorpd  %xmm4,%xmm4
jmp    1234 <ti_bbands+0x104>
mov    $0x1,%eax
jmp    14ba <ti_bbands+0x38a>
and    $0xfffffffc,%edx
xorpd  %xmm5,%xmm5
xor    %ecx,%ecx
xorpd  %xmm4,%xmm4
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%r14,%rcx,8),%xmm1
movsd  0x8(%r14,%rcx,8),%xmm2
addsd  %xmm1,%xmm4
mulsd  %xmm1,%xmm1
addsd  %xmm5,%xmm1
addsd  %xmm2,%xmm4
mulsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
movsd  0x10(%r14,%rcx,8),%xmm1
addsd  %xmm1,%xmm4
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  0x18(%r14,%rcx,8),%xmm5
addsd  %xmm5,%xmm4
mulsd  %xmm5,%xmm5
addsd  %xmm1,%xmm5
add    $0x4,%rcx
cmp    %rcx,%rdx
jne    11e0 <ti_bbands+0xb0>
divsd  %xmm0,%xmm8
test   %rax,%rax
je     126a <ti_bbands+0x13a>
lea    (%r14,%rcx,8),%rcx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rcx,%rdx,8),%xmm0
addsd  %xmm0,%xmm4
mulsd  %xmm0,%xmm0
addsd  %xmm0,%xmm5
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1250 <ti_bbands+0x120>
movapd %xmm8,%xmm6
mulsd  %xmm4,%xmm6
movapd %xmm6,%xmm1
mulsd  %xmm6,%xmm1
movapd %xmm5,%xmm0
mulsd  %xmm8,%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
movsd  %xmm8,0x38(%rsp)
jb     129f <ti_bbands+0x16f>
sqrtsd %xmm0,%xmm0
jmp    12cf <ti_bbands+0x19f>
movsd  %xmm4,0x20(%rsp)
movsd  %xmm5,0x10(%rsp)
movsd  %xmm6,0x40(%rsp)
call   1050 <sqrt@plt>
movsd  0x40(%rsp),%xmm6
movsd  0x10(%rsp),%xmm5
movsd  0x20(%rsp),%xmm4
movsd  0x38(%rsp),%xmm8
mov    0x8(%rsp),%rcx
movapd 0x50(%rsp),%xmm2
movsd  %xmm6,(%r15)
mulsd  %xmm2,%xmm0
subsd  %xmm0,%xmm6
movsd  %xmm6,(%r12)
addsd  (%r15),%xmm0
movsd  %xmm0,(%rcx)
add    $0x8,%r15
add    $0x8,%r12
add    $0x8,%rcx
cmp    %ebx,%ebp
jge    1444 <ti_bbands+0x314>
mov    %r13,0x60(%rsp)
movapd 0xcf9(%rip),%xmm6
xorpd  %xmm2,%xmm6
movslq %ebp,%rax
mov    %ebx,0x1c(%rsp)
movslq %ebx,%rbx
lea    (%r14,%rax,8),%rdx
sub    %rax,%rbx
xor    %ebp,%ebp
xorpd  %xmm7,%xmm7
movapd %xmm6,0x40(%rsp)
mov    %r15,0x70(%rsp)
jmp    13de <ti_bbands+0x2ae>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%r15
mov    %rcx,%r12
movsd  %xmm4,0x20(%rsp)
movsd  %xmm5,0x10(%rsp)
mov    %r14,%r13
mov    %rdx,%r14
movsd  %xmm3,0x8(%rsp)
call   1050 <sqrt@plt>
movsd  0x8(%rsp),%xmm3
xorpd  %xmm7,%xmm7
mov    %r14,%rdx
mov    %r13,%r14
movapd 0x40(%rsp),%xmm6
movsd  0x10(%rsp),%xmm5
movsd  0x20(%rsp),%xmm4
movsd  0x38(%rsp),%xmm8
movapd 0x50(%rsp),%xmm2
mov    %r12,%rcx
mov    %r15,%r12
mov    0x70(%rsp),%r15
movsd  %xmm3,(%r15,%rbp,1)
movapd %xmm2,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm3,%xmm1
movsd  %xmm1,(%rcx,%rbp,1)
mulsd  %xmm6,%xmm0
addsd  (%r15,%rbp,1),%xmm0
movsd  %xmm0,(%r12,%rbp,1)
add    $0x8,%rbp
add    $0xffffffffffffffff,%rbx
je     1432 <ti_bbands+0x302>
movsd  (%rdx,%rbp,1),%xmm0
addsd  %xmm0,%xmm4
mulsd  %xmm0,%xmm0
addsd  %xmm0,%xmm5
movsd  (%r14,%rbp,1),%xmm0
subsd  %xmm0,%xmm4
mulsd  %xmm0,%xmm0
subsd  %xmm0,%xmm5
movapd %xmm8,%xmm3
mulsd  %xmm4,%xmm3
movapd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
movapd %xmm5,%xmm0
mulsd  %xmm8,%xmm0
subsd  %xmm1,%xmm0
ucomisd %xmm7,%xmm0
jb     1350 <ti_bbands+0x220>
sqrtsd %xmm0,%xmm0
jmp    13ad <ti_bbands+0x27d>
add    %rbp,%rcx
add    %rbp,%r12
add    %rbp,%r15
mov    0x1c(%rsp),%ebx
mov    0x60(%rsp),%r13
mov    %rcx,%rbp
mov    0x68(%rsp),%r14
sub    (%r14),%r12
sar    $0x3,%r12
mov    %r13,%rdi
call   1040 <ti_bbands_start@plt>
mov    %ebx,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
xor    %edi,%edi
cmp    %rax,%r12
sete   %dil
call   1030 <assert@plt>
sub    0x8(%r14),%r15
sar    $0x3,%r15
mov    %r13,%rdi
call   1040 <ti_bbands_start@plt>
mov    %ebx,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
xor    %edi,%edi
cmp    %rax,%r15
sete   %dil
call   1030 <assert@plt>
sub    0x10(%r14),%rbp
sar    $0x3,%rbp
mov    %r13,%rdi
call   1040 <ti_bbands_start@plt>
sub    %eax,%ebx
movslq %ebx,%rax
xor    %edi,%edi
cmp    %rax,%rbp
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ti_bbands(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 double*
%13 = alloca double*
%14 = alloca i32
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca i32
%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*** %9
%25 = getelementptr inbounds double*, double** %24, i64 0
%26 = load double*, double** %25
store double* %26, double** %11
%27 = load double**, double*** %9
%28 = getelementptr inbounds double*, double** %27, i64 1
%29 = load double*, double** %28
store double* %29, double** %12
%30 = load double**, double*** %9
%31 = getelementptr inbounds double*, double** %30, i64 2
%32 = load double*, double** %31
store double* %32, double** %13
%33 = load double*, double** %8
%34 = getelementptr inbounds double, double* %33, i64 0
%35 = load double, double* %34
%36 = fptosi double %35 to i32
store i32 %36, i32* %14
%37 = load double*, double** %8
%38 = getelementptr inbounds double, double* %37, i64 1
%39 = load double, double* %38
store double %39, double* %15
%40 = load i32, i32* %14
%41 = sitofp i32 %40 to double
%42 = fdiv double 1.000000e+00, %41
store double %42, double* %16
%43 = load i32, i32* %14
%44 = icmp slt i32 %43, 1
br i1 %44, label %45, label %46
45: ; preds = %4
store i32 1, i32* %5
br label %250
46: ; preds = %4
%47 = load i32, i32* %6
%48 = load double*, double** %8
%49 = call i32 @ti_bbands_start(double* %48)
%50 = icmp sle i32 %47, %49
br i1 %50, label %51, label %52
51: ; preds = %46
store i32 0, i32* %5
br label %250
52: ; preds = %46
store double 0.000000e+00, double* %17
store double 0.000000e+00, double* %18
store i32 0, i32* %19
br label %53
53: ; preds = %77, %52
%54 = load i32, i32* %19
%55 = load i32, i32* %14
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %80
57: ; preds = %53
%58 = load double*, double** %10
%59 = load i32, i32* %19
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double, double* %61
%63 = load double, double* %17
%64 = fadd double %63, %62
store double %64, double* %17
%65 = load double*, double** %10
%66 = load i32, i32* %19
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %65, i64 %67
%69 = load double, double* %68
%70 = load double*, double** %10
%71 = load i32, i32* %19
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double, double* %70, i64 %72
%74 = load double, double* %73
%75 = load double, double* %18
%76 = call double @llvm.fmuladd.f64(double %69, double %74, double %75)
store double %76, double* %18
br label %77
77: ; preds = %57
%78 = load i32, i32* %19
%79 = add nsw i32 %78, 1
store i32 %79, i32* %19
br label %53
80: ; preds = %53
%81 = load double, double* %18
%82 = load double, double* %16
%83 = load double, double* %17
%84 = load double, double* %16
%85 = fmul double %83, %84
%86 = load double, double* %17
%87 = load double, double* %16
%88 = fmul double %86, %87
%89 = fmul double %85, %88
%90 = fneg double %89
%91 = call double @llvm.fmuladd.f64(double %81, double %82, double %90)
%92 = call double @sqrt(double %91)
store double %92, double* %20
%93 = load double, double* %17
%94 = load double, double* %16
%95 = fmul double %93, %94
%96 = load double*, double** %12
store double %95, double* %96
%97 = load double*, double** %12
%98 = load double, double* %97
%99 = load double, double* %15
%100 = load double, double* %20
%101 = fneg double %99
%102 = call double @llvm.fmuladd.f64(double %101, double %100, double %98)
%103 = load double*, double** %11
%104 = getelementptr inbounds double, double* %103, i32 1
store double* %104, double** %11
store double %102, double* %103
%105 = load double*, double** %12
%106 = load double, double* %105
%107 = load double, double* %15
%108 = load double, double* %20
%109 = call double @llvm.fmuladd.f64(double %107, double %108, double %106)
%110 = load double*, double** %13
%111 = getelementptr inbounds double, double* %110, i32 1
store double* %111, double** %13
store double %109, double* %110
%112 = load double*, double** %12
%113 = getelementptr inbounds double, double* %112, i32 1
store double* %113, double** %12
%114 = load i32, i32* %14
store i32 %114, i32* %19
br label %115
115: ; preds = %198, %80
%116 = load i32, i32* %19
%117 = load i32, i32* %6
%118 = icmp slt i32 %116, %117
br i1 %118, label %119, label %201
119: ; preds = %115
%120 = load double*, double** %10
%121 = load i32, i32* %19
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds double, double* %120, i64 %122
%124 = load double, double* %123
%125 = load double, double* %17
%126 = fadd double %125, %124
store double %126, double* %17
%127 = load double*, double** %10
%128 = load i32, i32* %19
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds double, double* %127, i64 %129
%131 = load double, double* %130
%132 = load double*, double** %10
%133 = load i32, i32* %19
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds double, double* %132, i64 %134
%136 = load double, double* %135
%137 = load double, double* %18
%138 = call double @llvm.fmuladd.f64(double %131, double %136, double %137)
store double %138, double* %18
%139 = load double*, double** %10
%140 = load i32, i32* %19
%141 = load i32, i32* %14
%142 = sub nsw i32 %140, %141
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds double, double* %139, i64 %143
%145 = load double, double* %144
%146 = load double, double* %17
%147 = fsub double %146, %145
store double %147, double* %17
%148 = load double*, double** %10
%149 = load i32, i32* %19
%150 = load i32, i32* %14
%151 = sub nsw i32 %149, %150
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds double, double* %148, i64 %152
%154 = load double, double* %153
%155 = load double*, double** %10
%156 = load i32, i32* %19
%157 = load i32, i32* %14
%158 = sub nsw i32 %156, %157
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds double, double* %155, i64 %159
%161 = load double, double* %160
%162 = load double, double* %18
%163 = fneg double %154
%164 = call double @llvm.fmuladd.f64(double %163, double %161, double %162)
store double %164, double* %18
%165 = load double, double* %18
%166 = load double, double* %16
%167 = load double, double* %17
%168 = load double, double* %16
%169 = fmul double %167, %168
%170 = load double, double* %17
%171 = load double, double* %16
%172 = fmul double %170, %171
%173 = fmul double %169, %172
%174 = fneg double %173
%175 = call double @llvm.fmuladd.f64(double %165, double %166, double %174)
%176 = call double @sqrt(double %175)
store double %176, double* %20
%177 = load double, double* %17
%178 = load double, double* %16
%179 = fmul double %177, %178
%180 = load double*, double** %12
store double %179, double* %180
%181 = load double*, double** %12
%182 = load double, double* %181
%183 = load double, double* %15
%184 = load double, double* %20
%185 = call double @llvm.fmuladd.f64(double %183, double %184, double %182)
%186 = load double*, double** %13
%187 = getelementptr inbounds double, double* %186, i32 1
store double* %187, double** %13
store double %185, double* %186
%188 = load double*, double** %12
%189 = load double, double* %188
%190 = load double, double* %15
%191 = load double, double* %20
%192 = fneg double %190
%193 = call double @llvm.fmuladd.f64(double %192, double %191, double %189)
%194 = load double*, double** %11
%195 = getelementptr inbounds double, double* %194, i32 1
store double* %195, double** %11
store double %193, double* %194
%196 = load double*, double** %12
%197 = getelementptr inbounds double, double* %196, i32 1
store double* %197, double** %12
br label %198
198: ; preds = %119
%199 = load i32, i32* %19
%200 = add nsw i32 %199, 1
store i32 %200, i32* %19
br label %115
201: ; preds = %115
%202 = load double*, double** %11
%203 = load double**, double*** %9
%204 = getelementptr inbounds double*, double** %203, i64 0
%205 = load double*, double** %204
%206 = ptrtoint double* %202 to i64
%207 = ptrtoint double* %205 to i64
%208 = sub i64 %206, %207
%209 = sdiv exact i64 %208, 8
%210 = load i32, i32* %6
%211 = load double*, double** %8
%212 = call i32 @ti_bbands_start(double* %211)
%213 = sub nsw i32 %210, %212
%214 = sext i32 %213 to i64
%215 = icmp eq i64 %209, %214
%216 = zext i1 %215 to i32
%217 = call i32 @assert(i32 %216)
%218 = load double*, double** %12
%219 = load double**, double*** %9
%220 = getelementptr inbounds double*, double** %219, i64 1
%221 = load double*, double** %220
%222 = ptrtoint double* %218 to i64
%223 = ptrtoint double* %221 to i64
%224 = sub i64 %222, %223
%225 = sdiv exact i64 %224, 8
%226 = load i32, i32* %6
%227 = load double*, double** %8
%228 = call i32 @ti_bbands_start(double* %227)
%229 = sub nsw i32 %226, %228
%230 = sext i32 %229 to i64
%231 = icmp eq i64 %225, %230
%232 = zext i1 %231 to i32
%233 = call i32 @assert(i32 %232)
%234 = load double*, double** %13
%235 = load double**, double*** %9
%236 = getelementptr inbounds double*, double** %235, i64 2
%237 = load double*, double** %236
%238 = ptrtoint double* %234 to i64
%239 = ptrtoint double* %237 to i64
%240 = sub i64 %238, %239
%241 = sdiv exact i64 %240, 8
%242 = load i32, i32* %6
%243 = load double*, double** %8
%244 = call i32 @ti_bbands_start(double* %243)
%245 = sub nsw i32 %242, %244
%246 = sext i32 %245 to i64
%247 = icmp eq i64 %241, %246
%248 = zext i1 %247 to i32
%249 = call i32 @assert(i32 %248)
store i32 0, i32* %5
br label %250
250: ; preds = %201, %51, %45
%251 = load i32, i32* %5
ret i32 %251
}

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