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

/* berechnet irgendeinen 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 zaehler, i,j, 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) && !gefunden; i++) 
  { gefunden= get_spiralcode ( F_eck_kanten[i], i, code, sixgons);
    (F_eck_kanten[i])->mininame=1; }

mark=61;

for (i=0; (i<60) && !gefunden; i++) 
  { gefunden= get_spiralcode_inv ( F_eck_kanten[i], mark, code, sixgons);
    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)
{
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) && !hexgefunden; i++) 
  for (j=0; j<3 && !hexgefunden; j++)
    if (!map[i][j].mininame) 
      { hexgefunden= get_spiralcode ( map[i]+j, mark, dummy, sixgons); mark++;
        if (!hexgefunden) 
	  { hexgefunden= get_spiralcode_inv ( map[i]+j, mark, dummy, sixgons); 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 $0x998, %rsp            # imm = 0x998
movq %rsi, %r14
movzwl 0x2(%rdi), %eax
leaq 0x1(%rax), %rcx
addl $-0x14, %eax
movq %rdi, 0x8(%rsp)
leaq 0xa4(%rdi), %rdx
pushq $0x1
popq %rsi
cmpq %rcx, %rsi
je 0x1bea
xorl %edi, %edi
cmpq $0x90, %rdi
je 0x1bde
andw $0x0, (%rdx,%rdi)
andq $0x0, -0xc(%rdx,%rdi)
addq $0x30, %rdi
jmp 0x1bc4
incq %rsi
addq $0x90, %rdx
jmp 0x1bbd
xorl %ecx, %ecx
cmpq $0xc, %rcx
je 0x1bfc
movb $-0x1, (%r14,%rcx)
incq %rcx
jmp 0x1bec
pushq $0x2
popq %rcx
cltd
idivl %ecx
movl %eax, %ebp
leaq 0x11645(%rip), %rbx     # 0x13250
xorl %r12d, %r12d
xorl %ecx, %ecx
cmpq $0x3b, %r12
ja 0x1c3e
testb %cl, %cl
jne 0x1c3e
movq (%rbx), %rdi
movl %r12d, %esi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x1398
movl %eax, %ecx
movq (%rbx), %rax
movw $0x1, 0x14(%rax)
incq %r12
addq $0x8, %rbx
jmp 0x1c10
leaq 0x1160b(%rip), %rbx     # 0x13250
xorl %r15d, %r15d
leaq 0x3d(%r15), %r12
cmpq $0x3b, %r15
ja 0x1c71
testb %cl, %cl
jne 0x1c71
movq (%rbx), %rdi
movl %r12d, %esi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x14be
movl %eax, %ecx
incq %r15
addq $0x8, %rbx
jmp 0x1c48
testb %cl, %cl
je 0x1ca0
cmpb $0x0, 0x114f7(%rip)     # 0x13173
je 0x1e3f
xorl %eax, %eax
leaq 0x24(%rsp), %r14
cmpq $0xc, %rax
je 0x1c99
movb $-0x1, 0x24(%rsp,%rax)
incq %rax
jmp 0x1c89
movq %rcx, 0x10(%rsp)
jmp 0x1d1a
movq %rcx, 0x10(%rsp)
incl 0x114bd(%rip)           # 0x13168
leaq 0x30(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x1a6a
movl %eax, %ebx
leaq 0x1176d(%rip), %rdi     # 0x13430
leaq 0xc5d4(%rip), %rsi      # 0xe29e
callq 0x10f0
testq %rax, %rax
je 0x1e78
movq %rax, %r13
cmpb $0x0, 0x1155a(%rip)     # 0x1323c
jne 0x1cff
movb $0x1, 0x11551(%rip)     # 0x1323c
leaq 0xc598(%rip), %rsi      # 0xe28a
pushq $0x6c
popq %rdx
movq %r13, %rdi
xorl %eax, %eax
callq 0x10a0
movslq %ebx, %rdx
leaq 0x30(%rsp), %rdi
pushq $0x1
popq %rsi
movq %r13, %rcx
callq 0x1150
movq %r13, %rdi
callq 0x1050
movq 0x8(%rsp), %rax
leaq 0x90(%rax), %r13
pushq $0x1
popq %r15
xorl %eax, %eax
movq 0x8(%rsp), %rcx
movzwl 0x2(%rcx), %ecx
cmpq %rcx, %r15
ja 0x1daa
testb %al, %al
jne 0x1daa
xorl %ebx, %ebx
movq %r13, 0x18(%rsp)
xorl %eax, %eax
cmpq $0x2, %rbx
ja 0x1d99
testb %al, %al
jne 0x1d99
cmpw $0x0, 0x14(%r13)
je 0x1d5d
xorl %eax, %eax
jmp 0x1d90
movq %r13, %rdi
movl %r12d, %esi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x1398
movl %eax, %ecx
leal 0x1(%r12), %esi
movb $0x1, %al
testb %cl, %cl
je 0x1d7f
movl %esi, %r12d
jmp 0x1d90
movq %r13, %rdi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x14be
addl $0x2, %r12d
incq %rbx
addq $0x30, %r13
jmp 0x1d47
incq %r15
movq 0x18(%rsp), %r13
addq $0x90, %r13
jmp 0x1d2c
testb %al, %al
setne %r14b
cmpb $0x0, 0x113bc(%rip)     # 0x13173
movq 0x10(%rsp), %rcx
je 0x1e42
testb %al, %al
jne 0x1e42
movq %rcx, %r15
incl 0x1139d(%rip)           # 0x1316c
leaq 0x30(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x1a6a
movl %eax, %ebp
leaq 0x11719(%rip), %rdi     # 0x13500
leaq 0xc4b0(%rip), %rsi      # 0xe29e
callq 0x10f0
testq %rax, %rax
je 0x1e5e
movq %rax, %rbx
cmpb $0x0, 0x1143e(%rip)     # 0x13240
jne 0x1e1f
movb $0x1, 0x11435(%rip)     # 0x13240
leaq 0xc478(%rip), %rsi      # 0xe28a
pushq $0x6c
popq %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10a0
movslq %ebp, %rdx
leaq 0x30(%rsp), %rdi
pushq $0x1
popq %rsi
movq %rbx, %rcx
callq 0x1150
movq %rbx, %rdi
callq 0x1050
movq %r15, %rcx
jmp 0x1e42
xorl %r14d, %r14d
testb %cl, %cl
setne %al
orb %r14b, %al
andb $0x1, %al
addq $0x998, %rsp            # imm = 0x998
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x11193(%rip), %rax     # 0x12ff8
movq (%rax), %rdi
leaq 0xc432(%rip), %rsi      # 0xe2a1
leaq 0x1168a(%rip), %rdx     # 0x13500
jmp 0x1e90
movq 0x11179(%rip), %rax     # 0x12ff8
movq (%rax), %rdi
leaq 0xc418(%rip), %rsi      # 0xe2a1
leaq 0x115a0(%rip), %rdx     # 0x13430
xorl %eax, %eax
callq 0x10a0
pushq $0x1
popq %rdi
callq 0x1140