// File: /workspace/github_c_makefile_star2_O2/mishun[P]plantri/fullgen.c
// Function: minspiralcode
BOOL minspiralcode(PLANMAP map, FLAECHENTYP code[12])

/* berechnet den minimalen Spiralcode von map und schreibt ihn in code.
   Gibt 1 zurueck, wenn der gefunden wurde und 0 sonst. versucht zuerst
   einen Code zu finden, der an einem 5-Eck startet. */

{ int i,j, zaehler, mark, sixgons;
  BOOL gefunden=0, hexgefunden=0;
  FLAECHENTYP codeF[2*(81+8*S)];
  FILE *fil2;
  FLAECHENTYP dummycode[12];
  FLAECHENTYP *dummy;
  static int write_nopentaheader=1, write_nohexaheader=1;


/*schreibemap(map);*/

sixgons= (map[0][0].name - 20)/2;

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



for (i=0; (i<60); i++) 
  { if (get_spiralcode ( F_eck_kanten[i], i, code, sixgons)) gefunden=1;
    (F_eck_kanten[i])->mininame=1; }

mark=61;

for (i=0; (i<60); i++) 
  { if (get_spiralcode_inv ( F_eck_kanten[i], mark, code, sixgons)) gefunden=1;
    mark++; }


if (!gefunden) { no_penta_spiral++;
		 zaehler=longcode(map,codeF);
		fil2=fopen(no_penta_spiral_filename,"ab");
		if (fil2==NULL) { fprintf(stderr,"Can't open %s\n",no_penta_spiral_filename);
		                  exit(1); }
		if (write_nopentaheader)
		  { write_nopentaheader=0;
		  fprintf(fil2,">>planar_code %ce<<", my_endianness);
		  }
		fwrite(codeF,sizeof(FLAECHENTYP),zaehler,fil2);
		fclose(fil2);
	       }


if (!gefunden || hexspi) /* sonst waeren die neuen codes eh alle groesser */
{
if (!gefunden) dummy=code; else
  { for (i=0; i<12; i++) dummycode[i]=FL_MAX; dummy=dummycode; }
for (i=1; (i<=map[0][0].name); i++) 
  for (j=0; j<3 ; j++)
    if (!map[i][j].mininame) 
      { if (get_spiralcode ( map[i]+j, mark, dummy, sixgons)) hexgefunden=1; mark++; 
	if (get_spiralcode_inv ( map[i]+j, mark, dummy, sixgons)) hexgefunden=1; mark++; 
      }
}

if (hexspi && !hexgefunden) { no_hexa_spiral++;
		 zaehler=longcode(map,codeF);
		fil2=fopen(no_hexa_spiral_filename,"ab");
		if (fil2==NULL) { fprintf(stderr,"Can't open %s\n",no_hexa_spiral_filename);
		                  exit(1); }
		if (write_nohexaheader)
		  { write_nohexaheader=0;
		  fprintf(fil2,">>planar_code %ce<<", my_endianness);
		  }
		fwrite(codeF,sizeof(FLAECHENTYP),zaehler,fil2);
		fclose(fil2);
	       }


return(gefunden || hexgefunden);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x9a8, %rsp            # imm = 0x9A8
movq %rsi, 0x8(%rsp)
movzwl 0x2(%rdi), %eax
leaq 0x1(%rax), %rcx
addl $-0x14, %eax
movq %rdi, 0x18(%rsp)
leaq 0xa4(%rdi), %rdx
pushq $0x1
popq %rsi
cmpq %rcx, %rsi
je 0x1efc
xorl %edi, %edi
cmpq $0x90, %rdi
je 0x1ef0
andw $0x0, (%rdx,%rdi)
andq $0x0, -0xc(%rdx,%rdi)
addq $0x30, %rdi
jmp 0x1ed6
incq %rsi
addq $0x90, %rdx
jmp 0x1ecf
xorl %ecx, %ecx
movq 0x8(%rsp), %rdx
cmpq $0xc, %rcx
je 0x1f12
movb $-0x1, (%rdx,%rcx)
incq %rcx
jmp 0x1f03
pushq $0x2
popq %rcx
cltd
idivl %ecx
movl %eax, 0x4(%rsp)
leaq 0x1132d(%rip), %rbx     # 0x13250
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpq $0x3c, %r15
je 0x1f62
movq (%rbx), %rdi
movl %r15d, %esi
movq 0x8(%rsp), %rdx
movl 0x4(%rsp), %ecx
callq 0x1398
testb %al, %al
movzbl %r12b, %r12d
pushq $0x1
popq %rax
cmovnel %eax, %r12d
movq (%rbx), %rax
movw $0x1, 0x14(%rax)
incq %r15
addq $0x8, %rbx
jmp 0x1f29
pushq $0x3d
popq %r15
xorl %ebx, %ebx
leaq 0x112e1(%rip), %r14     # 0x13250
cmpq $0x1e0, %rbx            # imm = 0x1E0
je 0x1fa3
movq (%rbx,%r14), %rdi
movl %r15d, %esi
movq 0x8(%rsp), %rdx
movl 0x4(%rsp), %ecx
callq 0x14be
testb %al, %al
movzbl %r12b, %r12d
pushq $0x1
popq %rax
cmovnel %eax, %r12d
incl %r15d
addq $0x8, %rbx
jmp 0x1f6f
testb %r12b, %r12b
movl %r12d, 0x14(%rsp)
je 0x1fda
cmpb $0x0, 0x111bf(%rip)     # 0x13173
je 0x218b
xorl %eax, %eax
leaq 0x34(%rsp), %rcx
movq %rcx, 0x8(%rsp)
cmpq $0xc, %rax
je 0x2055
movb $-0x1, 0x34(%rsp,%rax)
incq %rax
jmp 0x1fc6
incl 0x11188(%rip)           # 0x13168
leaq 0x40(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x1a6a
movl %eax, %r12d
leaq 0x11437(%rip), %rdi     # 0x13430
leaq 0xc29e(%rip), %rsi      # 0xe29e
callq 0x10f0
testq %rax, %rax
je 0x21c5
movq %rax, %r15
cmpb $0x0, 0x115b0(%rip)     # 0x135c8
jne 0x2035
movb $0x1, 0x115a7(%rip)     # 0x135c8
leaq 0xc262(%rip), %rsi      # 0xe28a
pushq $0x6c
popq %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0x10a0
movslq %r12d, %rdx
leaq 0x40(%rsp), %rdi
pushq $0x1
popq %rsi
movq %r15, %rcx
callq 0x1150
movq %r15, %rdi
callq 0x1050
movl 0x14(%rsp), %r12d
movq 0x18(%rsp), %rax
leaq 0x90(%rax), %rdx
pushq $0x79
popq %r13
pushq $0x1
popq %rsi
xorl %ecx, %ecx
movq 0x8(%rsp), %rbp
movl 0x4(%rsp), %ebx
movq 0x18(%rsp), %rax
movzwl 0x2(%rax), %eax
cmpq %rax, %rsi
ja 0x2105
movq %rsi, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
movq %rdx, %r12
pushq $0x3
popq %r14
subq $0x1, %r14
jb 0x20e7
cmpw $0x0, 0x14(%r12)
jne 0x20e1
movq %r12, %rdi
movl %r13d, %esi
movq %rbp, %rdx
movl %ecx, %r15d
movl %ebx, %ecx
callq 0x1398
movb %al, 0x3(%rsp)
leal 0x1(%r13), %esi
movq %r12, %rdi
movq %rbp, %rdx
movl %ebx, %ecx
callq 0x14be
movl %r15d, %ecx
orb 0x3(%rsp), %al
movzbl %cl, %ecx
pushq $0x1
popq %rax
cmovnel %eax, %ecx
addl $0x2, %r13d
addq $0x30, %r12
jmp 0x2096
movq 0x20(%rsp), %rsi
incq %rsi
movq 0x28(%rsp), %rdx
addq $0x90, %rdx
movl 0x14(%rsp), %r12d
jmp 0x2073
testb %cl, %cl
setne %r15b
cmpb $0x0, 0x11061(%rip)     # 0x13173
je 0x218e
testb %cl, %cl
jne 0x218e
incl 0x1104e(%rip)           # 0x1316c
leaq 0x40(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x1a6a
movl %eax, %ebp
leaq 0x113ca(%rip), %rdi     # 0x13500
leaq 0xc161(%rip), %rsi      # 0xe29e
callq 0x10f0
testq %rax, %rax
je 0x21ab
movq %rax, %r14
cmpb $0x0, 0x1147b(%rip)     # 0x135cc
jne 0x216e
movb $0x1, 0x11472(%rip)     # 0x135cc
leaq 0xc129(%rip), %rsi      # 0xe28a
pushq $0x6c
popq %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x10a0
movslq %ebp, %rdx
leaq 0x40(%rsp), %rdi
pushq $0x1
popq %rsi
movq %r14, %rcx
callq 0x1150
movq %r14, %rdi
callq 0x1050
jmp 0x218e
xorl %r15d, %r15d
testb %r12b, %r12b
setne %al
orb %r15b, %al
andb $0x1, %al
addq $0x9a8, %rsp            # imm = 0x9A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10e46(%rip), %rax     # 0x12ff8
movq (%rax), %rdi
leaq 0xc0e5(%rip), %rsi      # 0xe2a1
leaq 0x1133d(%rip), %rdx     # 0x13500
jmp 0x21dd
movq 0x10e2c(%rip), %rax     # 0x12ff8
movq (%rax), %rdi
leaq 0xc0cb(%rip), %rsi      # 0xe2a1
leaq 0x11253(%rip), %rdx     # 0x13430
xorl %eax, %eax
callq 0x10a0
pushq $0x1
popq %rdi
callq 0x1140