#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 fabs(double);
int rf5(double *array_ext, int nr, double *array_t, double *array_out) {
  double a[512], t[512], ampl, mean, period, atime;
  int index, j, cNr, tot_num;
  tot_num = nr;
  for (index = 0; index < nr * 5; index++) {
    array_out[index] = 0.0;
  }
  j = -1;
  cNr = 1;
  for (index = 0; index < tot_num; index++) {
    a[++j] = *array_ext++;
    t[j] = *array_t++;
    while ((j >= 2) && (fabs(a[j - 1] - a[j - 2]) <= fabs(a[j] - a[j - 1]))) {
      ampl = fabs((a[j - 1] - a[j - 2]) / 2);
      switch (j) {
      case 0: {
        break;
      }
      case 1: {
        break;
      }
      case 2: {
        mean = (a[0] + a[1]) / 2;
        period = (t[1] - t[0]) * 2;
        atime = t[0];
        a[0] = a[1];
        a[1] = a[2];
        t[0] = t[1];
        t[1] = t[2];
        j = 1;
        if (ampl > 0) {
          *array_out++ = ampl;
          *array_out++ = mean;
          *array_out++ = 0.50;
          *array_out++ = atime;
          *array_out++ = period;
        }
        break;
      }
      default: {
        mean = (a[j - 1] + a[j - 2]) / 2;
        period = (t[j - 1] - t[j - 2]) * 2;
        atime = t[j - 2];
        a[j - 2] = a[j];
        t[j - 2] = t[j];
        j = j - 2;
        if (ampl > 0) {
          *array_out++ = ampl;
          *array_out++ = mean;
          *array_out++ = 1.00;
          *array_out++ = atime;
          *array_out++ = period;
          cNr++;
        }
        break;
      }
      }
    }
  }
  for (index = 0; index < j; index++) {
    ampl = fabs(a[index] - a[index + 1]) / 2;
    mean = (a[index] + a[index + 1]) / 2;
    period = (t[index + 1] - t[index]) * 2;
    atime = t[index];
    if (ampl > 0) {
      *array_out++ = ampl;
      *array_out++ = mean;
      *array_out++ = 0.50;
      *array_out++ = atime;
      *array_out++ = period;
    }
  }
  return (tot_num - 1 - cNr);
}


x86 assembly (clang, -O0):
<rf5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2060,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2050(%rbp)
movl   $0x0,-0x2044(%rbp)
mov    -0x2044(%rbp),%eax
imul   $0x5,-0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    1176 <rf5+0x66>
mov    -0x20(%rbp),%rax
movslq -0x2044(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2044(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2044(%rbp)
jmp    113d <rf5+0x2d>
movl   $0xffffffff,-0x2048(%rbp)
ff ff ff
movl   $0x1,-0x204c(%rbp)
movl   $0x0,-0x2044(%rbp)
mov    -0x2044(%rbp),%eax
cmp    -0x2050(%rbp),%eax
jge    161a <rf5+0x50a>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
movsd  (%rax),%xmm0
mov    -0x2048(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2048(%rbp)
cltq
movsd  %xmm0,-0x1020(%rbp,%rax,8)
ff ff
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
movsd  (%rax),%xmm0
movslq -0x2048(%rbp),%rax
movsd  %xmm0,-0x2020(%rbp,%rax,8)
ff ff
xor    %eax,%eax
cmpl   $0x2,-0x2048(%rbp)
mov    %al,-0x2051(%rbp)
jl     127a <rf5+0x16a>
mov    -0x2048(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x1020(%rbp,%rax,8),%xmm0
ff ff
mov    -0x2048(%rbp),%eax
sub    $0x2,%eax
cltq
subsd  -0x1020(%rbp,%rax,8),%xmm0
ff ff
call   1030 <fabs@plt>
mov    %eax,-0x2058(%rbp)
movslq -0x2048(%rbp),%rax
movsd  -0x1020(%rbp,%rax,8),%xmm0
ff ff
mov    -0x2048(%rbp),%eax
sub    $0x1,%eax
cltq
subsd  -0x1020(%rbp,%rax,8),%xmm0
ff ff
call   1030 <fabs@plt>
mov    %eax,%ecx
mov    -0x2058(%rbp),%eax
cmp    %ecx,%eax
setle  %al
mov    %al,-0x2051(%rbp)
mov    -0x2051(%rbp),%al
test   $0x1,%al
jne    128d <rf5+0x17d>
jmp    1601 <rf5+0x4f1>
mov    -0x2048(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
movsd  -0x1020(%rbp,%rcx,8),%xmm0
ff ff
add    $0xfffffffe,%eax
cltq
movsd  -0x1020(%rbp,%rax,8),%xmm1
ff ff
subsd  %xmm1,%xmm0
movsd  0xd42(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x2028(%rbp)
ff
mov    -0x2048(%rbp),%eax
mov    %eax,-0x205c(%rbp)
test   %eax,%eax
je     1314 <rf5+0x204>
jmp    12ec <rf5+0x1dc>
mov    -0x205c(%rbp),%eax
sub    $0x1,%eax
je     1319 <rf5+0x209>
jmp    1300 <rf5+0x1f0>
mov    -0x205c(%rbp),%eax
sub    $0x2,%eax
je     131e <rf5+0x20e>
jmp    1461 <rf5+0x351>
jmp    15fc <rf5+0x4ec>
jmp    15fc <rf5+0x4ec>
movsd  -0x1020(%rbp),%xmm0
ff
addsd  -0x1018(%rbp),%xmm0
ff
movsd  0xcca(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x2030(%rbp)
ff
movsd  -0x2018(%rbp),%xmm0
ff
subsd  -0x2020(%rbp),%xmm0
ff
movsd  0xca6(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x2038(%rbp)
ff
movsd  -0x2020(%rbp),%xmm0
ff
movsd  %xmm0,-0x2040(%rbp)
ff
movsd  -0x1018(%rbp),%xmm0
ff
movsd  %xmm0,-0x1020(%rbp)
ff
movsd  -0x1010(%rbp),%xmm0
ff
movsd  %xmm0,-0x1018(%rbp)
ff
movsd  -0x2018(%rbp),%xmm0
ff
movsd  %xmm0,-0x2020(%rbp)
ff
movsd  -0x2010(%rbp),%xmm0
ff
movsd  %xmm0,-0x2018(%rbp)
ff
movl   $0x1,-0x2048(%rbp)
movsd  -0x2028(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    145c <rf5+0x34c>
movsd  -0x2028(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,(%rax)
movsd  -0x2030(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  0xbe6(%rip),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x2040(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,(%rax)
movsd  -0x2038(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,(%rax)
jmp    15fc <rf5+0x4ec>
mov    -0x2048(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x1020(%rbp,%rax,8),%xmm0
ff ff
mov    -0x2048(%rbp),%eax
sub    $0x2,%eax
cltq
addsd  -0x1020(%rbp,%rax,8),%xmm0
ff ff
movsd  0xb6f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x2030(%rbp)
ff
mov    -0x2048(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x2020(%rbp,%rax,8),%xmm0
ff ff
mov    -0x2048(%rbp),%eax
sub    $0x2,%eax
cltq
subsd  -0x2020(%rbp,%rax,8),%xmm0
ff ff
movsd  0xb33(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x2038(%rbp)
ff
mov    -0x2048(%rbp),%eax
sub    $0x2,%eax
cltq
movsd  -0x2020(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x2040(%rbp)
ff
movslq -0x2048(%rbp),%rax
movsd  -0x1020(%rbp,%rax,8),%xmm0
ff ff
mov    -0x2048(%rbp),%eax
sub    $0x2,%eax
cltq
movsd  %xmm0,-0x1020(%rbp,%rax,8)
ff ff
movslq -0x2048(%rbp),%rax
movsd  -0x2020(%rbp,%rax,8),%xmm0
ff ff
mov    -0x2048(%rbp),%eax
sub    $0x2,%eax
cltq
movsd  %xmm0,-0x2020(%rbp,%rax,8)
ff ff
mov    -0x2048(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x2048(%rbp)
movsd  -0x2028(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    15f7 <rf5+0x4e7>
movsd  -0x2028(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,(%rax)
movsd  -0x2030(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  0xa62(%rip),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x2040(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,(%rax)
movsd  -0x2038(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,(%rax)
mov    -0x204c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x204c(%rbp)
jmp    15fc <rf5+0x4ec>
jmp    11f6 <rf5+0xe6>
jmp    1606 <rf5+0x4f6>
mov    -0x2044(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2044(%rbp)
jmp    1194 <rf5+0x84>
movl   $0x0,-0x2044(%rbp)
mov    -0x2044(%rbp),%eax
cmp    -0x2048(%rbp),%eax
jge    17b0 <rf5+0x6a0>
movslq -0x2044(%rbp),%rax
movsd  -0x1020(%rbp,%rax,8),%xmm0
ff ff
mov    -0x2044(%rbp),%eax
add    $0x1,%eax
cltq
subsd  -0x1020(%rbp,%rax,8),%xmm0
ff ff
call   1030 <fabs@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x2028(%rbp)
ff
movslq -0x2044(%rbp),%rax
movsd  -0x1020(%rbp,%rax,8),%xmm0
ff ff
mov    -0x2044(%rbp),%eax
add    $0x1,%eax
cltq
addsd  -0x1020(%rbp,%rax,8),%xmm0
ff ff
movsd  0x961(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x2030(%rbp)
ff
mov    -0x2044(%rbp),%eax
add    $0x1,%eax
cltq
movsd  -0x2020(%rbp,%rax,8),%xmm0
ff ff
movslq -0x2044(%rbp),%rax
subsd  -0x2020(%rbp,%rax,8),%xmm0
ff ff
movsd  0x929(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x2038(%rbp)
ff
movslq -0x2044(%rbp),%rax
movsd  -0x2020(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x2040(%rbp)
ff
movsd  -0x2028(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1797 <rf5+0x687>
movsd  -0x2028(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,(%rax)
movsd  -0x2030(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  0x8ab(%rip),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x2040(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,(%rax)
movsd  -0x2038(%rbp),%xmm0
ff
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,(%rax)
jmp    179c <rf5+0x68c>
mov    -0x2044(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2044(%rbp)
jmp    1624 <rf5+0x514>
mov    -0x2050(%rbp),%eax
sub    $0x1,%eax
sub    -0x204c(%rbp),%eax
add    $0x2060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rf5>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2048,%rsp
mov    %esi,%r12d
test   %esi,%esi
jle    1453 <rf5+0x333>
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rdi,%rbp
lea    (%r12,%r12,4),%edx
cmp    $0x2,%edx
mov    $0x1,%eax
movl   $0x1,0x4(%rsp)
cmovl  %eax,%edx
shl    $0x3,%rdx
xor    %r14d,%r14d
mov    %rcx,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    $0xffffffff,%r13d
mov    %r12,0x20(%rsp)
jmp    1199 <rf5+0x79>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13d
add    $0x8,%rbp
add    $0x8,%r15
add    $0x1,%r14d
cmp    %r12d,%r14d
je     139a <rf5+0x27a>
movsd  0x0(%rbp),%xmm0
movslq %r13d,%rax
movsd  %xmm0,0x1048(%rsp,%rax,8)
movsd  (%r15),%xmm0
movsd  %xmm0,0x48(%rsp,%rax,8)
test   %r13d,%r13d
jle    1180 <rf5+0x60>
mov    %rbp,0x8(%rsp)
mov    %r15,0x10(%rsp)
lea    -0x1(%r13),%r12d
jmp    11e6 <rf5+0xc6>
nopw   0x0(%rax,%rax,1)
lea    -0x2(%r15),%r13d
add    $0xffffffff,%r15d
add    $0xfffffffffffffffe,%r12
cmp    $0x1,%r15d
jbe    1380 <rf5+0x260>
mov    %r13d,%r15d
add    $0x1,%r13d
movsd  0x1040(%rsp,%r15,8),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x1040(%rsp,%r12,8),%xmm1
movsd  %xmm1,0x30(%rsp)
subsd  %xmm1,%xmm0
movsd  %xmm0,0x28(%rsp)
call   1040 <fabs@plt>
mov    %eax,%ebp
movsd  0x1040(%rsp,%r13,8),%xmm0
movsd  %xmm0,0x38(%rsp)
subsd  0x18(%rsp),%xmm0
call   1040 <fabs@plt>
cmp    %eax,%ebp
jg     12f0 <rf5+0x1d0>
movsd  0x28(%rsp),%xmm0
mulsd  0xdb1(%rip),%xmm0
call   1040 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
test   %r12d,%r12d
je     1300 <rf5+0x1e0>
movsd  0x40(%rsp,%r15,8),%xmm1
movsd  0x40(%rsp,%r12,8),%xmm2
movsd  0x38(%rsp),%xmm3
movsd  %xmm3,0x1040(%rsp,%r12,8)
movsd  0x40(%rsp,%r13,8),%xmm3
movsd  %xmm3,0x40(%rsp,%r12,8)
test   %eax,%eax
jle    11d0 <rf5+0xb0>
subsd  %xmm2,%xmm1
addsd  %xmm1,%xmm1
movsd  0x18(%rsp),%xmm3
addsd  0x30(%rsp),%xmm3
mulsd  0xd4c(%rip),%xmm3
movsd  %xmm0,(%rbx)
movsd  %xmm3,0x8(%rbx)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x10(%rbx)
movsd  %xmm2,0x18(%rbx)
movsd  %xmm1,0x20(%rbx)
add    $0x28,%rbx
addl   $0x1,0x4(%rsp)
jmp    11d0 <rf5+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r15d
mov    %r15d,%r13d
jmp    1386 <rf5+0x266>
nopl   0x0(%rax)
movsd  0x1040(%rsp),%xmm2
movsd  0x40(%rsp),%xmm1
movupd 0x1048(%rsp),%xmm4
movapd %xmm4,0x1040(%rsp)
movupd 0x48(%rsp),%xmm3
movapd %xmm3,0x40(%rsp)
mov    $0x1,%r13d
test   %eax,%eax
mov    0x20(%rsp),%r12
jle    138b <rf5+0x26b>
subsd  %xmm1,%xmm3
addsd  %xmm3,%xmm3
addsd  %xmm4,%xmm2
mulsd  0xcb0(%rip),%xmm2
movsd  %xmm0,(%rbx)
movsd  %xmm2,0x8(%rbx)
movabs $0x3fe0000000000000,%rax
mov    %rax,0x10(%rbx)
movsd  %xmm1,0x18(%rbx)
movsd  %xmm3,0x20(%rbx)
add    $0x28,%rbx
jmp    138b <rf5+0x26b>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%r13d
mov    0x20(%rsp),%r12
mov    0x10(%rsp),%r15
mov    0x8(%rsp),%rbp
jmp    1184 <rf5+0x64>
test   %r13d,%r13d
jle    144d <rf5+0x32d>
mov    %r13d,%r14d
xor    %ebp,%ebp
movabs $0x3fe0000000000000,%r13
jmp    13cc <rf5+0x2ac>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rbp
cmp    %r15,%r14
je     144d <rf5+0x32d>
movsd  0x1040(%rsp,%rbp,8),%xmm0
movsd  0x1048(%rsp,%rbp,8),%xmm1
lea    0x1(%rbp),%r15
movsd  %xmm0,0x18(%rsp)
movsd  %xmm1,0x28(%rsp)
subsd  %xmm1,%xmm0
call   1040 <fabs@plt>
cmp    $0x2,%eax
jl     13c0 <rf5+0x2a0>
shr    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x40(%rsp,%rbp,8),%xmm1
movsd  0x48(%rsp,%rbp,8),%xmm2
subsd  %xmm1,%xmm2
addsd  %xmm2,%xmm2
movsd  0x18(%rsp),%xmm3
addsd  0x28(%rsp),%xmm3
mulsd  0xbd3(%rip),%xmm3
movsd  %xmm0,(%rbx)
movsd  %xmm3,0x8(%rbx)
mov    %r13,0x10(%rbx)
movsd  %xmm1,0x18(%rbx)
movsd  %xmm2,0x20(%rbx)
add    $0x28,%rbx
jmp    13c0 <rf5+0x2a0>
mov    0x4(%rsp),%eax
jmp    1458 <rf5+0x338>
mov    $0x1,%eax
not    %eax
add    %r12d,%eax
add    $0x2048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rf5(double* %0, i32 %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca [512 x double]
%10 = alloca [512 x double]
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store double* %2, double** %7
store double* %3, double** %8
%19 = load i32, i32* %6
store i32 %19, i32* %18
store i32 0, i32* %15
br label %20
20: ; preds = %30, %4
%21 = load i32, i32* %15
%22 = load i32, i32* %6
%23 = mul nsw i32 %22, 5
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %33
25: ; preds = %20
%26 = load double*, double** %8
%27 = load i32, i32* %15
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
store double 0.000000e+00, double* %29
br label %30
30: ; preds = %25
%31 = load i32, i32* %15
%32 = add nsw i32 %31, 1
store i32 %32, i32* %15
br label %20
33: ; preds = %20
store i32 -1, i32* %16
store i32 1, i32* %17
store i32 0, i32* %15
br label %34
34: ; preds = %215, %33
%35 = load i32, i32* %15
%36 = load i32, i32* %18
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %218
38: ; preds = %34
%39 = load double*, double** %5
%40 = getelementptr inbounds double, double* %39, i32 1
store double* %40, double** %5
%41 = load double, double* %39
%42 = load i32, i32* %16
%43 = add nsw i32 %42, 1
store i32 %43, i32* %16
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %44
store double %41, double* %45
%46 = load double*, double** %7
%47 = getelementptr inbounds double, double* %46, i32 1
store double* %47, double** %7
%48 = load double, double* %46
%49 = load i32, i32* %16
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 %50
store double %48, double* %51
br label %52
52: ; preds = %213, %38
%53 = load i32, i32* %16
%54 = icmp sge i32 %53, 2
br i1 %54, label %55, label %80
55: ; preds = %52
%56 = load i32, i32* %16
%57 = sub nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %58
%60 = load double, double* %59
%61 = load i32, i32* %16
%62 = sub nsw i32 %61, 2
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %63
%65 = load double, double* %64
%66 = fsub double %60, %65
%67 = call i32 @fabs(double %66)
%68 = load i32, i32* %16
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %69
%71 = load double, double* %70
%72 = load i32, i32* %16
%73 = sub nsw i32 %72, 1
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %74
%76 = load double, double* %75
%77 = fsub double %71, %76
%78 = call i32 @fabs(double %77)
%79 = icmp sle i32 %67, %78
br label %80
80: ; preds = %55, %52
%81 = phi i1 [ false, %52 ], [ %79, %55 ]
br i1 %81, label %82, label %214
82: ; preds = %80
%83 = load i32, i32* %16
%84 = sub nsw i32 %83, 1
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %85
%87 = load double, double* %86
%88 = load i32, i32* %16
%89 = sub nsw i32 %88, 2
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %90
%92 = load double, double* %91
%93 = fsub double %87, %92
%94 = fdiv double %93, 2.000000e+00
%95 = call i32 @fabs(double %94)
%96 = sitofp i32 %95 to double
store double %96, double* %11
%97 = load i32, i32* %16
switch i32 %97, label %145 [
i32 0, label %98
i32 1, label %99
i32 2, label %100
]
98: ; preds = %82
br label %213
99: ; preds = %82
br label %213
100: ; preds = %82
%101 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 0
%102 = load double, double* %101
%103 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 1
%104 = load double, double* %103
%105 = fadd double %102, %104
%106 = fdiv double %105, 2.000000e+00
store double %106, double* %12
%107 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 1
%108 = load double, double* %107
%109 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 0
%110 = load double, double* %109
%111 = fsub double %108, %110
%112 = fmul double %111, 2.000000e+00
store double %112, double* %13
%113 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 0
%114 = load double, double* %113
store double %114, double* %14
%115 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 1
%116 = load double, double* %115
%117 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 0
store double %116, double* %117
%118 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 2
%119 = load double, double* %118
%120 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 1
store double %119, double* %120
%121 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 1
%122 = load double, double* %121
%123 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 0
store double %122, double* %123
%124 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 2
%125 = load double, double* %124
%126 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 1
store double %125, double* %126
store i32 1, i32* %16
%127 = load double, double* %11
%128 = fcmp ogt double %127, 0.000000e+00
br i1 %128, label %129, label %144
129: ; preds = %100
%130 = load double, double* %11
%131 = load double*, double** %8
%132 = getelementptr inbounds double, double* %131, i32 1
store double* %132, double** %8
store double %130, double* %131
%133 = load double, double* %12
%134 = load double*, double** %8
%135 = getelementptr inbounds double, double* %134, i32 1
store double* %135, double** %8
store double %133, double* %134
%136 = load double*, double** %8
%137 = getelementptr inbounds double, double* %136, i32 1
store double* %137, double** %8
store double 5.000000e-01, double* %136
%138 = load double, double* %14
%139 = load double*, double** %8
%140 = getelementptr inbounds double, double* %139, i32 1
store double* %140, double** %8
store double %138, double* %139
%141 = load double, double* %13
%142 = load double*, double** %8
%143 = getelementptr inbounds double, double* %142, i32 1
store double* %143, double** %8
store double %141, double* %142
br label %144
144: ; preds = %129, %100
br label %213
145: ; preds = %82
%146 = load i32, i32* %16
%147 = sub nsw i32 %146, 1
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %148
%150 = load double, double* %149
%151 = load i32, i32* %16
%152 = sub nsw i32 %151, 2
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %153
%155 = load double, double* %154
%156 = fadd double %150, %155
%157 = fdiv double %156, 2.000000e+00
store double %157, double* %12
%158 = load i32, i32* %16
%159 = sub nsw i32 %158, 1
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 %160
%162 = load double, double* %161
%163 = load i32, i32* %16
%164 = sub nsw i32 %163, 2
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 %165
%167 = load double, double* %166
%168 = fsub double %162, %167
%169 = fmul double %168, 2.000000e+00
store double %169, double* %13
%170 = load i32, i32* %16
%171 = sub nsw i32 %170, 2
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 %172
%174 = load double, double* %173
store double %174, double* %14
%175 = load i32, i32* %16
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %176
%178 = load double, double* %177
%179 = load i32, i32* %16
%180 = sub nsw i32 %179, 2
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %181
store double %178, double* %182
%183 = load i32, i32* %16
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 %184
%186 = load double, double* %185
%187 = load i32, i32* %16
%188 = sub nsw i32 %187, 2
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 %189
store double %186, double* %190
%191 = load i32, i32* %16
%192 = sub nsw i32 %191, 2
store i32 %192, i32* %16
%193 = load double, double* %11
%194 = fcmp ogt double %193, 0.000000e+00
br i1 %194, label %195, label %212
195: ; preds = %145
%196 = load double, double* %11
%197 = load double*, double** %8
%198 = getelementptr inbounds double, double* %197, i32 1
store double* %198, double** %8
store double %196, double* %197
%199 = load double, double* %12
%200 = load double*, double** %8
%201 = getelementptr inbounds double, double* %200, i32 1
store double* %201, double** %8
store double %199, double* %200
%202 = load double*, double** %8
%203 = getelementptr inbounds double, double* %202, i32 1
store double* %203, double** %8
store double 1.000000e+00, double* %202
%204 = load double, double* %14
%205 = load double*, double** %8
%206 = getelementptr inbounds double, double* %205, i32 1
store double* %206, double** %8
store double %204, double* %205
%207 = load double, double* %13
%208 = load double*, double** %8
%209 = getelementptr inbounds double, double* %208, i32 1
store double* %209, double** %8
store double %207, double* %208
%210 = load i32, i32* %17
%211 = add nsw i32 %210, 1
store i32 %211, i32* %17
br label %212
212: ; preds = %195, %145
br label %213
213: ; preds = %212, %144, %99, %98
br label %52
214: ; preds = %80
br label %215
215: ; preds = %214
%216 = load i32, i32* %15
%217 = add nsw i32 %216, 1
store i32 %217, i32* %15
br label %34
218: ; preds = %34
store i32 0, i32* %15
br label %219
219: ; preds = %281, %218
%220 = load i32, i32* %15
%221 = load i32, i32* %16
%222 = icmp slt i32 %220, %221
br i1 %222, label %223, label %284
223: ; preds = %219
%224 = load i32, i32* %15
%225 = sext i32 %224 to i64
%226 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %225
%227 = load double, double* %226
%228 = load i32, i32* %15
%229 = add nsw i32 %228, 1
%230 = sext i32 %229 to i64
%231 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %230
%232 = load double, double* %231
%233 = fsub double %227, %232
%234 = call i32 @fabs(double %233)
%235 = sdiv i32 %234, 2
%236 = sitofp i32 %235 to double
store double %236, double* %11
%237 = load i32, i32* %15
%238 = sext i32 %237 to i64
%239 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %238
%240 = load double, double* %239
%241 = load i32, i32* %15
%242 = add nsw i32 %241, 1
%243 = sext i32 %242 to i64
%244 = getelementptr inbounds [512 x double], [512 x double]* %9, i64 0, i64 %243
%245 = load double, double* %244
%246 = fadd double %240, %245
%247 = fdiv double %246, 2.000000e+00
store double %247, double* %12
%248 = load i32, i32* %15
%249 = add nsw i32 %248, 1
%250 = sext i32 %249 to i64
%251 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 %250
%252 = load double, double* %251
%253 = load i32, i32* %15
%254 = sext i32 %253 to i64
%255 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 %254
%256 = load double, double* %255
%257 = fsub double %252, %256
%258 = fmul double %257, 2.000000e+00
store double %258, double* %13
%259 = load i32, i32* %15
%260 = sext i32 %259 to i64
%261 = getelementptr inbounds [512 x double], [512 x double]* %10, i64 0, i64 %260
%262 = load double, double* %261
store double %262, double* %14
%263 = load double, double* %11
%264 = fcmp ogt double %263, 0.000000e+00
br i1 %264, label %265, label %280
265: ; preds = %223
%266 = load double, double* %11
%267 = load double*, double** %8
%268 = getelementptr inbounds double, double* %267, i32 1
store double* %268, double** %8
store double %266, double* %267
%269 = load double, double* %12
%270 = load double*, double** %8
%271 = getelementptr inbounds double, double* %270, i32 1
store double* %271, double** %8
store double %269, double* %270
%272 = load double*, double** %8
%273 = getelementptr inbounds double, double* %272, i32 1
store double* %273, double** %8
store double 5.000000e-01, double* %272
%274 = load double, double* %14
%275 = load double*, double** %8
%276 = getelementptr inbounds double, double* %275, i32 1
store double* %276, double** %8
store double %274, double* %275
%277 = load double, double* %13
%278 = load double*, double** %8
%279 = getelementptr inbounds double, double* %278, i32 1
store double* %279, double** %8
store double %277, double* %278
br label %280
280: ; preds = %265, %223
br label %281
281: ; preds = %280
%282 = load i32, i32* %15
%283 = add nsw i32 %282, 1
store i32 %283, i32* %15
br label %219
284: ; preds = %219
%285 = load i32, i32* %18
%286 = sub nsw i32 %285, 1
%287 = load i32, i32* %17
%288 = sub nsw i32 %286, %287
ret i32 %288
}

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