#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 const fabs(double const);
int ti_kvo_start(double const *);
int ti_kvo(int size, double const *const *inputs, double const *options,
           double *const *outputs) {
  const double *high = inputs[0];
  const double *low = inputs[1];
  const double *close = inputs[2];
  const double *volume = inputs[3];
  const int short_period = (int)options[0];
  const int long_period = (int)options[1];
  if (short_period < 1)
    return 1;
  if (long_period < short_period)
    return 1;
  if (size <= ti_kvo_start(options))
    return 0;
  const double short_per = 2 / ((double)short_period + 1);
  const double long_per = 2 / ((double)long_period + 1);
  double *output = outputs[0];
  double cm = 0;
  double prev_hlc = high[0] + low[0] + close[0];
  int trend = -1;
  double short_ema = 0, long_ema = 0;
  int i;
  for (i = 1; i < size; ++i) {
    const double hlc = high[i] + low[i] + close[i];
    const double dm = high[i] - low[i];
    if (hlc > prev_hlc && trend != 1) {
      trend = 1;
      cm = high[i - 1] - low[i - 1];
    } else if (hlc < prev_hlc && trend != 0) {
      trend = 0;
      cm = high[i - 1] - low[i - 1];
    }
    cm += dm;
    const double vf =
        volume[i] * fabs(dm / cm * 2 - 1) * 100 * (trend ? 1.0 : -1.0);
    if (i == 1) {
      short_ema = vf;
      long_ema = vf;
    } else {
      short_ema = (vf - short_ema) * short_per + short_ema;
      long_ema = (vf - long_ema) * long_per + long_ema;
    }
    *output++ = short_ema - long_ema;
    prev_hlc = hlc;
  }
  assert(output - outputs[0] == size - ti_kvo_start(options));
  return 0;
}


x86 assembly (clang, -O0):
<ti_kvo>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%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)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
cvttsd2si (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rax
cvttsd2si 0x8(%rax),%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x1,-0x44(%rbp)
jge    11a6 <ti_kvo+0x76>
movl   $0x1,-0x4(%rbp)
jmp    1585 <ti_kvo+0x455>
mov    -0x48(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    11be <ti_kvo+0x8e>
movl   $0x1,-0x4(%rbp)
jmp    1585 <ti_kvo+0x455>
mov    -0x8(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <ti_kvo_start@plt>
mov    %eax,%ecx
mov    -0xac(%rbp),%eax
cmp    %ecx,%eax
jg     11ec <ti_kvo+0xbc>
movl   $0x0,-0x4(%rbp)
jmp    1585 <ti_kvo+0x455>
cvtsi2sdl -0x44(%rbp),%xmm1
movsd  0xe0f(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xdfb(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdl -0x48(%rbp),%xmm1
movsd  0xded(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xdd9(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
addsd  (%rax),%xmm0
mov    -0x38(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
movl   $0xffffffff,-0x74(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movl   $0x1,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    152f <ti_kvo+0x3ff>
mov    -0x28(%rbp),%rax
movslq -0x8c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x8c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x8c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
mov    -0x28(%rbp),%rax
movslq -0x8c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x8c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
ucomisd -0x70(%rbp),%xmm0
jbe    134b <ti_kvo+0x21b>
cmpl   $0x1,-0x74(%rbp)
je     134b <ti_kvo+0x21b>
movl   $0x1,-0x74(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x8c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x8c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    13a7 <ti_kvo+0x277>
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0x70(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    13a2 <ti_kvo+0x272>
cmpl   $0x0,-0x74(%rbp)
je     13a2 <ti_kvo+0x272>
movl   $0x0,-0x74(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x8c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x8c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    13a7 <ti_kvo+0x277>
movsd  -0xa0(%rbp),%xmm0
ff
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x8c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
divsd  -0x68(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xc26(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <fabs@plt>
movaps %xmm0,%xmm1
movsd  -0xd0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  0xc0e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
mov    -0x74(%rbp),%eax
movsd  0xbe7(%rip),%xmm0
movsd  0xbe7(%rip),%xmm1
movsd  %xmm1,-0xc0(%rbp)
ff
cmp    $0x0,%eax
movsd  %xmm0,-0xb8(%rbp)
ff
jne    1452 <ti_kvo+0x322>
movsd  -0xc0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0xc8(%rbp),%xmm0
ff
movsd  -0xb8(%rbp),%xmm1
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
cmpl   $0x1,-0x8c(%rbp)
jne    149d <ti_kvo+0x36d>
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0x80(%rbp)
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0x88(%rbp)
ff
jmp    14ee <ti_kvo+0x3be>
movsd  -0xa8(%rbp),%xmm0
ff
subsd  -0x80(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x80(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0xa8(%rbp),%xmm0
ff
subsd  -0x88(%rbp),%xmm0
ff
movsd  -0x58(%rbp),%xmm2
movsd  -0x88(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
subsd  -0x88(%rbp),%xmm0
ff
mov    -0x60(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x60(%rbp)
movsd  %xmm0,(%rax)
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x70(%rbp)
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    1284 <ti_kvo+0x154>
mov    -0x60(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
sar    $0x3,%rax
mov    %rax,-0xd8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xdc(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <ti_kvo_start@plt>
mov    -0xdc(%rbp),%ecx
mov    %eax,%edx
mov    -0xd8(%rbp),%rax
sub    %edx,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ti_kvo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movupd (%rdx),%xmm0
cvttpd2dq %xmm0,%xmm2
mov    %rcx,%rbp
movd   %xmm2,%eax
mov    $0x1,%ecx
test   %eax,%eax
jle    139a <ti_kvo+0x27a>
pshufd $0x55,%xmm2,%xmm0
movdqa %xmm2,%xmm1
pcmpgtd %xmm0,%xmm1
movd   %xmm1,%eax
test   $0x1,%al
jne    139a <ti_kvo+0x27a>
mov    %edi,%r12d
movaps %xmm2,0x10(%rsp)
mov    (%rsi),%rax
mov    %rax,0x8(%rsp)
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%r13
mov    0x18(%rsi),%r14
mov    %rdx,%rdi
mov    %rdx,%r15
call   1030 <ti_kvo_start@plt>
xor    %ecx,%ecx
cmp    %r12d,%eax
jge    139a <ti_kvo+0x27a>
mov    %rbx,%rax
mov    0x8(%rsp),%rbx
mov    0x0(%rbp),%r9
mov    %r9,%rbp
cmp    $0x2,%r12d
jl     1375 <ti_kvo+0x255>
mov    %r14,%r10
mov    %rbx,%r14
movsd  (%rbx),%xmm0
mov    %rax,%rbx
movsd  (%rax),%xmm2
movapd %xmm0,%xmm3
addsd  %xmm2,%xmm3
addsd  0x0(%r13),%xmm3
movsd  0x8(%r14),%xmm1
movsd  0x8(%rax),%xmm5
movapd %xmm1,%xmm4
addsd  %xmm5,%xmm4
addsd  0x8(%r13),%xmm4
subsd  %xmm5,%xmm1
ucomisd %xmm3,%xmm4
jbe    11fb <ti_kvo+0xdb>
subsd  %xmm2,%xmm0
mov    $0x1,%eax
jmp    1214 <ti_kvo+0xf4>
xor    %eax,%eax
ucomisd %xmm4,%xmm3
jbe    120b <ti_kvo+0xeb>
subsd  %xmm2,%xmm0
mov    $0x1,%dl
jmp    1216 <ti_kvo+0xf6>
mov    $0xffffffff,%eax
xorpd  %xmm0,%xmm0
xor    %edx,%edx
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm1
addsd  %xmm1,%xmm1
addsd  0xe16(%rip),%xmm1
andpd  0xdee(%rip),%xmm1
mulsd  0x8(%r10),%xmm1
mulsd  0xe08(%rip),%xmm1
test   %dl,%dl
je     124c <ti_kvo+0x12c>
xorpd  0xde4(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm1,%xmm2
lea    0x8(%r9),%rbp
movsd  %xmm2,(%r9)
cmp    $0x2,%r12d
je     1375 <ti_kvo+0x255>
cvtdq2pd 0x10(%rsp),%xmm2
addpd  0xd8b(%rip),%xmm2
movapd 0xd93(%rip),%xmm3
divpd  %xmm2,%xmm3
mov    %r12d,%edx
unpcklpd %xmm1,%xmm1
add    $0xfffffffffffffffe,%rdx
xor    %esi,%esi
movsd  0xda9(%rip),%xmm9
movapd 0xd80(%rip),%xmm10
movsd  0xda0(%rip),%xmm6
movapd 0xd7f(%rip),%xmm8
jmp    12f4 <ti_kvo+0x1d4>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
unpcklpd %xmm2,%xmm2
subpd  %xmm1,%xmm2
mulpd  %xmm3,%xmm2
addpd  %xmm2,%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
movapd %xmm1,%xmm4
subsd  %xmm2,%xmm4
movsd  %xmm4,0x0(%rbp,%rsi,1)
add    $0x8,%rsi
movapd %xmm7,%xmm4
add    $0xffffffffffffffff,%rdx
je     1372 <ti_kvo+0x252>
movsd  0x10(%r14,%rsi,1),%xmm2
movsd  0x10(%rbx,%rsi,1),%xmm5
movapd %xmm2,%xmm7
addsd  %xmm5,%xmm7
addsd  0x10(%r13,%rsi,1),%xmm7
ucomisd %xmm4,%xmm7
jbe    1320 <ti_kvo+0x200>
mov    $0x1,%ecx
cmp    $0x1,%eax
jne    132c <ti_kvo+0x20c>
ucomisd %xmm7,%xmm4
jbe    133b <ti_kvo+0x21b>
xor    %ecx,%ecx
test   %eax,%eax
je     133b <ti_kvo+0x21b>
movsd  0x8(%r14,%rsi,1),%xmm0
subsd  0x8(%rbx,%rsi,1),%xmm0
mov    %ecx,%eax
subsd  %xmm5,%xmm2
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm2
addsd  %xmm2,%xmm2
addsd  %xmm9,%xmm2
andpd  %xmm10,%xmm2
mulsd  0x10(%r10,%rsi,1),%xmm2
mulsd  %xmm6,%xmm2
test   %eax,%eax
jne    12c0 <ti_kvo+0x1a0>
xorpd  %xmm8,%xmm2
jmp    12c0 <ti_kvo+0x1a0>
add    %rsi,%rbp
sub    %r9,%rbp
sar    $0x3,%rbp
mov    %r15,%rdi
call   1030 <ti_kvo_start@plt>
sub    %eax,%r12d
movslq %r12d,%rax
xor    %edi,%edi
cmp    %rax,%rbp
sete   %dil
call   1040 <assert@plt>
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @ti_kvo(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 = getelementptr inbounds double*, double** %1, i64 2
%9 = load double*, double** %8
%10 = getelementptr inbounds double*, double** %1, i64 3
%11 = load double*, double** %10
%12 = bitcast double* %2 to <2 x double>*
%13 = load <2 x double>, <2 x double>* %12
%14 = fptosi <2 x double> %13 to <2 x i32>
%15 = extractelement <2 x i32> %14, i64 0
%16 = icmp slt i32 %15, 1
%17 = shufflevector <2 x i32> %14, <2 x i32> poison, <2 x i32> <i32 1, i32 undef>
%18 = icmp slt <2 x i32> %17, %14
%19 = extractelement <2 x i1> %18, i64 0
%20 = select i1 %16, i1 true, i1 %19
br i1 %20, label %140, label %21
21: ; preds = %4
%22 = tail call i32 @ti_kvo_start(double* %2)
%23 = icmp slt i32 %22, %0
br i1 %23, label %24, label %140
24: ; preds = %21
%25 = sitofp <2 x i32> %14 to <2 x double>
%26 = fadd <2 x double> %25, <double 1.000000e+00, double 1.000000e+00>
%27 = fdiv <2 x double> <double 2.000000e+00, double 2.000000e+00>, %26
%28 = load double*, double** %3
%29 = load double, double* %5
%30 = load double, double* %7
%31 = fadd double %29, %30
%32 = load double, double* %9
%33 = fadd double %31, %32
%34 = icmp sgt i32 %0, 1
br i1 %34, label %35, label %128
35: ; preds = %24
%36 = zext i32 %0 to i64
%37 = getelementptr inbounds double, double* %5, i64 1
%38 = load double, double* %37
%39 = getelementptr inbounds double, double* %7, i64 1
%40 = load double, double* %39
%41 = fadd double %38, %40
%42 = getelementptr inbounds double, double* %9, i64 1
%43 = load double, double* %42
%44 = fadd double %41, %43
%45 = fsub double %38, %40
%46 = fcmp ogt double %44, %33
br i1 %46, label %51, label %47
47: ; preds = %35
%48 = fcmp olt double %44, %33
br i1 %48, label %49, label %53
49: ; preds = %47
%50 = fsub double %29, %30
br label %53
51: ; preds = %35
%52 = fsub double %29, %30
br label %53
53: ; preds = %51, %49, %47
%54 = phi double [ %52, %51 ], [ %50, %49 ], [ 0.000000e+00, %47 ]
%55 = phi i1 [ false, %51 ], [ true, %49 ], [ false, %47 ]
%56 = phi i32 [ 1, %51 ], [ 0, %49 ], [ -1, %47 ]
%57 = fadd double %45, %54
%58 = getelementptr inbounds double, double* %11, i64 1
%59 = load double, double* %58
%60 = fdiv double %45, %57
%61 = tail call double @llvm.fmuladd.f64(double %60, double 2.000000e+00, double -1.000000e+00)
%62 = tail call double @llvm.fabs.f64(double %61)
%63 = fmul double %59, %62
%64 = fmul double %63, 1.000000e+02
%65 = fneg double %64
%66 = select i1 %55, double %65, double %64
%67 = fsub double %66, %66
%68 = getelementptr inbounds double, double* %28, i64 1
store double %67, double* %28
%69 = icmp eq i32 %0, 2
br i1 %69, label %128, label %70
70: ; preds = %53
%71 = insertelement <2 x double> poison, double %66, i64 0
%72 = shufflevector <2 x double> %71, <2 x double> poison, <2 x i32> zeroinitializer
br label %73
73: ; preds = %70, %104
%74 = phi i64 [ %126, %104 ], [ 2, %70 ]
%75 = phi double* [ %125, %104 ], [ %68, %70 ]
%76 = phi i32 [ %106, %104 ], [ %56, %70 ]
%77 = phi double [ %87, %104 ], [ %44, %70 ]
%78 = phi double [ %107, %104 ], [ %57, %70 ]
%79 = phi <2 x double> [ %121, %104 ], [ %72, %70 ]
%80 = getelementptr inbounds double, double* %5, i64 %74
%81 = load double, double* %80
%82 = getelementptr inbounds double, double* %7, i64 %74
%83 = load double, double* %82
%84 = fadd double %81, %83
%85 = getelementptr inbounds double, double* %9, i64 %74
%86 = load double, double* %85
%87 = fadd double %84, %86
%88 = fsub double %81, %83
%89 = fcmp ogt double %87, %77
%90 = icmp ne i32 %76, 1
%91 = select i1 %89, i1 %90, i1 false
br i1 %91, label %96, label %92
92: ; preds = %73
%93 = fcmp olt double %87, %77
%94 = icmp ne i32 %76, 0
%95 = select i1 %93, i1 %94, i1 false
br i1 %95, label %96, label %104
96: ; preds = %92, %73
%97 = phi i32 [ 1, %73 ], [ 0, %92 ]
%98 = add nsw i64 %74, -1
%99 = getelementptr inbounds double, double* %5, i64 %98
%100 = load double, double* %99
%101 = getelementptr inbounds double, double* %7, i64 %98
%102 = load double, double* %101
%103 = fsub double %100, %102
br label %104
104: ; preds = %96, %92
%105 = phi double [ %78, %92 ], [ %103, %96 ]
%106 = phi i32 [ %76, %92 ], [ %97, %96 ]
%107 = fadd double %88, %105
%108 = getelementptr inbounds double, double* %11, i64 %74
%109 = load double, double* %108
%110 = fdiv double %88, %107
%111 = tail call double @llvm.fmuladd.f64(double %110, double 2.000000e+00, double -1.000000e+00)
%112 = tail call double @llvm.fabs.f64(double %111)
%113 = fmul double %109, %112
%114 = fmul double %113, 1.000000e+02
%115 = icmp eq i32 %106, 0
%116 = fneg double %114
%117 = select i1 %115, double %116, double %114
%118 = insertelement <2 x double> poison, double %117, i64 0
%119 = shufflevector <2 x double> %118, <2 x double> poison, <2 x i32> zeroinitializer
%120 = fsub <2 x double> %119, %79
%121 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %120, <2 x double> %27, <2 x double> %79)
%122 = shufflevector <2 x double> %121, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%123 = fsub <2 x double> %121, %122
%124 = extractelement <2 x double> %123, i64 0
%125 = getelementptr inbounds double, double* %75, i64 1
store double %124, double* %75
%126 = add nuw nsw i64 %74, 1
%127 = icmp eq i64 %126, %36
br i1 %127, label %128, label %73
128: ; preds = %104, %53, %24
%129 = phi double* [ %28, %24 ], [ %68, %53 ], [ %125, %104 ]
%130 = ptrtoint double* %129 to i64
%131 = ptrtoint double* %28 to i64
%132 = sub i64 %130, %131
%133 = ashr exact i64 %132, 3
%134 = tail call i32 @ti_kvo_start(double* %2)
%135 = sub nsw i32 %0, %134
%136 = sext i32 %135 to i64
%137 = icmp eq i64 %133, %136
%138 = zext i1 %137 to i32
%139 = tail call i32 @assert(i32 %138)
br label %140
140: ; preds = %21, %4, %128
%141 = phi i32 [ 0, %128 ], [ 1, %4 ], [ 0, %21 ]
ret i32 %141
}