// File: /workspace/github_c_makefile_star2_O0/josch[P]stride/mergepat.c
// Function: Near
int Near(int Res1, int Res2, int Res3, int Res4, int Res5, int Res6, int Res7, int Res8,
	 char Cn1, char Cn2, char Cn3, char Cn4, int *DistBest, int *DistWorst)
{

/*
   Res5 Res2 Res1
   Res6 Res3 Res4
*/

  int a, b, c1, d1, c, d, Nei1, Nei2;


  if( Cn1 != Cn2 || Cn3 != Cn4 ) return(FAILURE);


  if( Res1 >= Res2 && Res2 >= Res5 && Res7 >= Res1 && 
      Res4 <= Res3 && Res4 <= Res6 && Res8 <= Res4 ) {

    if( Res5 == Res2 ) 
      Nei1 = Res2;
    else
      Nei1 = Res2-1;
    
    if( Res1 == Res7 ) 
      Nei2 = Res1;
    else
      Nei2 = Res1+1;
    
    a = Nei2-Nei1;
    c1 = Nei2-Res5;
    
    if( Res3 == Res6 ) 
      Nei1 = Res3;
    else
      Nei1 = Res3+1;
    
    if( Res4 == Res8 ) 
      Nei2 = Res4;
    else
      Nei2 = Res4-1;
    
    b = Nei1-Nei2;
    d1 = Res6-Nei2;
  }
  else
    return(FAILURE);
  
  c = Maximum(c1,a);
  d = Maximum(d1,b);
  
  if( a >= 0 && b >= 0 && c >= 0 && d >= 0 && 
      ( (a <= 2 && b <= 5) || (a <= 5 && b <= 2) ) ) {
    *DistBest  = Minimum(a,b);
    *DistWorst = Maximum(c,d);
    if( *DistBest <= *DistWorst ) 
      return(SUCCESS);
    else
      return(FAILURE);
  }
  
  return(FAILURE);
}

// Assembly:
movq 0x40(%rsp), %rax
movq 0x38(%rsp), %rax
movb 0x30(%rsp), %al
movb 0x28(%rsp), %al
movb 0x20(%rsp), %al
movb 0x18(%rsp), %al
movl 0x10(%rsp), %eax
movl 0x8(%rsp), %eax
movl %edi, -0x8(%rsp)
movl %esi, -0xc(%rsp)
movl %edx, -0x10(%rsp)
movl %ecx, -0x14(%rsp)
movl %r8d, -0x18(%rsp)
movl %r9d, -0x1c(%rsp)
movsbl 0x18(%rsp), %eax
movsbl 0x20(%rsp), %ecx
cmpl %ecx, %eax
jne 0x12538
movsbl 0x28(%rsp), %eax
movsbl 0x30(%rsp), %ecx
cmpl %ecx, %eax
je 0x12545
movl $0x0, -0x4(%rsp)
jmp 0x1275e
movl -0x8(%rsp), %eax
cmpl -0xc(%rsp), %eax
jl 0x12647
movl -0xc(%rsp), %eax
cmpl -0x18(%rsp), %eax
jl 0x12647
movl 0x8(%rsp), %eax
cmpl -0x8(%rsp), %eax
jl 0x12647
movl -0x14(%rsp), %eax
cmpl -0x10(%rsp), %eax
jg 0x12647
movl -0x14(%rsp), %eax
cmpl -0x1c(%rsp), %eax
jg 0x12647
movl 0x10(%rsp), %eax
cmpl -0x14(%rsp), %eax
jg 0x12647
movl -0x18(%rsp), %eax
cmpl -0xc(%rsp), %eax
jne 0x125ad
movl -0xc(%rsp), %eax
movl %eax, -0x38(%rsp)
jmp 0x125b8
movl -0xc(%rsp), %eax
subl $0x1, %eax
movl %eax, -0x38(%rsp)
movl -0x8(%rsp), %eax
cmpl 0x8(%rsp), %eax
jne 0x125cc
movl -0x8(%rsp), %eax
movl %eax, -0x3c(%rsp)
jmp 0x125d7
movl -0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rsp)
movl -0x3c(%rsp), %eax
subl -0x38(%rsp), %eax
movl %eax, -0x20(%rsp)
movl -0x3c(%rsp), %eax
subl -0x18(%rsp), %eax
movl %eax, -0x28(%rsp)
movl -0x10(%rsp), %eax
cmpl -0x1c(%rsp), %eax
jne 0x12603
movl -0x10(%rsp), %eax
movl %eax, -0x38(%rsp)
jmp 0x1260e
movl -0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rsp)
movl -0x14(%rsp), %eax
cmpl 0x10(%rsp), %eax
jne 0x12622
movl -0x14(%rsp), %eax
movl %eax, -0x3c(%rsp)
jmp 0x1262d
movl -0x14(%rsp), %eax
subl $0x1, %eax
movl %eax, -0x3c(%rsp)
movl -0x38(%rsp), %eax
subl -0x3c(%rsp), %eax
movl %eax, -0x24(%rsp)
movl -0x1c(%rsp), %eax
subl -0x3c(%rsp), %eax
movl %eax, -0x2c(%rsp)
jmp 0x12654
movl $0x0, -0x4(%rsp)
jmp 0x1275e
movl -0x28(%rsp), %eax
cmpl -0x20(%rsp), %eax
jge 0x12668
movl -0x20(%rsp), %eax
movl %eax, -0x40(%rsp)
jmp 0x12670
movl -0x28(%rsp), %eax
movl %eax, -0x40(%rsp)
movl -0x40(%rsp), %eax
movl %eax, -0x30(%rsp)
movl -0x2c(%rsp), %eax
cmpl -0x24(%rsp), %eax
jge 0x1268c
movl -0x24(%rsp), %eax
movl %eax, -0x44(%rsp)
jmp 0x12694
movl -0x2c(%rsp), %eax
movl %eax, -0x44(%rsp)
movl -0x44(%rsp), %eax
movl %eax, -0x34(%rsp)
cmpl $0x0, -0x20(%rsp)
jl 0x12756
cmpl $0x0, -0x24(%rsp)
jl 0x12756
cmpl $0x0, -0x30(%rsp)
jl 0x12756
cmpl $0x0, -0x34(%rsp)
jl 0x12756
cmpl $0x2, -0x20(%rsp)
jg 0x126d6
cmpl $0x5, -0x24(%rsp)
jle 0x126e4
cmpl $0x5, -0x20(%rsp)
jg 0x12756
cmpl $0x2, -0x24(%rsp)
jg 0x12756
movl -0x20(%rsp), %eax
cmpl -0x24(%rsp), %eax
jge 0x126f8
movl -0x20(%rsp), %eax
movl %eax, -0x48(%rsp)
jmp 0x12700
movl -0x24(%rsp), %eax
movl %eax, -0x48(%rsp)
movl -0x48(%rsp), %ecx
movq 0x38(%rsp), %rax
movl %ecx, (%rax)
movl -0x30(%rsp), %eax
cmpl -0x34(%rsp), %eax
jge 0x1271f
movl -0x34(%rsp), %eax
movl %eax, -0x4c(%rsp)
jmp 0x12727
movl -0x30(%rsp), %eax
movl %eax, -0x4c(%rsp)
movl -0x4c(%rsp), %ecx
movq 0x40(%rsp), %rax
movl %ecx, (%rax)
movq 0x38(%rsp), %rax
movl (%rax), %eax
movq 0x40(%rsp), %rcx
cmpl (%rcx), %eax
jg 0x1274c
movl $0x1, -0x4(%rsp)
jmp 0x1275e
movl $0x0, -0x4(%rsp)
jmp 0x1275e
movl $0x0, -0x4(%rsp)
movl -0x4(%rsp), %eax
retq
nopw %cs:(%rax,%rax)