// File: /workspace/github_c_makefile_star2_O2/mishun[P]plantri/fullgen.c
// Function: codiere
int codiere(PLANMAP map, FLAECHENTYP *code, KANTE *start, int codesize, int laenge)
{
int i, j, stelle, zaehler, knotenzahl, flaechennumber, verschiebung, merkeknoten;
/* zaehler zaehlt die Flaechengroesse, knotenzahl die zahl der restlichen knoten */
int tempknz, laufzaehler, autozaehler, minitest;
KANTE *run, *merke, *run2;
FLAECHENTYP testcode[9];


if (start->name != aussen) { fprintf(stderr,"Codiere must start at external edge !\n"); 
			     exit(8); }

tempknz=map[0][0].name;

if (tempknz==5) { code[0]=1; return(1); }

for (i=1; i<=tempknz; i++) for (j=0; j<3; j++)
  if (map[i][j].name == aussen) map[i][j].dummy= infty; else map[i][j].dummy=0;

run=start; stelle=0; knotenzahl=tempknz;

if (laenge) /* d.h. 6-Fuenfecke-patch */
  { verschiebung=0;
    code[2]=unbelegt; 
    code[0]=0; /*code[1]=verschiebung;*/ stelle=2; 
    merkeknoten=knotenzahl;
    laufzaehler=1;
    /* Jetzt den minimalen Code ausrechnen: */
    for ( autozaehler=0, run2=start->prev; 
	 (verschiebung<laenge) && !autozaehler; verschiebung++, run2=run2->prev->invers->next->invers)
      if (checksize(run2)==5)
	{
	  laufzaehler++;
	  run=run2->next;
	  stelle=2; knotenzahl=merkeknoten;
	  flaechennumber=0;
	  while (stelle<codesize)
	    { flaechennumber++;
	      zaehler=2;
	      while (run->prev->invers->prev->dummy>=laufzaehler) 
		                                     run=run->prev->invers->prev; /* sicherstellen, dass davor
										     keine aussenkanten sind */
	      run->prev->invers->dummy=laufzaehler; run->next->invers->dummy=laufzaehler;
	      run=run->next->invers->next; knotenzahl--;
	      while (run->dummy>=laufzaehler)
		{ zaehler++; knotenzahl--; run->prev->invers->dummy=laufzaehler; 
		  run->next->invers->dummy=laufzaehler;
		  run=run->next->invers->next; }
	      merke=run->next;
	      run=run->prev;
	      while (merke->dummy<laufzaehler)
		{ zaehler++; merke=merke->invers->prev; }
	      if (zaehler==5) { testcode[stelle]=flaechennumber; stelle++; }
	      else if (zaehler!=6) { fprintf(stderr,"ERROR in CODIERE: No 5- or 6-Gon !\n"); exit(9); }
	      if (knotenzahl==5) { testcode[stelle]=flaechennumber+1; stelle++; }
	    } /* ende while */
	  if ((minitest=codecmp(code+2,testcode+2,6))>0) 
	    { if (verschiebung) return(0);
	      else { for (stelle=2; stelle<8; stelle++) code[stelle]=testcode[stelle]; }
	    }
	  if (minitest==0) autozaehler=1; /* verschiebung>=1 ist automatisch */
	} /* ende checksize==5 */
    if (autozaehler) code[1]=verschiebung-1;
    else code[1]=laenge;
    return(1);
  } /* ende if */



 flaechennumber=0;



while (stelle<codesize)
  { flaechennumber++;
    zaehler=2;
    while (run->prev->invers->prev->dummy) run=run->prev->invers->prev; /* sicherstellen, dass davor
									   keine aussenkanten sind */
    run->prev->invers->dummy=1; run->next->invers->dummy=1;
    run=run->next->invers->next; knotenzahl--;
    while (run->dummy)
      { zaehler++; knotenzahl--; run->prev->invers->dummy=1; run->next->invers->dummy=1;
	run=run->next->invers->next; }
    merke=run->next;
    run=run->prev;
    while (!(merke->dummy))
      { zaehler++; merke=merke->invers->prev; }
    if (zaehler==5) { code[stelle]=flaechennumber; stelle++; }
    else if (zaehler!=6) { fprintf(stderr,"ERROR in CODIERE(2): No 5- or 6-Gon !\n"); exit(10); }
    if (knotenzahl==5) { code[stelle]=flaechennumber+1; stelle++; }
  } /* ende while */

return(1);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, 0xc(%rsp)
cmpw $0x246, 0x2(%rdx)       # imm = 0x246
jne 0x374e
movq %rsi, %rbx
movzwl 0x2(%rdi), %r13d
cmpl $0x5, %r13d
jne 0x346e
movb $0x1, (%rbx)
jmp 0x36f4
movl %ecx, %ebp
pushq $0x1
popq %rax
leaq 0x1(%r13), %rcx
addq $0x98, %rdi
movabsq $0x7fffffffffffffff, %rsi # imm = 0x7FFFFFFFFFFFFFFF
cmpq %rcx, %rax
je 0x34c1
xorl %r8d, %r8d
cmpq $0x90, %r8
je 0x34b5
cmpw $0x246, -0x6(%rdi,%r8)  # imm = 0x246
movl $0x0, %r9d
cmoveq %rsi, %r9
movq %r9, (%rdi,%r8)
addq $0x30, %r8
jmp 0x3490
incq %rax
addq $0x90, %rdi
jmp 0x3488
cmpl $0x0, 0xc(%rsp)
je 0x363d
leaq 0x2(%rbx), %rax
movq %rax, 0x20(%rsp)
movb $-0x1, 0x2(%rbx)
movb $0x0, (%rbx)
addq $0x18, %rdx
pushq $0x1
popq %rax
movl %eax, 0x10(%rsp)
xorl %r15d, %r15d
pushq $0x2
popq %r14
xorl %ecx, %ecx
cmpl 0xc(%rsp), %r15d
jge 0x3629
testl %ecx, %ecx
jne 0x3629
movq (%rdx), %r12
movq %r12, %rdi
callq 0x3424
xorl %ecx, %ecx
cmpl $0x5, %eax
jne 0x3610
movl 0x10(%rsp), %eax
incl %eax
movq 0x20(%r12), %rdi
movl %eax, 0x10(%rsp)
cltq
xorl %r9d, %r9d
movl %r14d, %ecx
movl %r13d, %edx
cmpl %ebp, %ecx
jge 0x35d5
movl %r9d, %esi
movq %rdi, %r9
movq 0x18(%rdi), %rdi
movq 0x28(%rdi), %r10
movq 0x18(%r10), %rdi
cmpq %rax, 0x8(%rdi)
jge 0x353e
decl %edx
movl %r14d, %r8d
movq %rax, 0x8(%r10)
movq 0x20(%r9), %rdi
movq 0x28(%rdi), %rdi
movq %rax, 0x8(%rdi)
movq 0x20(%rdi), %r9
movq 0x18(%r9), %rdi
cmpq %rax, 0x8(%r9)
jl 0x3581
incl %r8d
movq 0x28(%rdi), %r10
decl %edx
jmp 0x3558
addq $0x20, %r9
movq (%r9), %r9
cmpq %rax, 0x8(%r9)
jge 0x359b
incl %r8d
movq 0x28(%r9), %r9
addq $0x18, %r9
jmp 0x3585
leal 0x1(%rsi), %r9d
cmpl $0x6, %r8d
je 0x35b9
cmpl $0x5, %r8d
jne 0x370a
movslq %ecx, %r8
movb %r9b, 0x17(%rsp,%r8)
incl %ecx
cmpl $0x5, %edx
jne 0x3533
addb $0x2, %sil
movslq %ecx, %rcx
movb %sil, 0x17(%rsp,%rcx)
incl %ecx
jmp 0x3533
movq 0x20(%rsp), %rdi
leaq 0x19(%rsp), %rsi
pushq $0x6
popq %rdx
callq 0x2357
testl %eax, %eax
jle 0x3609
testl %r15d, %r15d
jne 0x3706
pushq $0x2
popq %rcx
cmpq $0x8, %rcx
je 0x3609
movb 0x17(%rsp,%rcx), %dl
movb %dl, (%rbx,%rcx)
incq %rcx
jmp 0x35f7
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
incl %r15d
movq 0x18(%r12), %rax
movq 0x28(%rax), %rax
movq 0x20(%rax), %rdx
addq $0x28, %rdx
jmp 0x34f0
testl %ecx, %ecx
je 0x36ed
decb %r15b
movb %r15b, 0x1(%rbx)
jmp 0x36f4
xorl %ecx, %ecx
pushq $0x1
popq %rax
pushq $0x2
popq %rsi
pushq $0x1
popq %rdi
xorl %r10d, %r10d
cmpl %ebp, %ecx
jge 0x36f7
movl %r10d, %r8d
movq %rdx, %r10
movq 0x18(%rdx), %rdx
movq 0x28(%rdx), %r11
movq 0x18(%r11), %rdx
cmpq $0x0, 0x8(%rdx)
jne 0x3656
decl %r13d
movl %esi, %r9d
movq %rdi, 0x8(%r11)
movq 0x20(%r10), %rdx
movq 0x28(%rdx), %rdx
movq %rdi, 0x8(%rdx)
movq 0x20(%rdx), %r10
cmpq $0x0, 0x8(%r10)
movq 0x18(%r10), %rdx
je 0x369d
incl %r9d
movq 0x28(%rdx), %r11
decl %r13d
jmp 0x3672
addq $0x20, %r10
movq (%r10), %r10
cmpq $0x0, 0x8(%r10)
jne 0x36b8
incl %r9d
movq 0x28(%r10), %r10
addq $0x18, %r10
jmp 0x36a1
leal 0x1(%r8), %r10d
cmpl $0x6, %r9d
je 0x36d1
cmpl $0x5, %r9d
jne 0x372e
movslq %ecx, %r9
movb %r10b, (%rbx,%r9)
incl %ecx
cmpl $0x5, %r13d
jne 0x364b
addb $0x2, %r8b
movslq %ecx, %rcx
movb %r8b, (%rbx,%rcx)
incl %ecx
jmp 0x364b
movl 0xc(%rsp), %eax
movb %al, 0x1(%rbx)
pushq $0x1
popq %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x36f7
movq 0xf8e7(%rip), %rax      # 0x12ff8
movq (%rax), %rcx
leaq 0xace8(%rip), %rdi      # 0xe403
pushq $0x23
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
pushq $0x9
popq %rdi
callq 0x1140
movq 0xf8c3(%rip), %rax      # 0x12ff8
movq (%rax), %rcx
leaq 0xace8(%rip), %rdi      # 0xe427
pushq $0x26
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
pushq $0xa
jmp 0x3728
movq 0xf8a3(%rip), %rax      # 0x12ff8
movq (%rax), %rcx
leaq 0xac7d(%rip), %rdi      # 0xe3dc
pushq $0x26
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
pushq $0x8
jmp 0x3728