// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movq %r8, %rbx
movl %ecx, %ebp
movq %rdi, %r14
testl %esi, %esi
jle 0xfccc
movq %rdx, %r15
movl %esi, %r12d
testl %ebp, %ebp
jle 0xfcef
movq 0x38(%rbx), %r8
movq 0x40(%rbx), %r9
movq %rsp, %rax
leaq 0x4(%rsp), %r10
movq %r14, %rdi
movl %r12d, %esi
movq %r15, %rdx
movl %ebp, %ecx
pushq %rax
pushq %r10
callq 0xf82c
addq $0x10, %rsp
movl %eax, %r13d
cmpl $0x2, %eax
jl 0xfd0f
movslq 0x4(%rsp), %rsi
movq %rsi, 0x8(%rsp)
movslq (%rsp), %rcx
movq %rcx, 0x10(%rsp)
movq %r14, %rdi
movq %r15, %rdx
movq %rbx, %r8
callq 0xfc1f
movq 0x8(%rsp), %rax
addq %rax, %r14
subl %eax, %r12d
movq 0x10(%rsp), %rax
addq %rax, %r15
subl %eax, %ebp
movq %r14, %rdi
movl %r12d, %esi
movq %r15, %rdx
movl %ebp, %ecx
movq %rbx, %r8
callq 0xfc1f
jmp 0xfd5b
testl %ebp, %ebp
jle 0xfcea
notl %r14d
addl 0x10(%rbx), %r14d
movq (%rbx), %rax
movl %ebp, %ecx
movl %r14d, (%rax)
addq $0x4, %rax
decl %ecx
jne 0xfcdc
movq %rax, (%rbx)
movl %ebp, %r13d
jmp 0xfd5b
subl 0x18(%rbx), %r15d
incl %r15d
movq (%rbx), %rax
movl %r12d, %ecx
movl %r15d, (%rax)
addq $0x4, %rax
decl %ecx
jne 0xfcfc
movq %rax, (%rbx)
movl %r12d, %r13d
jmp 0xfd5b
cmpl $0x1, %r13d
jne 0xfd5b
cmpl %ebp, %r12d
jbe 0xfd3a
subl 0x18(%rbx), %r15d
movl (%rsp), %eax
addl %r15d, %eax
incl %eax
movq (%rbx), %rcx
leaq 0x4(%rcx), %rdx
movq %rdx, (%rbx)
movl %eax, (%rcx)
movl $0x1, %r13d
jmp 0xfd5b
movl $0x1, %r13d
jae 0xfd5b
addl 0x4(%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 $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq