#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_rsi_start(double const *);
int ti_rsi(int size, double const *const *inputs, double const *options,
           double *const *outputs) {
  const double *input = inputs[0];
  const int period = (int)options[0];
  double *output = outputs[0];
  const double per = 1.0 / ((double)period);
  if (period < 1)
    return 1;
  if (size <= ti_rsi_start(options))
    return 0;
  double smooth_up = 0, smooth_down = 0;
  int i;
  for (i = 1; i <= period; ++i) {
    const double upward = input[i] > input[i - 1] ? input[i] - input[i - 1] : 0;
    const double downward =
        input[i] < input[i - 1] ? input[i - 1] - input[i] : 0;
    smooth_up += upward;
    smooth_down += downward;
  }
  smooth_up /= period;
  smooth_down /= period;
  *output++ = 100.0 * (smooth_up / (smooth_up + smooth_down));
  for (i = period + 1; i < size; ++i) {
    const double upward = input[i] > input[i - 1] ? input[i] - input[i - 1] : 0;
    const double downward =
        input[i] < input[i - 1] ? input[i - 1] - input[i] : 0;
    smooth_up = (upward - smooth_up) * per + smooth_up;
    smooth_down = (downward - smooth_down) * per + smooth_down;
    *output++ = 100.0 * (smooth_up / (smooth_up + smooth_down));
  }
  assert(output - outputs[0] == size - ti_rsi_start(options));
  return 0;
}


x86 assembly (clang, -O0):
<ti_rsi>:
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    -0x18(%rbp),%rax
cvttsd2si (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm1
movsd  0xe98(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cmpl   $0x1,-0x2c(%rbp)
jge    1187 <ti_rsi+0x67>
movl   $0x1,-0x4(%rbp)
jmp    1503 <ti_rsi+0x3e3>
mov    -0x8(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <ti_rsi_start@plt>
mov    %eax,%ecx
mov    -0x7c(%rbp),%eax
cmp    %ecx,%eax
jg     11af <ti_rsi+0x8f>
movl   $0x0,-0x4(%rbp)
jmp    1503 <ti_rsi+0x3e3>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     12de <ti_rsi+0x1be>
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    1223 <ti_rsi+0x103>
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    1233 <ti_rsi+0x113>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    1233 <ti_rsi+0x113>
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x60(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x28(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    1295 <ti_rsi+0x175>
mov    -0x28(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    12a5 <ti_rsi+0x185>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    12a5 <ti_rsi+0x185>
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x68(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11c6 <ti_rsi+0xa6>
cvtsi2sdl -0x2c(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xce9(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x38(%rbp)
movsd  %xmm0,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14ad <ti_rsi+0x38d>
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    139c <ti_rsi+0x27c>
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
jmp    13ac <ti_rsi+0x28c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
jmp    13ac <ti_rsi+0x28c>
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x70(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x28(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    140e <ti_rsi+0x2ee>
mov    -0x28(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
jmp    141e <ti_rsi+0x2fe>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
jmp    141e <ti_rsi+0x2fe>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x78(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xb80(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x38(%rbp)
movsd  %xmm0,(%rax)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    133f <ti_rsi+0x21f>
mov    -0x38(%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_rsi_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>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ti_rsi>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  (%rdx),%xmm0
cvttsd2si %xmm0,%ebp
test   %ebp,%ebp
jle    1187 <ti_rsi+0x67>
mov    %rcx,%r15
mov    %rdx,%r13
mov    %edi,%r12d
movapd %xmm0,(%rsp)
mov    (%rsi),%r14
mov    (%rcx),%rbx
mov    %rdx,%rdi
call   1040 <ti_rsi_start@plt>
xor    %ecx,%ecx
cmp    %r12d,%eax
jge    1326 <ti_rsi+0x206>
cvttpd2dq (%rsp),%xmm0
cvtdq2pd %xmm0,%xmm1
lea    0x1(%rbp),%eax
movsd  (%r14),%xmm2
mov    %ebp,%ecx
cmp    $0x2,%eax
jne    1191 <ti_rsi+0x71>
xorpd  %xmm0,%xmm0
mov    $0x1,%edx
jmp    1213 <ti_rsi+0xf3>
mov    $0x1,%ecx
jmp    1326 <ti_rsi+0x206>
mov    %ecx,%esi
and    $0xfffffffe,%esi
neg    %rsi
xorpd  %xmm0,%xmm0
mov    $0x1,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%r14,%rdx,8),%xmm3
movapd %xmm3,%xmm4
unpcklpd %xmm2,%xmm4
unpcklpd %xmm3,%xmm2
movapd %xmm2,%xmm5
cmpltpd %xmm4,%xmm5
subpd  %xmm2,%xmm4
andpd  %xmm5,%xmm4
addpd  %xmm0,%xmm4
movsd  0x8(%r14,%rdx,8),%xmm2
movapd %xmm2,%xmm0
unpcklpd %xmm3,%xmm0
movupd (%r14,%rdx,8),%xmm3
movapd %xmm3,%xmm5
cmpltpd %xmm0,%xmm5
subpd  %xmm3,%xmm0
andpd  %xmm5,%xmm0
addpd  %xmm4,%xmm0
lea    (%rsi,%rdx,1),%rdi
add    $0x2,%rdi
add    $0x2,%rdx
cmp    $0x1,%rdi
jne    11b0 <ti_rsi+0x90>
test   $0x1,%cl
je     123f <ti_rsi+0x11f>
movsd  (%r14,%rdx,8),%xmm3
movapd %xmm3,%xmm4
unpcklpd %xmm2,%xmm4
unpcklpd %xmm3,%xmm2
movapd %xmm2,%xmm3
cmpltpd %xmm4,%xmm3
subpd  %xmm2,%xmm4
andpd  %xmm3,%xmm4
addpd  %xmm4,%xmm0
movapd %xmm1,%xmm2
unpcklpd %xmm1,%xmm2
divpd  %xmm2,%xmm0
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
addsd  %xmm0,%xmm2
movapd %xmm0,%xmm3
divsd  %xmm2,%xmm3
mulsd  0xda1(%rip),%xmm3
movsd  %xmm3,(%rbx)
add    $0x8,%rbx
cmp    %r12d,%eax
jge    1301 <ti_rsi+0x1e1>
movsd  0xd80(%rip),%xmm2
divsd  %xmm1,%xmm2
cltq
unpcklpd %xmm2,%xmm2
lea    (%r14,%rax,8),%rax
lea    -0x1(%r12),%ecx
movsd  0xd6d(%rip),%xmm1
nopl   0x0(%rax,%rax,1)
movslq %ebp,%rbp
movsd  (%r14,%rbp,8),%xmm3
movsd  (%rax),%xmm4
movapd %xmm4,%xmm5
unpcklpd %xmm3,%xmm5
unpcklpd %xmm4,%xmm3
movapd %xmm3,%xmm4
cmpltpd %xmm5,%xmm4
subpd  %xmm3,%xmm5
andpd  %xmm4,%xmm5
subpd  %xmm0,%xmm5
mulpd  %xmm2,%xmm5
addpd  %xmm5,%xmm0
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
addsd  %xmm0,%xmm3
movapd %xmm0,%xmm4
divsd  %xmm3,%xmm4
mulsd  %xmm1,%xmm4
movsd  %xmm4,(%rbx)
add    $0x8,%rbx
add    $0x1,%ebp
add    $0x8,%rax
cmp    %ebp,%ecx
jne    12a0 <ti_rsi+0x180>
sub    (%r15),%rbx
sar    $0x3,%rbx
mov    %r13,%rdi
call   1040 <ti_rsi_start@plt>
sub    %eax,%r12d
movslq %r12d,%rax
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
call   1030 <assert@plt>
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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