// File: /workspace/github_c_makefile_star2_O2/mishun[P]plantri/fullgen.c
// Function: bauchbinde_reko
int bauchbinde_reko(PLANMAP map,KNOTENTYP *code,KANTE *anfangskante)
{
int i,j,k, patchknz1, patchknz2, test, test2, test3, test4, returnwert;
KANTE *run;
KNOTENTYP code1[8], code2[8], spiegelcode1[8], spiegelcode2[8];
KANTE *ministart1[7], *ministart2[7], *spiegelministart1[7], *spiegelministart2[7];
KNOTENTYP *ucode, *lcode, *uscode, *lscode;
KANTE **ustart, **lstart, **us_start, **ls_start;
BOOL gleich, ende;
BOOL j_gleich1, j_gleich2, j_gleich3, j_gleich4;                 /* TH */
FLAECHENTYP c3, c11;


c3=code[3]; c11=code[11];
code[3]=code[11]=0;

for (i=1; i<=map[0][0].name; i++) for (j=0;j<3; j++) { map[i][j].dummy=0;
						       map[i][j].mininame=map[i][j].name; }

for (i=1, run=anfangskante->invers->prev; i<code[0]; i+=2)
  { run->prev->mininame=aussen;
    run=run->invers->next->invers->prev; }

reko_bb_code(map, code1, spiegelcode1, code[0], anfangskante->invers->next, ministart1, spiegelministart1, 
	     &patchknz1);


for (i=1, run=anfangskante->invers->prev; i<code[0]; i+=2)
  { run->prev->mininame=run->prev->name;
    run->invers->prev->mininame=aussen;
    run=run->invers->next->invers->prev; }

reko_bb_code(map, code2, spiegelcode2, code[0], anfangskante->next, ministart2, spiegelministart2, 
	     &patchknz2);


if (patchknz2>patchknz1) { ucode=code2; uscode=spiegelcode2; lcode=code1; lscode=spiegelcode1; 
			   ustart=ministart2; lstart=ministart1; us_start=spiegelministart2;
			   ls_start=spiegelministart1; gleich=0; }
   else if (patchknz2<patchknz1) { ucode=code1; uscode=spiegelcode1; lcode=code2; lscode=spiegelcode2; 
				   ustart=ministart1; lstart=ministart2; us_start=spiegelministart1;
				   ls_start=spiegelministart2; gleich=0; }
        else /* d.h. beide patchknotenzahlen gleich */
	  { test=codecmp_kn(code1,code2,8);
	    if (test>0) { ucode=code1; lcode=code2; ustart=ministart1; lstart=ministart2; gleich=0; }
	      else { if (test<0) { ucode=code2; lcode=code1; ustart=ministart2; lstart=ministart1; gleich=0; }
		     else { ucode=code1; lcode=code2; ustart=ministart1; lstart=ministart2; /*vorerst*/ gleich=1;
			  }
		   }
	    test=codecmp_kn(spiegelcode1,spiegelcode2,8);
	    if (test>0) { uscode=spiegelcode1; lscode=spiegelcode2; us_start=spiegelministart1; 
			  ls_start=spiegelministart2;  }
	      else { if (test<0) { uscode=spiegelcode2; lscode=spiegelcode1; us_start=spiegelministart2; 
				   ls_start=spiegelministart1;  }
		     else { uscode=spiegelcode1; lscode=spiegelcode2; us_start=spiegelministart1; /*vorerst*/ 
			    ls_start=spiegelministart2; }
		   }
	  }

j_gleich1 = j_gleich2 = 0;       /* TH */
if ((test=codecmp_kn(lcode,code+2,8)) < 0) {code[3]=c3; code[11]=c11; return(0);}
   else if (test==0)
         { if ((test2=codecmp_kn(ucode,code+10,8)) < 0) {code[3]=c3; code[11]=c11; return(0);}
	   else if (test2==0) /* d.h. die verschiebung muss entscheiden */
	     { for (i=0; ustart[i]!=nil; i++)
		 { run=ustart[i]->next->invers->prev;
		   j=ende=0;
		   while (!ende)
		     { 
		       for (k=0; lstart[k] != nil; k++) if (lstart[k]==run) ende=1;
		       if (!ende) { j++; run=run->prev->invers->prev->invers->prev; }
		     }
		   if (j<code[18])  {code[3]=c3; code[11]=c11; return(0);}
		   if (j==code[18]) {j_gleich1 = 1;}            /* TH */
                 }
	       if (gleich) {
		 for (i=0; lstart[i]!=nil; i++)
		   { run=lstart[i]->next->invers->prev;
		     j=ende=0;
		     while (!ende)
		       {
		         for (k=0; ustart[k] != nil; k++) if (ustart[k]==run) ende=1;
		         if (!ende) { j++; run=run->prev->invers->prev->invers->prev; }
		       }
		     if (j<code[18]) {code[3]=c3; code[11]=c11; return(0);}
                     if (j==code[18]) {j_gleich2 = 1;}     /* TH */
                   }
               }
               else {j_gleich2 = 1;}     /* TH */
	     } /* ende test2==0 */
	 } /* ende test==0 */


/* nun fuer die gespiegelte version: */

j_gleich3 = j_gleich4 = 0;          /* TH */
if ((test3=codecmp_kn(lscode,code+2,8)) < 0) { code[3]=c3; code[11]=c11; return(0); }
   else if (test3==0)
         { if ((test4=codecmp_kn(uscode,code+10,8)) < 0) {code[3]=c3; code[11]=c11; return(0);}
	   else if (test4==0) /* d.h. die verschiebung muss entscheiden */
	     { 
	       for (i=0; us_start[i]!=nil; i++)
		 { run=us_start[i]->prev->invers->next;
		   j=ende=0;
		   while (!ende)
		     { for (k=0; ls_start[k] != nil; k++) if (ls_start[k]==run) ende=1;
		       if (!ende) { j++; run=run->next->invers->next->invers->next; }
		     }
		   if (j<code[18]) {code[3]=c3; code[11]=c11; return(0);}
                   if (j==code[18]) {j_gleich3 = 1;}         /* TH */
		 }
	       if (gleich) {
		 for (i=0; ls_start[i]!=nil; i++)
		 { run=ls_start[i]->prev->invers->next;
		   j=ende=0;
		   while (!ende)
		     { for (k=0; us_start[k] != nil; k++) if (us_start[k]==run) ende=1;
		       if (!ende) { j++; run=run->next->invers->next->invers->next; }
		     }
		   if (j<code[18]) {code[3]=c3; code[11]=c11; return(0);}
                   if (j==code[18]) {j_gleich4 = 1;}
		 }
               }
               else {j_gleich4 = 1;}      /* TH */
	     } /* ende test2==0 */
	 } /* ende test==0 */

code[3]=c3; code[11]=c11;

/* TH: Auswertung */
returnwert = 1;
if (test==0 && test2==0 && j_gleich1 && j_gleich2) {returnwert=2;}
if (test3==0 && test4==0 && j_gleich3 && j_gleich4) {
  if (returnwert==1) {returnwert=4;} else {returnwert=6;}
}
return(returnwert);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdx, %r15
movq %rsi, %rbx
movzbl 0x6(%rsi), %eax
movl %eax, 0x4(%rsp)
movzbl 0x16(%rsi), %eax
movl %eax, 0x8(%rsp)
andw $0x0, 0x16(%rsi)
movq %rdi, %rbp
andw $0x0, 0x6(%rsi)
movzwl 0x2(%rdi), %eax
incq %rax
leaq 0x92(%rdi), %rcx
pushq $0x1
popq %rdx
cmpq %rax, %rdx
je 0x56e2
xorl %esi, %esi
cmpq $0x90, %rsi
je 0x56d6
andq $0x0, 0x6(%rcx,%rsi)
movzwl (%rcx,%rsi), %edi
movw %di, 0x12(%rcx,%rsi)
addq $0x30, %rsi
jmp 0x56b8
incq %rdx
addq $0x90, %rcx
jmp 0x56b1
leaq 0x28(%r15), %r13
pushq $0x1
popq %rax
movq %r13, %rdx
movzwl (%rbx), %ecx
cmpl %ecx, %eax
jae 0x5715
movq (%rdx), %rcx
movq 0x18(%rcx), %rcx
movq 0x18(%rcx), %rdx
movw $0x246, 0x14(%rdx)      # imm = 0x246
movq 0x28(%rcx), %rcx
movq 0x20(%rcx), %rdx
addq $0x28, %rdx
addl $0x2, %eax
jmp 0x56ec
movq (%r13), %rax
movq 0x20(%rax), %r8
leaq 0x3c(%rsp), %rax
leaq 0x90(%rsp), %r12
leaq 0x40(%rsp), %rsi
leaq 0x60(%rsp), %rdx
leaq 0x110(%rsp), %r14
movq %rbp, %rdi
movq %rdx, 0x30(%rsp)
movq %r14, %r9
pushq %rax
pushq %r12
callq 0x4fdd
popq %rax
popq %rcx
pushq $0x1
popq %rax
movzwl (%rbx), %ecx
cmpl %ecx, %eax
jae 0x578a
movq (%r13), %rcx
movq 0x18(%rcx), %rcx
movq 0x18(%rcx), %rdx
movzwl 0x2(%rdx), %esi
movw %si, 0x14(%rdx)
movq 0x28(%rcx), %rcx
movq 0x18(%rcx), %rdx
movw $0x246, 0x14(%rdx)      # imm = 0x246
movq 0x20(%rcx), %r13
addq $0x28, %r13
addl $0x2, %eax
jmp 0x5754
movq 0x20(%r15), %r8
leaq 0x8c(%rsp), %r15
leaq 0x150(%rsp), %rax
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
leaq 0xd0(%rsp), %r13
movq %rbp, %rdi
movq %rax, %rbp
movq %rsi, 0x10(%rsp)
movq %rdx, 0x28(%rsp)
movq %r13, %r9
pushq %r15
pushq %rax
callq 0x4fdd
popq %rax
popq %rcx
movl (%r15), %eax
movl 0x3c(%rsp), %ecx
cmpl %ecx, %eax
jle 0x57ef
movq %rbp, 0x20(%rsp)
movl $0x0, 0xc(%rsp)
leaq 0x40(%rsp), %rdi
jmp 0x5931
leaq 0x150(%rsp), %r12
leaq 0x90(%rsp), %rax
jge 0x5846
movq %rax, 0x20(%rsp)
leaq 0xd0(%rsp), %r14
leaq 0x110(%rsp), %r13
leaq 0x50(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x60(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
jmp 0x5931
leaq 0x40(%rsp), %r14
leaq 0x70(%rsp), %rsi
pushq $0x8
popq %rdx
movq %r14, %rdi
movq %rsi, %r15
callq 0x2337
testl %eax, %eax
jle 0x5881
movq %r14, 0x10(%rsp)
leaq 0xd0(%rsp), %r14
leaq 0x110(%rsp), %r13
movl $0x0, 0xc(%rsp)
jmp 0x58bd
leaq 0x40(%rsp), %r15
leaq 0x70(%rsp), %rax
movq %rax, %rcx
cmoveq %r15, %rcx
movq %rcx, 0x10(%rsp)
cmoveq %rax, %r15
sete %al
movl %eax, 0xc(%rsp)
leaq 0x110(%rsp), %r14
leaq 0xd0(%rsp), %rax
movq %rax, %r13
cmoveq %r14, %r13
cmoveq %rax, %r14
leaq 0x60(%rsp), %rdi
leaq 0x50(%rsp), %rbp
pushq $0x8
popq %rdx
movq %rdi, 0x28(%rsp)
movq %rbp, %rsi
callq 0x2337
testl %eax, %eax
jle 0x58ef
movq %rbp, 0x30(%rsp)
leaq 0x90(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x592e
leaq 0x60(%rsp), %rcx
leaq 0x50(%rsp), %rax
movq %rax, %rdx
cmoveq %rcx, %rdx
movq %rdx, 0x28(%rsp)
cmoveq %rax, %rcx
movq %rcx, 0x30(%rsp)
leaq 0x90(%rsp), %r12
leaq 0x150(%rsp), %rax
movq %rax, %rcx
cmoveq %r12, %rcx
movq %rcx, 0x20(%rsp)
cmoveq %rax, %r12
movq %r15, %rdi
leaq 0x4(%rbx), %rbp
pushq $0x8
popq %rdx
movq %rbp, %rsi
callq 0x2337
testl %eax, %eax
js 0x5c24
movl %eax, %r15d
je 0x59dd
movl %r15d, 0x1c(%rsp)
xorl %r15d, %r15d
movl %eax, 0x10(%rsp)
xorl %ecx, %ecx
movl %ecx, 0x38(%rsp)
pushq $0x8
popq %rdx
movq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x2337
testl %eax, %eax
js 0x5c24
movl %eax, %r14d
je 0x5a88
xorl %ecx, %ecx
xorl %esi, %esi
cmpl $0x0, 0x1c(%rsp)
sete %al
andb 0x10(%rsp), %al
testb %r15b, %r15b
setne %dil
andb 0x38(%rsp), %dil
andb %al, %dil
movzbl %dil, %edi
leal 0x4(,%rdi,2), %eax
incl %edi
testb $0x1, %sil
cmovel %edi, %eax
testb %cl, %cl
cmovel %edi, %eax
testb $0x1, %dl
cmovel %edi, %eax
testl %r14d, %r14d
movl 0x4(%rsp), %ecx
movw %cx, 0x6(%rbx)
movl 0x8(%rsp), %ecx
movw %cx, 0x16(%rbx)
cmovnel %edi, %eax
jmp 0x5c36
leaq 0x14(%rbx), %rsi
pushq $0x8
popq %rdx
movq 0x10(%rsp), %rdi
callq 0x2337
testl %eax, %eax
js 0x5c24
movl %r15d, 0x1c(%rsp)
movl $0x0, 0x10(%rsp)
movl $0x0, %r15d
movl $0x0, %ecx
testl %eax, %eax
jne 0x595f
xorl %ecx, %ecx
pushq $0x1
popq %rax
xorl %r15d, %r15d
movq (%r13,%rcx,8), %rsi
testq %rsi, %rsi
je 0x5b2b
addq $0x20, %rsi
xorl %edx, %edx
movq (%rsi), %rsi
movq 0x28(%rsi), %rsi
movq 0x18(%rsi), %rsi
xorl %edi, %edi
movq %r14, %r8
movq (%r8), %r9
testq %r9, %r9
je 0x5a5a
cmpq %rsi, %r9
movzbl %dil, %edi
cmovel %eax, %edi
addq $0x8, %r8
jmp 0x5a42
testb %dil, %dil
jne 0x5a6f
incl %edx
movq 0x18(%rsi), %rsi
movq 0x28(%rsi), %rsi
addq $0x18, %rsi
jmp 0x5a32
movzwl 0x24(%rbx), %esi
cmpl %esi, %edx
jb 0x5c24
movzbl %r15b, %r15d
cmovel %eax, %r15d
incq %rcx
jmp 0x5a1e
leaq 0x14(%rbx), %rsi
pushq $0x8
popq %rdx
movq 0x28(%rsp), %rdi
callq 0x2337
testl %eax, %eax
js 0x5c24
xorl %edx, %edx
movl $0x0, %ecx
movl $0x0, %esi
testl %eax, %eax
jne 0x5988
xorl %edx, %edx
pushq $0x1
popq %rax
xorl %ecx, %ecx
movq 0x20(%rsp), %rbp
movq (%rbp,%rdx,8), %rdi
testq %rdi, %rdi
je 0x5ba9
addq $0x18, %rdi
xorl %esi, %esi
movq (%rdi), %rdi
movq 0x28(%rdi), %rdi
movq 0x20(%rdi), %rdi
xorl %r8d, %r8d
movq %r12, %r9
movq (%r9), %r10
testq %r10, %r10
je 0x5aff
cmpq %rdi, %r10
movzbl %r8b, %r8d
cmovel %eax, %r8d
addq $0x8, %r9
jmp 0x5ae6
testb %r8b, %r8b
jne 0x5b14
incl %esi
movq 0x20(%rdi), %rdi
movq 0x28(%rdi), %rdi
addq $0x20, %rdi
jmp 0x5ad5
movzwl 0x24(%rbx), %edi
cmpl %edi, %esi
jb 0x5c24
movzbl %cl, %ecx
cmovel %eax, %ecx
incq %rdx
jmp 0x5ac1
cmpb $0x0, 0xc(%rsp)
je 0x5c48
movb $0x1, %cl
movl %ecx, 0x10(%rsp)
xorl %ecx, %ecx
xorl %edx, %edx
movq (%r14,%rcx,8), %rdi
testq %rdi, %rdi
je 0x5c55
addq $0x20, %rdi
xorl %esi, %esi
movq (%rdi), %rdi
movq 0x28(%rdi), %rdi
movq 0x18(%rdi), %rdi
xorl %r8d, %r8d
movq %r13, %r9
movq (%r9), %r10
testq %r10, %r10
je 0x5b7d
cmpq %rdi, %r10
movzbl %r8b, %r8d
cmovel %eax, %r8d
addq $0x8, %r9
jmp 0x5b64
testb %r8b, %r8b
jne 0x5b92
incl %esi
movq 0x18(%rdi), %rdi
movq 0x28(%rdi), %rdi
addq $0x18, %rdi
jmp 0x5b53
movzwl 0x24(%rbx), %edi
cmpl %edi, %esi
jb 0x5c24
movzbl %dl, %edx
cmovel %eax, %edx
incq %rcx
jmp 0x5b40
movb $0x1, %dl
cmpb $0x0, 0xc(%rsp)
je 0x5c5f
xorl %esi, %esi
xorl %edi, %edi
movq (%r12,%rsi,8), %r9
testq %r9, %r9
je 0x5c67
addq $0x18, %r9
xorl %r8d, %r8d
movq (%r9), %r9
movq 0x28(%r9), %r9
movq 0x20(%r9), %r9
xorl %r10d, %r10d
movq %rbp, %r11
movq (%r11), %r13
testq %r13, %r13
je 0x5bf8
cmpq %r9, %r13
movzbl %r10b, %r10d
cmovel %eax, %r10d
addq $0x8, %r11
jmp 0x5bdf
testb %r10b, %r10b
jne 0x5c0e
incl %r8d
movq 0x20(%r9), %r9
movq 0x28(%r9), %r9
addq $0x20, %r9
jmp 0x5bce
movzwl 0x24(%rbx), %r9d
cmpl %r9d, %r8d
jb 0x5c24
movzbl %dil, %edi
cmovel %eax, %edi
incq %rsi
jmp 0x5bba
movl 0x4(%rsp), %eax
movw %ax, 0x6(%rbx)
movl 0x8(%rsp), %eax
movw %ax, 0x16(%rbx)
xorl %eax, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %al
movl %eax, 0x10(%rsp)
movb $0x1, %cl
jmp 0x595f
testb %dl, %dl
setne %cl
jmp 0x595f
movb $0x1, %sil
jmp 0x5988
testb %dil, %dil
setne %sil
jmp 0x5988