// File: /workspace/github_cpp_makefile_star2_O1/kchan1[P]helloworld_test1/./encoder.hh
// Function: isPNTZ(double**, int, int, int, unsigned char, int, int)
char isPNTZ(double**image,int width,int height,int depth, unsigned char threshold,int x, int y)
{
  //if the image is below the threshold, it may be a zerotree
  if(image[x][y] < threshold)
  {
    int layer = depth;
    while(x > width>>layer)
      layer++;
    //if this is the deepest level, there are three children to check
    if(x < width>>depth && y < height>>depth)
    {
      if(isPNTZ(image,width,height,depth,threshold, 
        x+(width>>depth),y)=='T' &&
	isPNTZ(image,width,height,depth,threshold, 
        x,y+(height>>depth))=='T' &&
	isPNTZ(image,width,height,depth,threshold, 
        x+(width>>depth),y+(height>>depth))=='T')
	return 'T';
      else
	return 'Z';
    }
    //if this is the lowest level, there are no children to check
    else if(x > width/2 && y > height/2)
    {
      return 'Z';
    }
    //otherwise there are 4 children to check
    else
    {
      if(isPNTZ(image,width,height,depth,threshold, 
	x*2,y*2)=='T' &&
	isPNTZ(image,width,height,depth,threshold, 
	x*2+1,y*2)=='T' &&
	isPNTZ(image,width,height,depth,threshold, 
        x*2,y*2+1)=='T' &&
	isPNTZ(image,width,height,depth,threshold, 
        x*2+1,y*2+1)=='T')
	return 'T';
      else
	return 'Z';
    }
  }
  else if(image[x][y] >= threshold)
    return 'P';
  else if(image[x][y] >= threshold)
    return 'N';
  else
    return '?';
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movslq 0x50(%rsp), %rbx
movslq %r9d, %rax
movq (%rdi,%rax,8), %rax
movsd (%rax,%rbx,8), %xmm0
cvtsi2sd %r8d, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x2574
movl %r9d, %r12d
movl %esi, %r14d
movq %rdi, %r15
movl %esi, %r13d
sarl %cl, %r13d
cmpl %r9d, %r13d
jle 0x2587
movl %edx, %ebp
sarl %cl, %ebp
cmpl %ebx, %ebp
jle 0x2587
addl %r12d, %r13d
movl %ebx, (%rsp)
movzbl %r8b, %r8d
movq %r15, %rdi
movl %r14d, %esi
movl %r8d, 0x10(%rsp)
movl %ecx, 0xc(%rsp)
movl %edx, 0x14(%rsp)
movl %r13d, %r9d
callq 0x24af
cmpb $0x54, %al
jne 0x263e
addl %ebx, %ebp
movl %ebp, (%rsp)
movq %r15, %rdi
movl %r14d, %esi
movl 0x14(%rsp), %edx
movl 0xc(%rsp), %ecx
movl 0x10(%rsp), %r8d
movl %r12d, %r9d
callq 0x24af
cmpb $0x54, %al
jne 0x263e
movl %ebp, (%rsp)
movq %r15, %rdi
movl %r14d, %esi
movl 0x14(%rsp), %edx
movl 0xc(%rsp), %ecx
movl 0x10(%rsp), %r8d
movl %r13d, %r9d
jmp 0x2630
movb $0x50, %al
ucomisd %xmm1, %xmm0
jae 0x2640
movb $0x3f, %al
jmp 0x2640
movl %r14d, %esi
shrl $0x1f, %esi
addl %r14d, %esi
sarl %esi
movb $0x5a, %al
cmpl %r12d, %esi
jge 0x25aa
movl %edx, %esi
shrl $0x1f, %esi
addl %edx, %esi
sarl %esi
cmpl %ebx, %esi
jl 0x2640
addl %r12d, %r12d
addl %ebx, %ebx
movl %ebx, (%rsp)
movzbl %r8b, %r13d
movq %r15, %rdi
movl %r14d, %esi
movl %r13d, %r8d
movl %ecx, 0xc(%rsp)
movl %edx, %ebp
movl %r12d, %r9d
callq 0x24af
cmpb $0x54, %al
jne 0x263e
movl %r12d, %r9d
orl $0x1, %r9d
movl %ebx, (%rsp)
movq %r15, %rdi
movl %r14d, %esi
movl %ebp, %edx
movl 0xc(%rsp), %ecx
movl %r13d, %r8d
movl %r9d, 0x10(%rsp)
callq 0x24af
cmpb $0x54, %al
jne 0x263e
orl $0x1, %ebx
movl %ebx, (%rsp)
movq %r15, %rdi
movl %r14d, %esi
movl %ebp, %edx
movl 0xc(%rsp), %ecx
movl %r13d, %r8d
movl %r12d, %r9d
callq 0x24af
cmpb $0x54, %al
jne 0x263e
movl %ebx, (%rsp)
movq %r15, %rdi
movl %r14d, %esi
movl %ebp, %edx
movl 0xc(%rsp), %ecx
movl %r13d, %r8d
movl 0x10(%rsp), %r9d
callq 0x24af
movl %eax, %ecx
movb $0x54, %al
cmpb $0x54, %cl
je 0x2640
movb $0x5a, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq