// File: /workspace/github_c_makefile_star2_O0/yui0[P]img2vec/./potracelib.h
// Function: penalty3
static double penalty3(privpath_t *pp, int i, int j) {
  int n = pp->len;
  point_t *pt = pp->pt;
  sums_t *sums = pp->sums;
  /* assume 0<=i<j<=n  */
  double x, y, x2, xy, y2;
  double k;
  double a, b, c, s;
  double px, py, ex, ey;
  int r = 0; /* rotations from i to j */
  if (j>=n) {
    j -= n;
    r = 1;
  }
  
  /* critical inner loop: the "if" gives a 4.6 percent speedup */
  if (r == 0) {
    x = sums[j+1].x - sums[i].x;
    y = sums[j+1].y - sums[i].y;
    x2 = sums[j+1].x2 - sums[i].x2;
    xy = sums[j+1].xy - sums[i].xy;
    y2 = sums[j+1].y2 - sums[i].y2;
    k = j+1 - i;
  } else {
    x = sums[j+1].x - sums[i].x + sums[n].x;
    y = sums[j+1].y - sums[i].y + sums[n].y;
    x2 = sums[j+1].x2 - sums[i].x2 + sums[n].x2;
    xy = sums[j+1].xy - sums[i].xy + sums[n].xy;
    y2 = sums[j+1].y2 - sums[i].y2 + sums[n].y2;
    k = j+1 - i + n;
  } 
  px = (pt[i].x + pt[j].x) / 2.0 - pt[0].x;
  py = (pt[i].y + pt[j].y) / 2.0 - pt[0].y;
  ey = (pt[j].x - pt[i].x);
  ex = -(pt[j].y - pt[i].y);
  a = ((x2 - 2*x*px) / k + px*px);
  b = ((xy - x*py - y*px) / k + px*py);
  c = ((y2 - 2*y*py) / k + py*py);
  
  s = ex*ex*a + 2*ex*ey*b + ey*ey*c;
  return sqrt(s);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x9c(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x2cbbd
movl -0x14(%rbp), %ecx
movl -0x10(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x10(%rbp)
movl $0x1, -0x9c(%rbp)
cmpl $0x0, -0x9c(%rbp)
jne 0x2ccd9
movq -0x28(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd 0x8(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd 0x10(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd 0x18(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x28(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd 0x20(%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
subl -0xc(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x2ce49
movq -0x28(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd (%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
addsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd 0x8(%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
addsd 0x8(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd 0x10(%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
addsd 0x10(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd 0x18(%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
addsd 0x18(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x28(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd 0x20(%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
addsd 0x20(%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
subl -0xc(%rbp), %eax
addl -0x14(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movslq -0x10(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
addq (%rcx), %rax
cvtsi2sd %rax, %xmm0
movsd 0x51ce(%rip), %xmm1     # 0x32048
divsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
cvtsi2sdq (%rax), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
movslq -0x10(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
addq 0x8(%rcx), %rax
cvtsi2sd %rax, %xmm0
movsd 0x5185(%rip), %xmm1     # 0x32048
divsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
cvtsi2sdq 0x8(%rax), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x20(%rbp), %rax
movslq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movslq -0xc(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
subq (%rcx), %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x98(%rbp)
movq -0x20(%rbp), %rax
movslq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
subq 0x8(%rax), %rcx
xorl %eax, %eax
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x40(%rbp), %xmm0
movsd 0x50f5(%rip), %xmm1     # 0x32048
mulsd -0x30(%rbp), %xmm1
movsd -0x80(%rbp), %xmm2
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
divsd -0x58(%rbp), %xmm1
movsd -0x80(%rbp), %xmm0
movsd -0x80(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x48(%rbp), %xmm1
movsd -0x30(%rbp), %xmm0
movsd -0x88(%rbp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x80(%rbp), %xmm2
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
divsd -0x58(%rbp), %xmm1
movsd -0x80(%rbp), %xmm0
movsd -0x88(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x50(%rbp), %xmm0
movsd 0x502a(%rip), %xmm1     # 0x32048
mulsd -0x38(%rbp), %xmm1
movsd -0x88(%rbp), %xmm2
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
divsd -0x58(%rbp), %xmm1
movsd -0x88(%rbp), %xmm0
movsd -0x88(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x90(%rbp), %xmm1
mulsd -0x90(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
movsd 0x4fbf(%rip), %xmm0     # 0x32048
mulsd -0x90(%rbp), %xmm0
mulsd -0x98(%rbp), %xmm0
mulsd -0x68(%rbp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0x98(%rbp), %xmm0
mulsd -0x98(%rbp), %xmm0
movsd -0x70(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x78(%rbp), %xmm0
callq 0x1220
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)