// File: /workspace/github_c_makefile_star2_O2/thegenemyers[P]DASCRUBBER/align.c
// Function: dandc_nd
static int dandc_nd(char *A, int M, char *B, int N, Trace_Waves *wave)
{ int x, y;
  int D;

#ifdef DEBUG_ALIGN
  printf("%*s %ld,%ld: %d vs %d\n",depth,"",A-wave->Aabs,B-wave->Babs,M,N);
#endif

  if (M <= 0)
    { x = (wave->Aabs-A)-1;
      for (y = 1; y <= N; y++)
        { *wave->Stop++ = x;
#ifdef DEBUG_SCRIPT
          printf("%*s *I %ld(%ld)\n",depth,"",y+(B-wave->Babs),(A-wave->Aabs)+1);
#endif
        }
      return (N);
    }

  if (N <= 0)
    { y = (B-wave->Babs)+1;
      for (x = 1; x <= M; x++)
        { *wave->Stop++ = y;
#ifdef DEBUG_SCRIPT
          printf("%*s *D %ld(%ld)\n",depth,"",x+(A-wave->Aabs),(B-wave->Babs)+1);
#endif
        }
      return (M);
    }

  D = split_nd(A,M,B,N,wave,&x,&y);

  if (D > 1)
    { 
#ifdef DEBUG_ALIGN
      printf("%*s (%d,%d) @ %d\n",depth,"",x,y,D);
      fflush(stdout);
      depth += 2;
#endif

      dandc_nd(A,x,B,y,wave);
      dandc_nd(A+x,M-x,B+y,N-y,wave);

#ifdef DEBUG_ALIGN
      depth -= 2;
#endif
    }

  else if (D == 1)

    { if (M > N)
        { *wave->Stop++ = (B-wave->Babs)+y+1;
#ifdef DEBUG_SCRIPT
          printf("%*s  D %ld(%ld)\n",depth,"",(A-wave->Aabs)+x,(B-wave->Babs)+y+1);
#endif
        }

      else if (M < N)
        { *wave->Stop++ = (wave->Aabs-A)-x-1;
#ifdef DEBUG_SCRIPT
          printf("%*s  I %ld(%ld)\n",depth,"",(B-wave->Babs)+y,(A-wave->Aabs)+x+1);
#endif
        }

#ifdef DEBUG_SCRIPT
      else
        printf("%*s  %ld S %ld\n",depth,"",(wave->Aabs-A)+x,(B-wave->Babs)+y);
#endif
    }

  return (D);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %rbx
movl %ecx, %ebp
movq %rdi, %r14
testl %esi, %esi
jle 0xe784
movq %rdx, %r15
movl %esi, %r12d
testl %ebp, %ebp
jle 0xe7ab
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
leaq 0x14(%rsp), %r9
movq %r14, %rdi
movl %r12d, %esi
movq %r15, %rdx
movl %ebp, %ecx
movq %rbx, %r8
callq 0xe316
movl %eax, %r13d
cmpl $0x2, %eax
jl 0xe7ce
movslq 0x14(%rsp), %rsi
movq %rsi, 0x18(%rsp)
movslq 0x10(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movq %r14, %rdi
movq %r15, %rdx
movq %rbx, %r8
callq 0xe6dc
movq 0x18(%rsp), %rax
addq %rax, %r14
subl %eax, %r12d
movq 0x20(%rsp), %rax
addq %rax, %r15
subl %eax, %ebp
movq %r14, %rdi
movl %r12d, %esi
movq %r15, %rdx
movl %ebp, %ecx
movq %rbx, %r8
callq 0xe6dc
jmp 0xe817
notl %r14d
addl 0x10(%rbx), %r14d
xorl %eax, %eax
testl %ebp, %ebp
cmovgl %ebp, %eax
subl $0x1, %eax
jb 0xe7a6
movq (%rbx), %rcx
leaq 0x4(%rcx), %rdx
movq %rdx, (%rbx)
movl %r14d, (%rcx)
jmp 0xe792
movl %ebp, %r13d
jmp 0xe817
subl 0x18(%rbx), %r15d
incl %r15d
movq (%rbx), %rax
movl %r12d, %ecx
subl $0x1, %ecx
jb 0xe7c6
movl %r15d, (%rax)
addq $0x4, %rax
jmp 0xe7b8
movq %rax, (%rbx)
movl %r12d, %r13d
jmp 0xe817
cmpl $0x1, %r13d
jne 0xe817
cmpl %ebp, %r12d
jbe 0xe7f8
subl 0x18(%rbx), %r15d
movl 0x10(%rsp), %eax
addl %r15d, %eax
incl %eax
movq (%rbx), %rcx
leaq 0x4(%rcx), %rdx
movq %rdx, (%rbx)
movl %eax, (%rcx)
pushq $0x1
popq %r13
jmp 0xe817
pushq $0x1
popq %r13
jae 0xe817
addl 0x14(%rsp), %r14d
notl %r14d
addl 0x10(%rbx), %r14d
movq (%rbx), %rax
leaq 0x4(%rax), %rcx
movq %rcx, (%rbx)
movl %r14d, (%rax)
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq