// File: /workspace/github_c_makefile_star2_O3/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 0x7591
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 0x755f
leaq 0x1(%rdx), %rsi
addq $0x90, %rcx
cmpq %rax, %rdx
movq %rsi, %rdx
jne 0x755d
leaq 0x28(%r12), %r13
movzwl (%rbx), %ecx
cmpl $0x2, %ecx
jb 0x75cd
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 0x75a6
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 0x6de8
addq $0x10, %rsp
movzwl (%rbx), %ecx
cmpl $0x2, %ecx
jb 0x7651
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 0x761d
movq 0x20(%r12), %r8
leaq 0x9c(%rsp), %r14
leaq 0x120(%rsp), %rax
leaq 0x60(%rsp), %r12
leaq 0x80(%rsp), %rdx
leaq 0xa0(%rsp), %r13
movq %r15, %rdi
movq %rdx, %r15
movq %r12, %rsi
movq %r13, %r9
pushq %r14
movq %rax, 0x38(%rsp)
pushq %rax
callq 0x6de8
addq $0x10, %rsp
movl (%r14), %eax
movl 0x4c(%rsp), %ecx
cmpl %ecx, %eax
jle 0x76b0
xorl %r8d, %r8d
leaq 0x50(%rsp), %r11
jmp 0x7808
leaq 0x120(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x160(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x80(%rsp), %r11
leaq 0x50(%rsp), %r15
jge 0x7700
leaq 0xa0(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0xe0(%rsp), %r13
leaq 0x60(%rsp), %rbp
leaq 0x70(%rsp), %r12
xorl %r8d, %r8d
jmp 0x7808
movzwl 0x70(%rsp), %eax
movzwl 0x60(%rsp), %ecx
cmpw %cx, %ax
jne 0x772f
movl $0x1, %edx
movzwl 0x70(%rsp,%rdx,2), %eax
movzwl 0x60(%rsp,%rdx,2), %ecx
cmpw %cx, %ax
jne 0x772f
leaq 0x1(%rdx), %rsi
cmpl $0x7, %edx
movq %rsi, %rdx
jne 0x7714
cmpw %cx, %ax
jbe 0x7758
leaq 0xa0(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0xe0(%rsp), %r13
leaq 0x60(%rsp), %rbp
leaq 0x70(%rsp), %r12
xorl %r8d, %r8d
jmp 0x7791
leaq 0x70(%rsp), %rbp
leaq 0x60(%rsp), %rax
movq %rax, %r12
cmoveq %rbp, %r12
cmoveq %rax, %rbp
sete %r8b
leaq 0xe0(%rsp), %rcx
leaq 0xa0(%rsp), %rax
movq %rax, %r13
cmoveq %rcx, %r13
cmoveq %rax, %rcx
movq %rcx, 0x18(%rsp)
movzwl 0x50(%rsp), %eax
movzwl 0x80(%rsp), %ecx
cmpw %cx, %ax
jne 0x77c6
movl $0x1, %edx
movzwl 0x50(%rsp,%rdx,2), %eax
movzwl 0x80(%rsp,%rdx,2), %ecx
cmpw %cx, %ax
jne 0x77c6
leaq 0x1(%rdx), %rsi
cmpl $0x7, %edx
movq %rsi, %rdx
jne 0x77a8
cmpw %cx, %ax
ja 0x7808
leaq 0x50(%rsp), %r11
leaq 0x80(%rsp), %rax
movq %rax, %r15
cmoveq %r11, %r15
cmoveq %rax, %r11
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), %edx
movzwl 0x4(%rbx), %ecx
movl %ecx, %esi
cmpw %cx, %dx
jne 0x7834
xorl %eax, %eax
movzwl 0x2(%rbp,%rax,2), %edx
movzwl 0x6(%rbx,%rax,2), %esi
cmpw %si, %dx
jne 0x7834
leaq 0x1(%rax), %rdi
cmpl $0x6, %eax
movq %rdi, %rax
jne 0x7819
cmpw %si, %dx
jb 0x798f
jne 0x7956
movl %r8d, 0x8(%rsp)
movzwl (%r12), %r8d
movzwl 0x14(%rbx), %r9d
cmpw %r9w, %r8w
jne 0x7878
xorl %eax, %eax
movzwl 0x2(%r12,%rax,2), %r8d
movzwl 0x16(%rbx,%rax,2), %r9d
cmpw %r9w, %r8w
jne 0x7878
leaq 0x1(%rax), %rdi
cmpl $0x6, %eax
movq %rdi, %rax
jne 0x785a
cmpw %r9w, %r8w
jb 0x798f
movl $0x0, 0x24(%rsp)
movl $0x0, %r12d
movl $0x0, %r14d
cmpw %r9w, %r8w
movl 0x8(%rsp), %r8d
jne 0x7960
movq (%r13), %r9
testq %r9, %r9
movq %r11, 0x40(%rsp)
movq %r15, 0x28(%rsp)
je 0x7b25
movq 0x18(%rsp), %rax
movq (%rax), %r14
movzwl 0x24(%rbx), %edi
movl %edi, 0x24(%rsp)
leaq 0x8(%rax), %rdi
xorl %r15d, %r15d
movl $0x1, %ebp
movq %r9, %rax
xorl %r12d, %r12d
movl %r12d, 0x14(%rsp)
addq $0x20, %rax
xorl %r12d, %r12d
movq (%rax), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
testq %r14, %r14
je 0x791f
xorl %r10d, %r10d
movq %rdi, %r11
movq %r14, %r8
cmpq %rax, %r8
movzbl %r10b, %r10d
cmovel %ebp, %r10d
movq (%r11), %r8
addq $0x8, %r11
testq %r8, %r8
jne 0x7903
testb %r10b, %r10b
jne 0x7930
incl %r12d
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
addq $0x18, %rax
jmp 0x78ea
cmpl 0x24(%rsp), %r12d
jb 0x798f
movl 0x14(%rsp), %r12d
movzbl %r12b, %r12d
cmovel %ebp, %r12d
movq 0x8(%r13,%r15,8), %rax
incq %r15
testq %rax, %rax
jne 0x78de
jmp 0x7b28
xorl %r12d, %r12d
movl %eax, 0x24(%rsp)
xorl %r14d, %r14d
movzwl (%r11), %r10d
cmpw %cx, %r10w
jne 0x7989
xorl %eax, %eax
movzwl 0x2(%r11,%rax,2), %r10d
movzwl 0x6(%rbx,%rax,2), %ecx
cmpw %cx, %r10w
jne 0x7989
leaq 0x1(%rax), %rdi
cmpl $0x6, %eax
movq %rdi, %rax
jne 0x796c
cmpw %cx, %r10w
jae 0x79b3
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 0x7acf
movl %r14d, 0x28(%rsp)
movl %r8d, 0x8(%rsp)
movzwl (%r15), %r9d
movzwl 0x14(%rbx), %r14d
cmpw %r14w, %r9w
jne 0x79f2
xorl %eax, %eax
movzwl 0x2(%r15,%rax,2), %r9d
movzwl 0x16(%rbx,%rax,2), %r14d
cmpw %r14w, %r9w
jne 0x79f2
leaq 0x1(%rax), %rdi
cmpl $0x6, %eax
movq %rdi, %rax
jne 0x79d4
cmpw %r14w, %r9w
jb 0x798f
xorl %ebp, %ebp
movl $0x0, %edi
movl $0x0, %r8d
cmpw %r14w, %r9w
movl 0x28(%rsp), %r14d
jne 0x7ad4
movq 0x30(%rsp), %rax
movq (%rax), %r14
testq %r14, %r14
movl %r12d, 0x14(%rsp)
je 0x7c19
movq 0x38(%rsp), %rax
movq (%rax), %r11
movzwl 0x24(%rbx), %edi
movl %edi, 0x40(%rsp)
leaq 0x8(%rax), %r12
xorl %r13d, %r13d
movl $0x1, %r8d
movq %r14, %rax
movl $0x0, 0x18(%rsp)
addq $0x18, %rax
xorl %r9d, %r9d
movq (%rax), %rax
movq 0x28(%rax), %rax
movq 0x20(%rax), %rax
testq %r11, %r11
je 0x7a8d
xorl %ebp, %ebp
movq %r12, %rdi
movq %r11, %r15
cmpq %rax, %r15
movzbl %bpl, %ebp
cmovel %r8d, %ebp
movq (%rdi), %r15
addq $0x8, %rdi
testq %r15, %r15
jne 0x7a71
testb %bpl, %bpl
jne 0x7a9e
incl %r9d
movq 0x20(%rax), %rax
movq 0x28(%rax), %rax
addq $0x20, %rax
jmp 0x7a59
cmpl 0x40(%rsp), %r9d
jb 0x798f
movl 0x18(%rsp), %eax
movzbl %al, %eax
cmovel %r8d, %eax
movl %eax, 0x18(%rsp)
movq 0x30(%rsp), %rax
movq 0x8(%rax,%r13,8), %rax
incq %r13
testq %rax, %rax
jne 0x7a52
jmp 0x7c21
xorl %edi, %edi
xorl %r8d, %r8d
cmpw %si, %dx
sete %al
andb 0x24(%rsp), %al
testb %r12b, %r12b
setne %dl
andb %r14b, %dl
andb %al, %dl
movzbl %dl, %edx
leal 0x4(,%rdx,2), %eax
incl %edx
testb $0x1, %r8b
cmovel %edx, %eax
testb %dil, %dil
cmovel %edx, %eax
testb $0x1, %bpl
cmovel %edx, %eax
cmpw %cx, %r10w
movl 0xc(%rsp), %ecx
movw %cx, 0x6(%rbx)
movl 0x10(%rsp), %ecx
movw %cx, 0x16(%rbx)
cmovnel %edx, %eax
jmp 0x79a1
xorl %r12d, %r12d
cmpb $0x0, 0x8(%rsp)
movq 0x40(%rsp), %r11
movq 0x28(%rsp), %r15
movb $0x1, %al
je 0x7bf6
movl %eax, 0x24(%rsp)
movl %r12d, 0x14(%rsp)
movq 0x18(%rsp), %rax
movq (%rax), %r12
testq %r12, %r12
je 0x7c07
movzwl 0x24(%rbx), %r10d
addq $0x8, %r13
xorl %r11d, %r11d
movl $0x1, %r8d
xorl %ebp, %ebp
addq $0x20, %r12
xorl %r15d, %r15d
movq (%r12), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
testq %r9, %r9
je 0x7baa
xorl %r12d, %r12d
movq %r13, %rdi
movq %r9, %r14
cmpq %rax, %r14
movzbl %r12b, %r12d
cmovel %r8d, %r12d
movq (%rdi), %r14
addq $0x8, %rdi
testq %r14, %r14
jne 0x7b8e
testb %r12b, %r12b
jne 0x7bbb
incl %r15d
movq 0x18(%rax), %rax
movq 0x28(%rax), %r12
addq $0x18, %r12
jmp 0x7b74
cmpl %r10d, %r15d
jb 0x798f
movzbl %bpl, %ebp
cmovel %r8d, %ebp
movq 0x18(%rsp), %rax
movq 0x8(%rax,%r11,8), %r12
incq %r11
testq %r12, %r12
jne 0x7b6d
testb %bpl, %bpl
setne %r14b
movl 0x8(%rsp), %r8d
movq 0x40(%rsp), %r11
movq 0x28(%rsp), %r15
jmp 0x7c0f
movl %eax, 0x24(%rsp)
movb $0x1, %r14b
movl 0x8(%rsp), %r8d
jmp 0x7960
xorl %r14d, %r14d
movl 0x8(%rsp), %r8d
movl 0x14(%rsp), %r12d
jmp 0x7960
movl $0x0, 0x18(%rsp)
movb $0x1, %bpl
cmpb $0x0, 0x8(%rsp)
movl 0x14(%rsp), %r12d
je 0x7cdf
movq 0x38(%rsp), %rax
movq (%rax), %r13
testq %r13, %r13
je 0x7ce4
movzwl 0x24(%rbx), %eax
movl %eax, 0x8(%rsp)
addq $0x8, 0x30(%rsp)
xorl %r15d, %r15d
movl $0x1, %r8d
xorl %r12d, %r12d
addq $0x18, %r13
xorl %r9d, %r9d
movq (%r13), %rax
movq 0x28(%rax), %rax
movq 0x20(%rax), %r13
testq %r14, %r14
je 0x7c9b
xorl %eax, %eax
movq 0x30(%rsp), %rdi
movq %r14, %r11
cmpq %r13, %r11
movzbl %al, %eax
cmovel %r8d, %eax
movq (%rdi), %r11
addq $0x8, %rdi
testq %r11, %r11
jne 0x7c81
testb %al, %al
jne 0x7cac
incl %r9d
movq 0x20(%r13), %rax
movq 0x28(%rax), %r13
addq $0x20, %r13
jmp 0x7c66
cmpl 0x8(%rsp), %r9d
jb 0x798f
movzbl %r12b, %r12d
cmovel %r8d, %r12d
movq 0x38(%rsp), %rax
movq 0x8(%rax,%r15,8), %r13
incq %r15
testq %r13, %r13
jne 0x7c5f
testb %r12b, %r12b
setne %r8b
movl 0x14(%rsp), %r12d
jmp 0x7ce7
movb $0x1, %r8b
jmp 0x7ce7
xorl %r8d, %r8d
movl 0x28(%rsp), %r14d
movl 0x18(%rsp), %edi
jmp 0x7ad4