#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 */
double atan2(double, double);
int /*<<< orphan*/ eval_cornu(double, double *, double *);
int /*<<< orphan*/ fit_cornu_half(double, double, double *, double *, double *,
                                  double *);
int /*<<< orphan*/ free(double *);
int hypot(double, double);
scalar_t__ malloc(int);
double mod_2pi(double);
void tweak_ths(const double xs[], const double ys[], double ths[], int n,
               double delt, int closed) {
  double *dks = (double *)malloc(sizeof(double) * n);
  int i;
  double first_k0, last_k1;
  for (i = 0; i < n - 1 + closed; i++) {
    double x0 = xs[i];
    double y0 = ys[i];
    int ip1 = (i + 1) % n;
    double x1 = xs[ip1];
    double y1 = ys[ip1];
    double th, th0, th1;
    double t0, t1, k0, k1;
    double s0, c0, s1, c1;
    double scale;
    double flip = -1;
    if (x0 == x1 && y0 == y1) {
      ((double *)xs)[i] = x1 = x1 + 1e-6;
    }
    th = atan2(y1 - y0, x1 - x0);
    th0 = mod_2pi(ths[i] - th);
    th1 = mod_2pi(th - ths[ip1]);
    th1 += 1e-6;
    if (th1 < th0) {
      double tmp = th0;
      th0 = th1;
      th1 = tmp;
      flip = 1;
    }
    fit_cornu_half(th0, th1, &t0, &t1, &k0, &k1);
    if (flip == 1) {
      double tmp = t0;
      t0 = t1;
      t1 = tmp;
      tmp = k0;
      k0 = k1;
      k1 = tmp;
    }
    eval_cornu(t0, &s0, &c0);
    eval_cornu(t1, &s1, &c1);
    scale = 1 / hypot(y1 - y0, x1 - x0);
    k0 *= scale;
    k1 *= scale;
    if (i > 0)
      dks[i] = k0 - last_k1;
    else
      first_k0 = k0;
    last_k1 = k1;
  }
  if (closed)
    dks[0] = first_k0 - last_k1;
  for (i = 1 - closed; i < n - 1 + closed; i++) {
    int im1 = (i + n - 1) % n;
    double x0 = xs[im1];
    double y0 = ys[im1];
    double x1 = xs[i];
    double y1 = ys[i];
    int ip1 = (i + 1) % n;
    double x2 = xs[ip1];
    double y2 = ys[ip1];
    double chord1 = hypot(x1 - x0, y1 - y0);
    double chord2 = hypot(x2 - x1, y2 - y1);
    ths[i] -= delt * dks[i] * chord1 * chord2 / (chord1 + chord2);
  }
  free(dks);
}


x86 assembly (clang, -O0):
<tweak_ths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
add    -0x2c(%rbp),%ecx
cmp    %ecx,%eax
jge    14d6 <tweak_ths+0x366>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,-0x64(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xde2(%rip),%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
ucomisd -0x70(%rbp),%xmm0
jne    1271 <tweak_ths+0x101>
jp     1271 <tweak_ths+0x101>
movsd  -0x60(%rbp),%xmm0
ucomisd -0x78(%rbp),%xmm0
jne    1271 <tweak_ths+0x101>
jp     1271 <tweak_ths+0x101>
movsd  0xdae(%rip),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x78(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
subsd  -0x58(%rbp),%xmm1
call   1040 <atan2@plt>
movsd  %xmm0,-0x80(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x80(%rbp),%xmm0
call   1090 <mod_2pi@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x64(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
call   1090 <mod_2pi@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  0xd33(%rip),%xmm0
addsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm1
ff
movsd  -0x88(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jbe    133f <tweak_ths+0x1cf>
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0xe8(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0xe8(%rbp),%xmm0
ff
movsd  %xmm0,-0x90(%rbp)
ff
movsd  0xcd9(%rip),%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x90(%rbp),%xmm1
ff
lea    -0x98(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
lea    -0xa8(%rbp),%rdx
lea    -0xb0(%rbp),%rcx
call   1080 <fit_cornu_half@plt>
movsd  -0xe0(%rbp),%xmm0
ff
movsd  0xc90(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    13f0 <tweak_ths+0x280>
jp     13f0 <tweak_ths+0x280>
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0xf0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0xf0(%rbp),%xmm0
ff
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0xf0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xf0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
lea    -0xb8(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
call   1050 <eval_cornu@plt>
movsd  -0xa0(%rbp),%xmm0
ff
lea    -0xc8(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
call   1050 <eval_cornu@plt>
movsd  -0x78(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
subsd  -0x58(%rbp),%xmm1
call   1070 <hypot@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0xd8(%rbp),%xmm0
ff
mulsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xd8(%rbp),%xmm0
ff
mulsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
cmpl   $0x0,-0x3c(%rbp)
jle    14ae <tweak_ths+0x33e>
movsd  -0xa8(%rbp),%xmm0
ff
subsd  -0x50(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    14bb <tweak_ths+0x34b>
movsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0x48(%rbp)
movsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0x50(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11ad <tweak_ths+0x3d>
cmpl   $0x0,-0x2c(%rbp)
je     14f2 <tweak_ths+0x382>
movsd  -0x48(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    $0x1,%eax
sub    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
add    -0x2c(%rbp),%ecx
cmp    %ecx,%eax
jge    167a <tweak_ths+0x50a>
mov    -0x3c(%rbp),%eax
add    -0x1c(%rbp),%eax
sub    $0x1,%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,-0xf4(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xf4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x100(%rbp)
ff
mov    -0x10(%rbp),%rax
movslq -0xf4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x108(%rbp)
ff
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x110(%rbp)
ff
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x118(%rbp)
ff
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,-0x11c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x11c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x128(%rbp)
ff
mov    -0x10(%rbp),%rax
movslq -0x11c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x130(%rbp)
ff
movsd  -0x110(%rbp),%xmm0
ff
subsd  -0x100(%rbp),%xmm0
ff
movsd  -0x118(%rbp),%xmm1
ff
subsd  -0x108(%rbp),%xmm1
ff
call   1070 <hypot@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x138(%rbp)
ff
movsd  -0x128(%rbp),%xmm0
ff
subsd  -0x110(%rbp),%xmm0
ff
movsd  -0x130(%rbp),%xmm1
ff
subsd  -0x118(%rbp),%xmm1
ff
call   1070 <hypot@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x140(%rbp)
ff
movsd  -0x28(%rbp),%xmm1
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  -0x138(%rbp),%xmm1
ff
mulsd  -0x140(%rbp),%xmm1
ff
movsd  -0x138(%rbp),%xmm0
ff
addsd  -0x140(%rbp),%xmm0
ff
divsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    14fd <tweak_ths+0x38d>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tweak_ths>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %r8d,%r12d
movsd  %xmm0,0x80(%rsp)
mov    %ecx,%r14d
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x0(,%r14,8),%edi
call   1060 <malloc@plt>
mov    %r14,%rsi
mov    %rax,0x10(%rsp)
mov    %r12,0x70(%rsp)
lea    (%r14,%r12,1),%eax
add    $0xffffffff,%eax
test   %eax,%eax
mov    %r14,0x40(%rsp)
mov    %eax,0x20(%rsp)
jle    139d <tweak_ths+0x22d>
mov    %eax,%eax
mov    %rax,0x30(%rsp)
movsd  0xe26(%rip),%xmm2
xor    %r13d,%r13d
jmp    1216 <tweak_ths+0xa6>
nop
subsd  0x38(%rsp),%xmm1
mov    0x10(%rsp),%rax
movsd  %xmm1,(%rax,%r13,8)
movsd  0x8(%rsp),%xmm0
mov    0x40(%rsp),%rsi
movsd  0xdfc(%rip),%xmm2
mov    %r14,%r13
movapd %xmm0,%xmm3
cmp    %r14,0x30(%rsp)
je     139d <tweak_ths+0x22d>
movsd  (%rbx,%r13,8),%xmm5
movsd  (%r15,%r13,8),%xmm4
lea    0x1(%r13),%r14
mov    %r14d,%eax
cltd
idiv   %esi
mov    %edx,%r12d
movsd  (%rbx,%r12,8),%xmm1
movsd  (%r15,%r12,8),%xmm0
ucomisd %xmm1,%xmm5
movsd  %xmm3,0x38(%rsp)
jne    125b <tweak_ths+0xeb>
jp     125b <tweak_ths+0xeb>
ucomisd %xmm0,%xmm4
jne    125b <tweak_ths+0xeb>
jp     125b <tweak_ths+0xeb>
addsd  %xmm2,%xmm1
movsd  %xmm1,(%rbx,%r13,8)
subsd  %xmm4,%xmm0
subsd  %xmm5,%xmm1
movsd  %xmm0,0x48(%rsp)
movsd  %xmm1,0x50(%rsp)
call   1040 <atan2@plt>
movapd %xmm0,%xmm1
movsd  %xmm0,(%rsp)
movsd  0x0(%rbp,%r13,8),%xmm0
subsd  %xmm1,%xmm0
call   1090 <mod_2pi@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
subsd  0x0(%rbp,%r12,8),%xmm0
call   1090 <mod_2pi@plt>
addsd  0xd54(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm2
movapd %xmm2,%xmm1
maxsd  %xmm0,%xmm1
minsd  %xmm2,%xmm0
lea    0x68(%rsp),%rdi
lea    0x60(%rsp),%rsi
lea    0x58(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1080 <fit_cornu_half@plt>
movsd  0x18(%rsp),%xmm0
ucomisd (%rsp),%xmm0
movsd  0x68(%rsp),%xmm0
jbe    131d <tweak_ths+0x1ad>
movsd  0x60(%rsp),%xmm1
movsd  %xmm1,0x68(%rsp)
movsd  %xmm0,0x60(%rsp)
movsd  0x58(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
movsd  %xmm2,0x58(%rsp)
movsd  %xmm0,0x8(%rsp)
movapd %xmm1,%xmm0
lea    0xa0(%rsp),%rdi
lea    0x98(%rsp),%rsi
call   1050 <eval_cornu@plt>
movsd  0x60(%rsp),%xmm0
lea    0x90(%rsp),%rdi
lea    0x88(%rsp),%rsi
call   1050 <eval_cornu@plt>
movsd  0x48(%rsp),%xmm0
movsd  0x50(%rsp),%xmm1
call   1070 <hypot@plt>
lea    0x1(%rax),%ecx
cmp    $0x3,%ecx
mov    $0x0,%ecx
cmovae %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x58(%rsp),%xmm1
mulsd  %xmm0,%xmm1
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
test   %r13,%r13
jne    11e0 <tweak_ths+0x70>
movsd  %xmm1,0x28(%rsp)
jmp    11f7 <tweak_ths+0x87>
mov    0x70(%rsp),%rdx
test   %edx,%edx
je     13b9 <tweak_ths+0x249>
movsd  0x28(%rsp),%xmm1
subsd  %xmm0,%xmm1
mov    0x10(%rsp),%rax
movsd  %xmm1,(%rax)
mov    $0x1,%eax
sub    %edx,%eax
cmp    0x20(%rsp),%eax
jge    14f8 <tweak_ths+0x388>
cltq
lea    (%rbx,%rax,8),%rcx
mov    %rcx,0x30(%rsp)
lea    (%r15,%rax,8),%rcx
mov    %rcx,0x28(%rsp)
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%rcx
mov    %rcx,0x20(%rsp)
lea    0x0(%rbp,%rax,8),%rbp
mov    %esi,%r14d
sub    %edx,%r14d
lea    (%rsi,%rdx,2),%eax
add    $0xfffffffe,%eax
mov    %rax,0x78(%rsp)
mov    $0x2,%r13d
sub    %edx,%r13d
xor    %r12d,%r12d
xchg   %ax,%ax
lea    (%r14,%r12,1),%eax
cltd
idiv   %esi
movslq %edx,%rcx
mov    0x30(%rsp),%rax
movsd  (%rax,%r12,8),%xmm1
movsd  %xmm1,0x38(%rsp)
mov    0x28(%rsp),%rax
movsd  (%rax,%r12,8),%xmm2
movsd  %xmm2,(%rsp)
lea    (%r12,%r13,1),%eax
cltd
idiv   %esi
movslq %edx,%rax
movsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,0x48(%rsp)
movsd  (%r15,%rax,8),%xmm0
movsd  %xmm0,0x50(%rsp)
movapd %xmm1,%xmm0
subsd  (%rbx,%rcx,8),%xmm0
movapd %xmm2,%xmm1
subsd  (%r15,%rcx,8),%xmm1
call   1070 <hypot@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x48(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
movsd  0x50(%rsp),%xmm1
subsd  (%rsp),%xmm1
call   1070 <hypot@plt>
movsd  0x80(%rsp),%xmm2
mov    0x40(%rsp),%rsi
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    0x20(%rsp),%rax
movsd  (%rax,%r12,8),%xmm1
mulsd  %xmm2,%xmm1
movsd  0x18(%rsp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm0,%xmm3
divsd  %xmm3,%xmm1
movsd  0x0(%rbp,%r12,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x0(%rbp,%r12,8)
add    $0x1,%r12
cmp    %r12d,0x78(%rsp)
jne    1410 <tweak_ths+0x2a0>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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