#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_macd_start(double const *);
int ti_macd(int size, double const *const *inputs, double const *options,
            double *const *outputs) {
  const double *input = inputs[0];
  double *macd = outputs[0];
  double *signal = outputs[1];
  double *hist = outputs[2];
  const int short_period = (int)options[0];
  const int long_period = (int)options[1];
  const int signal_period = (int)options[2];
  if (short_period < 1)
    return 1;
  if (long_period < 2)
    return 1;
  if (long_period < short_period)
    return 1;
  if (signal_period < 1)
    return 1;
  if (size <= ti_macd_start(options))
    return 0;
  double short_per = 2 / ((double)short_period + 1);
  double long_per = 2 / ((double)long_period + 1);
  double signal_per = 2 / ((double)signal_period + 1);
  if (short_period == 12 && long_period == 26) {
    short_per = 0.15;
    long_per = 0.075;
  }
  double short_ema = input[0];
  double long_ema = input[0];
  double signal_ema = 0;
  int i;
  for (i = 1; i < size; ++i) {
    short_ema = (input[i] - short_ema) * short_per + short_ema;
    long_ema = (input[i] - long_ema) * long_per + long_ema;
    const double out = short_ema - long_ema;
    if (i == long_period - 1) {
      signal_ema = out;
    }
    if (i >= long_period - 1) {
      signal_ema = (out - signal_ema) * signal_per + signal_ema;
      *macd++ = out;
      *signal++ = signal_ema;
      *hist++ = out - signal_ema;
    }
  }
  assert(macd - outputs[0] == size - ti_macd_start(options));
  assert(signal - outputs[1] == size - ti_macd_start(options));
  assert(hist - outputs[2] == size - ti_macd_start(options));
  return 0;
}


x86 assembly (clang, -O0):
<ti_macd>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%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
cvttsd2si 0x8(%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
cvttsd2si 0x10(%rax),%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x1,-0x44(%rbp)
jge    11a1 <ti_macd+0x81>
movl   $0x1,-0x4(%rbp)
jmp    1507 <ti_macd+0x3e7>
cmpl   $0x2,-0x48(%rbp)
jge    11b7 <ti_macd+0x97>
movl   $0x1,-0x4(%rbp)
jmp    1507 <ti_macd+0x3e7>
mov    -0x48(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    11cf <ti_macd+0xaf>
movl   $0x1,-0x4(%rbp)
jmp    1507 <ti_macd+0x3e7>
cmpl   $0x1,-0x4c(%rbp)
jge    11e5 <ti_macd+0xc5>
movl   $0x1,-0x4(%rbp)
jmp    1507 <ti_macd+0x3e7>
mov    -0x8(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <ti_macd_start@plt>
mov    %eax,%ecx
mov    -0x94(%rbp),%eax
cmp    %ecx,%eax
jg     1213 <ti_macd+0xf3>
movl   $0x0,-0x4(%rbp)
jmp    1507 <ti_macd+0x3e7>
cvtsi2sdl -0x44(%rbp),%xmm1
movsd  0xde8(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xdd4(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
cvtsi2sdl -0x48(%rbp),%xmm1
movsd  0xdc6(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xdb2(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
cvtsi2sdl -0x4c(%rbp),%xmm1
movsd  0xda4(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xd90(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
cmpl   $0xc,-0x44(%rbp)
jne    12a7 <ti_macd+0x187>
cmpl   $0x1a,-0x48(%rbp)
jne    12a7 <ti_macd+0x187>
movsd  0xd83(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xd6e(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x78(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
movl   $0x1,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1411 <ti_macd+0x2f1>
mov    -0x28(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x70(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x78(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
subsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x84(%rbp),%eax
mov    -0x48(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    136d <ti_macd+0x24d>
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x80(%rbp)
mov    -0x84(%rbp),%eax
mov    -0x48(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     13f8 <ti_macd+0x2d8>
movsd  -0x90(%rbp),%xmm0
ff
subsd  -0x80(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
movsd  -0x80(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x90(%rbp),%xmm0
ff
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x30(%rbp)
movsd  %xmm0,(%rax)
movsd  -0x80(%rbp),%xmm0
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x38(%rbp)
movsd  %xmm0,(%rax)
movsd  -0x90(%rbp),%xmm0
ff
subsd  -0x80(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x40(%rbp)
movsd  %xmm0,(%rax)
jmp    13fd <ti_macd+0x2dd>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    12d3 <ti_macd+0x1b3>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
sar    $0x3,%rax
mov    %rax,-0xc0(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc4(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <ti_macd_start@plt>
mov    -0xc4(%rbp),%ecx
mov    %eax,%edx
mov    -0xc0(%rbp),%rax
sub    %edx,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x38(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    0x8(%rcx),%rcx
sub    %rcx,%rax
sar    $0x3,%rax
mov    %rax,-0xb0(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xb4(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <ti_macd_start@plt>
mov    -0xb4(%rbp),%ecx
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
sub    %edx,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    0x10(%rcx),%rcx
sub    %rcx,%rax
sar    $0x3,%rax
mov    %rax,-0xa0(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <ti_macd_start@plt>
mov    -0xa4(%rbp),%ecx
mov    %eax,%edx
mov    -0xa0(%rbp),%rax
sub    %edx,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ti_macd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movupd (%rdx),%xmm0
cvttpd2dq %xmm0,%xmm1
movdqa 0xec2(%rip),%xmm0
pcmpgtd %xmm1,%xmm0
pshufd $0x50,%xmm0,%xmm0
movmskpd %xmm0,%eax
mov    $0x1,%ebp
test   $0x1,%al
jne    1373 <ti_macd+0x253>
shr    %al
jne    1373 <ti_macd+0x253>
pshufd $0x55,%xmm1,%xmm0
movd   %xmm0,%r15d
movd   %xmm1,%eax
cmp    %eax,%r15d
jl     1373 <ti_macd+0x253>
cvttsd2si 0x10(%rdx),%eax
test   %eax,%eax
jle    1373 <ti_macd+0x253>
mov    %eax,0xc(%rsp)
movaps %xmm1,0x20(%rsp)
mov    (%rsi),%rax
mov    %rax,0x18(%rsp)
mov    (%rcx),%r14
mov    0x8(%rcx),%rbx
mov    %rcx,%r12
mov    0x10(%rcx),%r13
mov    %edi,0x8(%rsp)
mov    %rdx,%rdi
mov    %rdx,0x10(%rsp)
call   1030 <ti_macd_start@plt>
mov    0x8(%rsp),%edx
xor    %ebp,%ebp
cmp    %edx,%eax
jge    1373 <ti_macd+0x253>
mov    0x18(%rsp),%rbp
mov    0x10(%rsp),%rdi
movdqa 0xe5c(%rip),%xmm0
movdqa 0x20(%rsp),%xmm1
pcmpeqd %xmm1,%xmm0
pshufd $0x50,%xmm0,%xmm0
movmskpd %xmm0,%ecx
xor    %eax,%eax
cmp    $0x3,%cl
sete   %cl
cmp    $0x2,%edx
jl     12f9 <ti_macd+0x1d9>
cvtdq2pd %xmm1,%xmm0
addpd  0xe0c(%rip),%xmm0
movapd 0xe14(%rip),%xmm2
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
divpd  %xmm0,%xmm2
addsd  0xe2f(%rip),%xmm1
movsd  0xe2f(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    %cl,%al
movd   %eax,%xmm1
pshufd $0x44,%xmm1,%xmm1
psllq  $0x3f,%xmm1
psrad  $0x1f,%xmm1
pshufd $0xf5,%xmm1,%xmm1
movdqa %xmm1,%xmm3
pand   0xded(%rip),%xmm1
pandn  %xmm2,%xmm3
por    %xmm3,%xmm1
add    $0xffffffff,%r15d
mov    %edx,%eax
mov    %rbp,%rdx
movsd  0x0(%rbp),%xmm2
unpcklpd %xmm2,%xmm2
xorpd  %xmm4,%xmm4
mov    $0x1,%ecx
jmp    128d <ti_macd+0x16d>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rcx
movapd %xmm3,%xmm4
cmp    %rcx,%rax
je     12f9 <ti_macd+0x1d9>
movapd %xmm2,%xmm3
movsd  (%rdx,%rcx,8),%xmm2
unpcklpd %xmm2,%xmm2
subpd  %xmm3,%xmm2
mulpd  %xmm1,%xmm2
addpd  %xmm3,%xmm2
movapd %xmm2,%xmm3
unpckhpd %xmm2,%xmm3
movapd %xmm2,%xmm5
subsd  %xmm3,%xmm5
movapd %xmm5,%xmm3
cmp    %rcx,%r15
je     12c3 <ti_macd+0x1a3>
movapd %xmm4,%xmm3
cmp    %r15,%rcx
jb     1280 <ti_macd+0x160>
movapd %xmm5,%xmm4
subsd  %xmm3,%xmm4
mulsd  %xmm0,%xmm4
addsd  %xmm4,%xmm3
movsd  %xmm5,(%r14)
add    $0x8,%r14
movsd  %xmm3,(%rbx)
add    $0x8,%rbx
subsd  %xmm3,%xmm5
movsd  %xmm5,0x0(%r13)
add    $0x8,%r13
jmp    1280 <ti_macd+0x160>
mov    %r12,%rbp
sub    (%r12),%r14
sar    $0x3,%r14
mov    %rdi,%r12
call   1030 <ti_macd_start@plt>
mov    0x8(%rsp),%r15d
mov    %r15d,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
xor    %edi,%edi
cmp    %rax,%r14
sete   %dil
call   1040 <assert@plt>
sub    0x8(%rbp),%rbx
sar    $0x3,%rbx
mov    %r12,%rdi
call   1030 <ti_macd_start@plt>
mov    %r15d,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
call   1040 <assert@plt>
sub    0x10(%rbp),%r13
sar    $0x3,%r13
mov    %r12,%rdi
call   1030 <ti_macd_start@plt>
sub    %eax,%r15d
movslq %r15d,%rax
xor    %edi,%edi
cmp    %rax,%r13
sete   %dil
call   1040 <assert@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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