// File: /workspace/github_cpp_makefile_star2_O2/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
movl %r9d, %r12d
movslq 0x50(%rsp), %rbp
movslq %r9d, %rax
movq (%rdi,%rax,8), %rax
movsd (%rax,%rbp,8), %xmm0
cvtsi2sd %r8d, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x259e
movl %edx, %r9d
movl %esi, %r14d
movq %rdi, %r15
movl %esi, %r13d
sarl %cl, %r13d
cmpl %r12d, %r13d
jle 0x25b1
movl %r9d, %ebx
sarl %cl, %ebx
cmpl %ebp, %ebx
jle 0x25b1
addl %r12d, %r13d
movl %ebp, (%rsp)
movzbl %r8b, %r8d
movq %r15, %rdi
movl %r14d, %esi
movl %r9d, %edx
movl %r8d, 0x10(%rsp)
movl %ecx, 0xc(%rsp)
movl %r9d, 0x14(%rsp)
movl %r13d, %r9d
callq 0x24d1
cmpb $0x54, %al
jne 0x266b
addl %ebp, %ebx
movl %ebx, (%rsp)
movq %r15, %rdi
movl %r14d, %esi
movl 0x14(%rsp), %edx
movl 0xc(%rsp), %ecx
movl 0x10(%rsp), %r8d
movl %r12d, %r9d
callq 0x24d1
cmpb $0x54, %al
jne 0x266b
movl %ebx, (%rsp)
movq %r15, %rdi
movl %r14d, %esi
movl 0x14(%rsp), %edx
movl 0xc(%rsp), %ecx
movl 0x10(%rsp), %r8d
movl %r13d, %r9d
jmp 0x265d
movb $0x50, %al
ucomisd %xmm1, %xmm0
jae 0x266d
movb $0x3f, %al
jmp 0x266d
pushq $0x2
popq %rdi
movl %r14d, %eax
cltd
idivl %edi
movl %eax, %esi
movl %r9d, %eax
cltd
idivl %edi
movl %eax, %edx
movb $0x5a, %al
cmpl %r12d, %esi
jge 0x25d3
cmpl %ebp, %edx
jl 0x266d
addl %r12d, %r12d
addl %ebp, %ebp
movl %ebp, (%rsp)
movzbl %r8b, %r13d
movq %r15, %rdi
movl %r14d, %esi
movl %r9d, %edx
movl %r13d, %r8d
movl %ecx, 0xc(%rsp)
movl %r9d, %ebx
movl %r12d, %r9d
callq 0x24d1
cmpb $0x54, %al
jne 0x266b
movl %r12d, %r9d
orl $0x1, %r9d
movl %ebp, (%rsp)
movq %r15, %rdi
movl %r14d, %esi
movl %ebx, %edx
movl 0xc(%rsp), %ecx
movl %r13d, %r8d
movl %r9d, 0x10(%rsp)
callq 0x24d1
cmpb $0x54, %al
jne 0x266b
orl $0x1, %ebp
movl %ebp, (%rsp)
movq %r15, %rdi
movl %r14d, %esi
movl %ebx, %edx
movl 0xc(%rsp), %ecx
movl %r13d, %r8d
movl %r12d, %r9d
callq 0x24d1
cmpb $0x54, %al
jne 0x266b
movl %ebp, (%rsp)
movq %r15, %rdi
movl %r14d, %esi
movl %ebx, %edx
movl 0xc(%rsp), %ecx
movl %r13d, %r8d
movl 0x10(%rsp), %r9d
callq 0x24d1
movl %eax, %ecx
movb $0x54, %al
cmpb $0x54, %cl
je 0x266d
movb $0x5a, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq