// File: /workspace/github_c_makefile_star2_O0/yui0[P]img2vec/./potracelib.h
// Function: pointslope
static void pointslope(privpath_t *pp, int i, int j, dpoint_t *ctr, dpoint_t *dir) {
  /* assume i<j */
  int n = pp->len;
  sums_t *sums = pp->sums;
  double x, y, x2, xy, y2;
  double k;
  double a, b, c, lambda2, l;
  int r=0; /* rotations from i to j */
  while (j>=n) {
    j-=n;
    r+=1;
  }
  while (i>=n) {
    i-=n;
    r-=1;
  }
  while (j<0) {
    j+=n;
    r-=1;
  }
  while (i<0) {
    i+=n;
    r+=1;
  }
  
  x = sums[j+1].x-sums[i].x+r*sums[n].x;
  y = sums[j+1].y-sums[i].y+r*sums[n].y;
  x2 = sums[j+1].x2-sums[i].x2+r*sums[n].x2;
  xy = sums[j+1].xy-sums[i].xy+r*sums[n].xy;
  y2 = sums[j+1].y2-sums[i].y2+r*sums[n].y2;
  k = j+1-i+r*n;
  
  ctr->x = x/k;
  ctr->y = y/k;
  a = (x2-(double)x*x/k)/k;
  b = (xy-(double)x*y/k)/k;
  c = (y2-(double)y*y/k)/k;
  
  lambda2 = (a+c+sqrt((a-c)*(a-c)+4*b*b))/2; /* larger e.value */
  /* now find e.vector for lambda2 */
  a -= lambda2;
  c -= lambda2;
  if (fabs(a) >= fabs(c)) {
    l = sqrt(a*a+b*b);
    if (l!=0) {
      dir->x = -b/l;
      dir->y = a/l;
    }
  } else {
    l = sqrt(c*c+b*b);
    if (l!=0) {
      dir->x = -c/l;
      dir->y = b/l;
    }
  }
  if (l==0) {
    dir->x = dir->y = 0;   /* sometimes this can happen when k=4:
			      the two eigenvalues coincide */
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x8c(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x24(%rbp), %eax
jl 0x2d140
movl -0x24(%rbp), %ecx
movl -0x10(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x10(%rbp)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x2d11c
jmp 0x2d142
movl -0xc(%rbp), %eax
cmpl -0x24(%rbp), %eax
jl 0x2d166
movl -0x24(%rbp), %ecx
movl -0xc(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xc(%rbp)
movl -0x8c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x2d142
jmp 0x2d168
cmpl $0x0, -0x10(%rbp)
jge 0x2d188
movl -0x24(%rbp), %eax
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x8c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x2d168
jmp 0x2d18a
cmpl $0x0, -0xc(%rbp)
jge 0x2d1aa
movl -0x24(%rbp), %eax
addl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x2d18a
movq -0x30(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm1
movq -0x30(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd (%rax), %xmm1
cvtsi2sdl -0x8c(%rbp), %xmm0
movq -0x30(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x30(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
movq -0x30(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd 0x8(%rax), %xmm1
cvtsi2sdl -0x8c(%rbp), %xmm0
movq -0x30(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x30(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm1
movq -0x30(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd 0x10(%rax), %xmm1
cvtsi2sdl -0x8c(%rbp), %xmm0
movq -0x30(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x30(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm1
movq -0x30(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd 0x18(%rax), %xmm1
cvtsi2sdl -0x8c(%rbp), %xmm0
movq -0x30(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x30(%rbp), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm1
movq -0x30(%rbp), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
subsd 0x20(%rax), %xmm1
cvtsi2sdl -0x8c(%rbp), %xmm0
movq -0x30(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
subl -0xc(%rbp), %eax
movl -0x8c(%rbp), %ecx
imull -0x24(%rbp), %ecx
addl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x38(%rbp), %xmm0
divsd -0x60(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
divsd -0x60(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movsd -0x48(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
mulsd -0x38(%rbp), %xmm1
divsd -0x60(%rbp), %xmm1
subsd %xmm1, %xmm0
divsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x50(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
mulsd -0x40(%rbp), %xmm1
divsd -0x60(%rbp), %xmm1
subsd %xmm1, %xmm0
divsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x58(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
mulsd -0x40(%rbp), %xmm1
divsd -0x60(%rbp), %xmm1
subsd %xmm1, %xmm0
divsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x68(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x68(%rbp), %xmm0
subsd -0x78(%rbp), %xmm0
movsd -0x68(%rbp), %xmm2
subsd -0x78(%rbp), %xmm2
movsd 0x4c24(%rip), %xmm1     # 0x32050
mulsd -0x70(%rbp), %xmm1
mulsd -0x70(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x1220
movaps %xmm0, %xmm1
movsd -0x98(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd 0x4bee(%rip), %xmm1     # 0x32048
divsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x80(%rbp), %xmm1
movsd -0x68(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x80(%rbp), %xmm1
movsd -0x78(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x68(%rbp), %xmm0
movaps 0x4c1b(%rip), %xmm1     # 0x320b0
pand %xmm1, %xmm0
movsd -0x78(%rbp), %xmm1
movaps 0x4c0b(%rip), %xmm2     # 0x320b0
pand %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2d538
movsd -0x68(%rbp), %xmm0
movsd -0x68(%rbp), %xmm2
movsd -0x70(%rbp), %xmm1
mulsd -0x70(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x1220
movsd %xmm0, -0x88(%rbp)
movsd -0x88(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x2d4f1
jp 0x2d4f1
jmp 0x2d533
movsd -0x70(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
divsd -0x88(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x68(%rbp), %xmm0
divsd -0x88(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0x2d5ba
movsd -0x78(%rbp), %xmm0
movsd -0x78(%rbp), %xmm2
movsd -0x70(%rbp), %xmm1
mulsd -0x70(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x1220
movsd %xmm0, -0x88(%rbp)
movsd -0x88(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x2d576
jp 0x2d576
jmp 0x2d5b8
movsd -0x78(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
divsd -0x88(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x70(%rbp), %xmm0
divsd -0x88(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0x2d5ba
movsd -0x88(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x2d5e4
jp 0x2d5e4
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rax)
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)