// File: /workspace/github_c_makefile_star2_O1/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 $0x198, %rsp            # imm = 0x198
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r15
movzbl 0x6(%rsi), %eax
movl %eax, 0xc(%rsp)
movzbl 0x16(%rsi), %eax
movl %eax, 0x10(%rsp)
xorl %eax, %eax
movw %ax, 0x16(%rsi)
movw %ax, 0x6(%rsi)
movzwl 0x2(%rdi), %eax
testq %rax, %rax
je 0x73d4
leaq 0x92(%r15), %rcx
movl $0x1, %edx
xorl %esi, %esi
movq $0x0, 0x6(%rcx,%rsi)
movzwl (%rcx,%rsi), %edi
movw %di, 0x12(%rcx,%rsi)
addq $0x30, %rsi
cmpq $0x90, %rsi
jne 0x73a2
leaq 0x1(%rdx), %rsi
addq $0x90, %rcx
cmpq %rax, %rdx
movq %rsi, %rdx
jne 0x73a0
leaq 0x28(%r12), %r13
movzwl (%rbx), %ecx
cmpl $0x2, %ecx
jb 0x7410
movl $0x1, %eax
movq %r13, %rdx
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
movzwl (%rbx), %ecx
cmpl %ecx, %eax
jb 0x73e9
movq (%r13), %rax
movq 0x20(%rax), %r8
leaq 0x4c(%rsp), %rax
leaq 0x160(%rsp), %r10
leaq 0x70(%rsp), %rbp
leaq 0x50(%rsp), %rdx
leaq 0xe0(%rsp), %r9
movq %r15, %rdi
movq %rbp, %rsi
movq %r9, 0x18(%rsp)
pushq %rax
movq %r10, 0x40(%rsp)
pushq %r10
callq 0x6c68
addq $0x10, %rsp
movzwl (%rbx), %ecx
cmpl $0x2, %ecx
jb 0x7494
movl $0x1, %eax
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
movzwl (%rbx), %ecx
cmpl %ecx, %eax
jb 0x7460
movq 0x20(%r12), %r8
leaq 0x9c(%rsp), %r13
leaq 0x120(%rsp), %rax
leaq 0x60(%rsp), %r12
leaq 0x80(%rsp), %rdx
leaq 0xa0(%rsp), %r14
movq %r15, %rdi
movq %r12, %rsi
movq %rdx, 0x20(%rsp)
movq %r14, %r9
pushq %r13
movq %rax, 0x38(%rsp)
pushq %rax
callq 0x6c68
addq $0x10, %rsp
movl (%r13), %eax
movl 0x4c(%rsp), %ecx
cmpl %ecx, %eax
jle 0x74f6
xorl %r11d, %r11d
leaq 0x50(%rsp), %r15
jmp 0x7658
leaq 0x120(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x160(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x80(%rsp), %r15
leaq 0x50(%rsp), %rdi
movq %rdi, 0x20(%rsp)
jge 0x754b
leaq 0xa0(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0xe0(%rsp), %r14
leaq 0x60(%rsp), %rbp
leaq 0x70(%rsp), %r12
xorl %r11d, %r11d
jmp 0x7658
movzwl 0x70(%rsp), %eax
movzwl 0x60(%rsp), %ecx
cmpw %cx, %ax
jne 0x757a
movl $0x1, %edx
movzwl 0x70(%rsp,%rdx,2), %eax
movzwl 0x60(%rsp,%rdx,2), %ecx
cmpw %cx, %ax
jne 0x757a
leaq 0x1(%rdx), %rsi
cmpl $0x7, %edx
movq %rsi, %rdx
jne 0x755f
cmpw %cx, %ax
jbe 0x75a3
leaq 0xa0(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0xe0(%rsp), %r14
leaq 0x60(%rsp), %rbp
leaq 0x70(%rsp), %r12
xorl %r11d, %r11d
jmp 0x75dc
leaq 0x70(%rsp), %rbp
leaq 0x60(%rsp), %rax
movq %rax, %r12
cmoveq %rbp, %r12
cmoveq %rax, %rbp
sete %r11b
leaq 0xe0(%rsp), %rcx
leaq 0xa0(%rsp), %rax
movq %rax, %r14
cmoveq %rcx, %r14
cmoveq %rax, %rcx
movq %rcx, 0x18(%rsp)
movzwl 0x50(%rsp), %eax
movzwl 0x80(%rsp), %ecx
cmpw %cx, %ax
jne 0x7611
movl $0x1, %edx
movzwl 0x50(%rsp,%rdx,2), %eax
movzwl 0x80(%rsp,%rdx,2), %ecx
cmpw %cx, %ax
jne 0x7611
leaq 0x1(%rdx), %rsi
cmpl $0x7, %edx
movq %rsi, %rdx
jne 0x75f3
cmpw %cx, %ax
ja 0x7658
leaq 0x50(%rsp), %r15
leaq 0x80(%rsp), %rax
movq %rax, %rcx
cmoveq %r15, %rcx
movq %rcx, 0x20(%rsp)
cmoveq %rax, %r15
leaq 0x160(%rsp), %rcx
leaq 0x120(%rsp), %rax
movq %rax, %rdx
cmoveq %rcx, %rdx
movq %rdx, 0x30(%rsp)
cmoveq %rax, %rcx
movq %rcx, 0x38(%rsp)
movzwl (%rbp), %eax
movzwl 0x4(%rbx), %ecx
movl %ecx, %esi
cmpw %cx, %ax
jne 0x7684
xorl %edx, %edx
movzwl 0x2(%rbp,%rdx,2), %eax
movzwl 0x6(%rbx,%rdx,2), %esi
cmpw %si, %ax
jne 0x7684
leaq 0x1(%rdx), %rdi
cmpl $0x6, %edx
movq %rdi, %rdx
jne 0x7669
cmpw %si, %ax
jb 0x77d0
jne 0x7794
movzwl (%r12), %edx
movzwl 0x14(%rbx), %r8d
cmpw %r8w, %dx
jne 0x76c3
xorl %edi, %edi
movzwl 0x2(%r12,%rdi,2), %edx
movzwl 0x16(%rbx,%rdi,2), %r8d
cmpw %r8w, %dx
jne 0x76c3
leaq 0x1(%rdi), %r9
cmpl $0x6, %edi
movq %r9, %rdi
jne 0x76a5
cmpw %r8w, %dx
jb 0x77d0
movl $0x0, 0x14(%rsp)
movl $0x0, %edi
movl $0x0, %ebp
cmpw %r8w, %dx
jne 0x779c
movq %r15, 0x40(%rsp)
movl %r11d, 0x28(%rsp)
movq (%r14), %rdx
testq %rdx, %rdx
je 0x796a
movq 0x18(%rsp), %rdi
movq (%rdi), %r8
movzwl 0x24(%rbx), %r9d
movl %r9d, 0x14(%rsp)
leaq 0x8(%rdi), %r9
xorl %r11d, %r11d
movl $0x1, %ebp
xorl %edi, %edi
movq 0x20(%rdx), %rdx
movq 0x28(%rdx), %rdx
movq 0x18(%rdx), %rdx
xorl %r15d, %r15d
xorl %r12d, %r12d
testq %r8, %r8
je 0x7753
movq %r9, %r10
movq %r8, %r13
cmpq %rdx, %r13
movzbl %r15b, %r15d
cmovel %ebp, %r15d
movq (%r10), %r13
addq $0x8, %r10
testq %r13, %r13
jne 0x773c
testb %r15b, %r15b
jne 0x776f
incl %r12d
movq 0x18(%rdx), %rdx
movq 0x28(%rdx), %rdx
movq 0x18(%rdx), %rdx
movq 0x28(%rdx), %rdx
movq 0x18(%rdx), %rdx
testb %r15b, %r15b
je 0x7731
cmpl 0x14(%rsp), %r12d
jl 0x77d0
movzbl %dil, %edi
cmovel %ebp, %edi
movq 0x8(%r14,%r11,8), %rdx
incq %r11
testq %rdx, %rdx
jne 0x771f
jmp 0x796c
xorl %edi, %edi
movl %edx, 0x14(%rsp)
xorl %ebp, %ebp
movzwl (%r15), %r10d
cmpw %cx, %r10w
movq 0x20(%rsp), %r14
jne 0x77ca
xorl %edx, %edx
movzwl 0x2(%r15,%rdx,2), %r10d
movzwl 0x6(%rbx,%rdx,2), %ecx
cmpw %cx, %r10w
jne 0x77ca
leaq 0x1(%rdx), %r8
cmpl $0x6, %edx
movq %r8, %rdx
jne 0x77ad
cmpw %cx, %r10w
jae 0x77f4
movl 0xc(%rsp), %eax
movw %ax, 0x6(%rbx)
movl 0x10(%rsp), %eax
movw %ax, 0x16(%rbx)
xorl %eax, %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jne 0x7912
movl %r11d, 0x28(%rsp)
movzwl (%r14), %r8d
movzwl 0x14(%rbx), %r9d
cmpw %r9w, %r8w
jne 0x782e
xorl %edx, %edx
movzwl 0x2(%r14,%rdx,2), %r8d
movzwl 0x16(%rbx,%rdx,2), %r9d
cmpw %r9w, %r8w
jne 0x782e
leaq 0x1(%rdx), %r11
cmpl $0x6, %edx
movq %r11, %rdx
jne 0x7810
cmpw %r9w, %r8w
jb 0x77d0
xorl %r14d, %r14d
movl $0x0, %r11d
movl $0x0, %edx
cmpw %r9w, %r8w
jne 0x7917
movq 0x30(%rsp), %rdx
movq (%rdx), %rdx
testq %rdx, %rdx
movl %ebp, 0x2c(%rsp)
je 0x7a4b
movq 0x38(%rsp), %r8
movq (%r8), %r11
movzwl 0x24(%rbx), %r9d
movl %r9d, 0x18(%rsp)
leaq 0x8(%r8), %rbp
xorl %r12d, %r12d
movl $0x1, %r13d
movl $0x0, 0x20(%rsp)
movq 0x18(%rdx), %rdx
movq 0x28(%rdx), %rdx
movq 0x20(%rdx), %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
testq %r11, %r11
je 0x78bc
movq %rbp, %r15
movq %r11, %r14
cmpq %rdx, %r14
movzbl %r8b, %r8d
cmovel %r13d, %r8d
movq (%r15), %r14
addq $0x8, %r15
testq %r14, %r14
jne 0x78a5
testb %r8b, %r8b
jne 0x78d8
incl %r9d
movq 0x20(%rdx), %rdx
movq 0x28(%rdx), %rdx
movq 0x20(%rdx), %rdx
movq 0x28(%rdx), %rdx
movq 0x20(%rdx), %rdx
testb %r8b, %r8b
je 0x789a
cmpl 0x18(%rsp), %r9d
jl 0x77d0
movl 0x20(%rsp), %edx
movzbl %dl, %edx
cmovel %r13d, %edx
movl %edx, 0x20(%rsp)
movq 0x30(%rsp), %rdx
movq 0x8(%rdx,%r12,8), %rdx
incq %r12
testq %rdx, %rdx
jne 0x7888
jmp 0x7a53
xorl %r11d, %r11d
xorl %edx, %edx
cmpw %si, %ax
sete %al
andb 0x14(%rsp), %al
testb %dil, %dil
setne %sil
andb %bpl, %sil
andb %al, %sil
movzbl %sil, %esi
leal 0x4(,%rsi,2), %eax
incl %esi
testb $0x1, %dl
cmovel %esi, %eax
testb %r11b, %r11b
cmovel %esi, %eax
testb $0x1, %r14b
cmovel %esi, %eax
cmpw %cx, %r10w
movl 0xc(%rsp), %ecx
movw %cx, 0x6(%rbx)
movl 0x10(%rsp), %ecx
movw %cx, 0x16(%rbx)
cmovnel %esi, %eax
jmp 0x77e2
xorl %edi, %edi
movl 0x28(%rsp), %r11d
movb $0x1, %dl
testb %r11b, %r11b
je 0x7a36
movl %edx, 0x14(%rsp)
movq 0x18(%rsp), %rdx
movq (%rdx), %rdx
testq %rdx, %rdx
je 0x7a3f
movq (%r14), %r10
movzwl 0x24(%rbx), %r8d
movl %r8d, 0x2c(%rsp)
addq $0x8, %r14
xorl %r11d, %r11d
movl $0x1, %ebp
xorl %r15d, %r15d
movq 0x20(%rdx), %rdx
movq 0x28(%rdx), %rdx
movq 0x18(%rdx), %rdx
xorl %r12d, %r12d
xorl %r8d, %r8d
testq %r10, %r10
je 0x79e2
movq %r14, %r13
movq %r10, %r9
cmpq %rdx, %r9
movzbl %r12b, %r12d
cmovel %ebp, %r12d
movq (%r13), %r9
addq $0x8, %r13
testq %r9, %r9
jne 0x79ca
testb %r12b, %r12b
jne 0x79fe
incl %r8d
movq 0x18(%rdx), %rdx
movq 0x28(%rdx), %rdx
movq 0x18(%rdx), %rdx
movq 0x28(%rdx), %rdx
movq 0x18(%rdx), %rdx
testb %r12b, %r12b
je 0x79bf
cmpl 0x2c(%rsp), %r8d
jl 0x77d0
movzbl %r15b, %r15d
cmovel %ebp, %r15d
movq 0x18(%rsp), %rdx
movq 0x8(%rdx,%r11,8), %rdx
incq %r11
testq %rdx, %rdx
jne 0x79ad
testb %r15b, %r15b
setne %bpl
movl 0x28(%rsp), %r11d
jmp 0x7a41
movl %edx, 0x14(%rsp)
movb $0x1, %bpl
jmp 0x7a41
xorl %ebp, %ebp
movq 0x40(%rsp), %r15
jmp 0x779c
movl $0x0, 0x20(%rsp)
movb $0x1, %r14b
cmpb $0x0, 0x28(%rsp)
movl 0x2c(%rsp), %ebp
je 0x7b38
movq 0x38(%rsp), %rdx
movq (%rdx), %r8
testq %r8, %r8
je 0x7b3c
movq 0x30(%rsp), %r15
movq (%r15), %rdx
movzwl 0x24(%rbx), %r9d
movl %r9d, 0x18(%rsp)
addq $0x8, %r15
xorl %r9d, %r9d
movl $0x1, %r12d
xorl %r13d, %r13d
movq %r9, 0x30(%rsp)
movq 0x18(%r8), %r8
movq 0x28(%r8), %r8
movq 0x20(%r8), %r14
xorl %r8d, %r8d
xorl %r9d, %r9d
testq %rdx, %rdx
je 0x7ad2
movq %r15, %rbp
movq %rdx, %r11
cmpq %r14, %r11
movzbl %r8b, %r8d
cmovel %r12d, %r8d
movq (%rbp), %r11
addq $0x8, %rbp
testq %r11, %r11
jne 0x7aba
testb %r8b, %r8b
jne 0x7aee
incl %r9d
movq 0x20(%r14), %r11
movq 0x28(%r11), %r11
movq 0x20(%r11), %r11
movq 0x28(%r11), %r11
movq 0x20(%r11), %r14
testb %r8b, %r8b
je 0x7aaf
cmpl 0x18(%rsp), %r9d
movq 0x30(%rsp), %r9
jl 0x77d0
movzbl %r13b, %r13d
cmovel %r12d, %r13d
movq 0x38(%rsp), %r8
movq 0x8(%r8,%r9,8), %r8
incq %r9
testq %r8, %r8
jne 0x7a98
testb %r13b, %r13b
setne %dl
movl 0x2c(%rsp), %ebp
movl 0x20(%rsp), %r11d
movb $0x1, %r14b
jmp 0x7917
movb $0x1, %dl
jmp 0x7b3e
xorl %edx, %edx
movl 0x20(%rsp), %r11d
jmp 0x7917