// File: /workspace/github_c_makefile_star2_O0/yui0[P]img2vec/./potracelib.h
// Function: findpath
static path_t *findpath(potrace_bitmap_t *bm, int x0, int y0, int sign, int turnpolicy) {
  int x, y, dirx, diry, len, size;
  uint64_t area;
  int c, d, tmp;
  point_t *pt, *pt1;
  path_t *p = NULL;
  x = x0;
  y = y0;
  dirx = 0;
  diry = -1;
  len = size = 0;
  pt = NULL;
  area = 0;
  
  while (1) {
    /* add point to path */
    if (len>=size) {
      size += 100;
      size = (int)(1.3 * size);
      pt1 = (point_t *)realloc(pt, size * sizeof(point_t));
      if (!pt1) {
	goto error;
      }
      pt = pt1;
    }
    pt[len].x = x;
    pt[len].y = y;
    len++;
    
    /* move to next point */
    x += dirx;
    y += diry;
    area += x*diry;
    
    /* path complete? */
    if (x==x0 && y==y0) {
      break;
    }
    
    /* determine next direction */
    c = BM_GET(bm, x + (dirx+diry-1)/2, y + (diry-dirx-1)/2);
    d = BM_GET(bm, x + (dirx-diry-1)/2, y + (diry+dirx-1)/2);
    
    if (c && !d) {               /* ambiguous turn */
      if (turnpolicy == POTRACE_TURNPOLICY_RIGHT
	  || (turnpolicy == POTRACE_TURNPOLICY_BLACK && sign == '+')
	  || (turnpolicy == POTRACE_TURNPOLICY_WHITE && sign == '-')
	  || (turnpolicy == POTRACE_TURNPOLICY_RANDOM && detrand(x,y))
	  || (turnpolicy == POTRACE_TURNPOLICY_MAJORITY && majority(bm, x, y))
	  || (turnpolicy == POTRACE_TURNPOLICY_MINORITY && !majority(bm, x, y))) {
	tmp = dirx;              /* right turn */
	dirx = diry;
	diry = -tmp;
      } else {
	tmp = dirx;              /* left turn */
	dirx = -diry;
	diry = tmp;
      }
    } else if (c) {              /* right turn */
      tmp = dirx;
      dirx = diry;
      diry = -tmp;
    } else if (!d) {             /* left turn */
      tmp = dirx;
      dirx = -diry;
      diry = tmp;
    }
  } /* while this path */
  /* allocate new path object */
  p = path_new();
  if (!p) {
    goto error;
  }
  p->priv->pt = pt;
  p->priv->len = len;
  p->area = area <= INT_MAX ? area : INT_MAX; /* avoid overflow */
  p->sign = sign;
  return p;
 
 error:
   free(pt);
   return NULL; 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq $0x0, -0x68(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x40(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jl 0xc51e
movl -0x38(%rbp), %eax
addl $0x64, %eax
movl %eax, -0x38(%rbp)
cvtsi2sdl -0x38(%rbp), %xmm1
movsd 0x25b6e(%rip), %xmm0    # 0x32058
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x38(%rbp)
movq -0x58(%rbp), %rdi
movslq -0x38(%rbp), %rsi
shlq $0x4, %rsi
callq 0x11b0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0xc516
jmp 0xca17
movq -0x60(%rbp), %rax
movq %rax, -0x58(%rbp)
movslq -0x24(%rbp), %rcx
movq -0x58(%rbp), %rax
movslq -0x34(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movslq -0x28(%rbp), %rcx
movq -0x58(%rbp), %rax
movslq -0x34(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x30(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
imull -0x30(%rbp), %eax
cltq
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0xc58c
movl -0x28(%rbp), %eax
cmpl -0x18(%rbp), %eax
jne 0xc58c
jmp 0xc9a0
movl -0x24(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
subl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x6c(%rbp), %eax
addl %ecx, %eax
cmpl $0x0, %eax
jl 0xc705
movl -0x24(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
subl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x70(%rbp), %eax
addl %ecx, %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xc705
movl -0x28(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x30(%rbp), %eax
subl -0x2c(%rbp), %eax
subl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x74(%rbp), %eax
addl %ecx, %eax
cmpl $0x0, %eax
jl 0xc705
movl -0x28(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x30(%rbp), %eax
subl -0x2c(%rbp), %eax
subl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x78(%rbp), %eax
addl %ecx, %eax
movq -0x10(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0xc705
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xa0(%rbp)
movl -0x28(%rbp), %ecx
movl -0x30(%rbp), %eax
subl -0x2c(%rbp), %eax
subl $0x1, %eax
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
movq -0xa0(%rbp), %rax
addl %edx, %ecx
movslq %ecx, %rcx
movq -0x10(%rbp), %rdx
movslq 0x8(%rdx), %rdx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
subl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x94(%rbp), %eax
addl %ecx, %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x90(%rbp), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x88(%rbp)
movl -0x24(%rbp), %ecx
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
subl $0x1, %eax
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
movq -0x88(%rbp), %rax
addl %edx, %ecx
andl $0x3f, %ecx
movl %ecx, %ecx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
shrq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x7c(%rbp)
jmp 0xc70c
xorl %eax, %eax
movl %eax, -0x7c(%rbp)
jmp 0xc70c
movl -0x7c(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0x2c(%rbp), %eax
subl -0x30(%rbp), %eax
subl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xa4(%rbp), %eax
addl %ecx, %eax
cmpl $0x0, %eax
jl 0xc8a6
movl -0x24(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0x2c(%rbp), %eax
subl -0x30(%rbp), %eax
subl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xa8(%rbp), %eax
addl %ecx, %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xc8a6
movl -0x28(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0x30(%rbp), %eax
addl -0x2c(%rbp), %eax
subl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xac(%rbp), %eax
addl %ecx, %eax
cmpl $0x0, %eax
jl 0xc8a6
movl -0x28(%rbp), %eax
movl %eax, -0xb0(%rbp)
movl -0x30(%rbp), %eax
addl -0x2c(%rbp), %eax
subl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xb0(%rbp), %eax
addl %ecx, %eax
movq -0x10(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0xc8a6
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xd8(%rbp)
movl -0x28(%rbp), %ecx
movl -0x30(%rbp), %eax
addl -0x2c(%rbp), %eax
subl $0x1, %eax
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
movq -0xd8(%rbp), %rax
addl %edx, %ecx
movslq %ecx, %rcx
movq -0x10(%rbp), %rdx
movslq 0x8(%rdx), %rdx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0xcc(%rbp)
movl -0x2c(%rbp), %eax
subl -0x30(%rbp), %eax
subl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xcc(%rbp), %eax
addl %ecx, %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xc8(%rbp), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xc0(%rbp)
movl -0x24(%rbp), %ecx
movl -0x2c(%rbp), %eax
subl -0x30(%rbp), %eax
subl $0x1, %eax
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
movq -0xc0(%rbp), %rax
addl %edx, %ecx
andl $0x3f, %ecx
movl %ecx, %ecx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
shrq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0xb4(%rbp)
jmp 0xc8b0
xorl %eax, %eax
movl %eax, -0xb4(%rbp)
jmp 0xc8b0
movl -0xb4(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0xc961
cmpl $0x0, -0x48(%rbp)
jne 0xc961
cmpl $0x3, -0x20(%rbp)
je 0xc935
cmpl $0x0, -0x20(%rbp)
jne 0xc8df
cmpl $0x2b, -0x1c(%rbp)
je 0xc935
cmpl $0x1, -0x20(%rbp)
jne 0xc8eb
cmpl $0x2d, -0x1c(%rbp)
je 0xc935
cmpl $0x6, -0x20(%rbp)
jne 0xc901
movl -0x24(%rbp), %edi
movl -0x28(%rbp), %esi
callq 0x2ed90
cmpl $0x0, %eax
jne 0xc935
cmpl $0x5, -0x20(%rbp)
jne 0xc91b
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
callq 0x2ee30
cmpl $0x0, %eax
jne 0xc935
cmpl $0x4, -0x20(%rbp)
jne 0xc94b
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
callq 0x2ee30
cmpl $0x0, %eax
jne 0xc94b
movl -0x2c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
xorl %eax, %eax
subl -0x4c(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0xc95f
movl -0x2c(%rbp), %eax
movl %eax, -0x4c(%rbp)
xorl %eax, %eax
subl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0xc99b
cmpl $0x0, -0x44(%rbp)
je 0xc97d
movl -0x2c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
xorl %eax, %eax
subl -0x4c(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0xc999
cmpl $0x0, -0x48(%rbp)
jne 0xc997
movl -0x2c(%rbp), %eax
movl %eax, -0x4c(%rbp)
xorl %eax, %eax
subl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0xc999
jmp 0xc99b
jmp 0xc4cc
callq 0x85f0
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0xc9b2
jmp 0xca17
movq -0x58(%rbp), %rcx
movq -0x68(%rbp), %rax
movq 0x38(%rax), %rax
movq %rcx, 0x8(%rax)
movl -0x34(%rbp), %ecx
movq -0x68(%rbp), %rax
movq 0x38(%rax), %rax
movl %ecx, (%rax)
cmpq $0x7fffffff, -0x40(%rbp) # imm = 0x7FFFFFFF
ja 0xc9e6
movq -0x40(%rbp), %rax
movq %rax, -0xe0(%rbp)
jmp 0xc9f4
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, -0xe0(%rbp)
jmp 0xc9f4
movq -0xe0(%rbp), %rax
movl %eax, %ecx
movq -0x68(%rbp), %rax
movl %ecx, (%rax)
movl -0x1c(%rbp), %ecx
movq -0x68(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x68(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xca28
movq -0x58(%rbp), %rdi
callq 0x1030
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)