// File: /workspace/github_c_makefile_star2_O3/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
movq %rdi, %r13
movzwl 0x2(%rdi), %eax
leal -0x14(%rax), %ecx
shrl $0x1f, %ecx
leal (%rax,%rcx), %ebp
addl $-0x14, %ebp
testl %eax, %eax
je 0x3588
incq %rax
leaq 0xa4(%r13), %rcx
movl $0x1, %edx
xorl %esi, %esi
movw $0x0, (%rcx,%rsi)
movq $0x0, -0xc(%rcx,%rsi)
addq $0x30, %rsi
cmpq $0x90, %rsi
jne 0x355d
incq %rdx
addq $0x90, %rcx
cmpq %rax, %rdx
jne 0x355b
sarl %ebp
movl $0xffffffff, 0x8(%r14)  # imm = 0xFFFFFFFF
movq $-0x1, (%r14)
leaq 0x11cd0(%rip), %rbx     # 0x15270
xorl %r15d, %r15d
movq (%rbx), %rdi
movl %r15d, %esi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x2c42
movq (%rbx), %rcx
movw $0x1, 0x14(%rcx)
cmpq $0x3a, %r15
ja 0x35cd
incq %r15
addq $0x8, %rbx
testb %al, %al
je 0x35a3
testb %al, %al
movq %r13, 0x10(%rsp)
je 0x35e1
movl $0x3d, %r12d
movb $0x1, %r15b
jmp 0x361d
leaq 0x11c88(%rip), %rbx     # 0x15270
xorl %r12d, %r12d
movq %r12, %r15
leal 0x3d(%r12), %esi
movq (%rbx), %rdi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x2d87
incq %r12
cmpq $0x3a, %r15
ja 0x3611
addq $0x8, %rbx
testb %al, %al
je 0x35eb
addq $0x3d, %r12
testb %al, %al
setne %r15b
je 0x3640
cmpb $0x0, 0x11b6f(%rip)     # 0x15193
je 0x3754
leaq 0x20(%rsp), %r14
movl $0xffffffff, 0x8(%r14)  # imm = 0xFFFFFFFF
movq $-0x1, (%r14)
jmp 0x36bc
incl 0x11b42(%rip)           # 0x15188
leaq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0x33bc
movl %eax, %ebx
leaq 0x11df4(%rip), %rdi     # 0x15450
leaq 0xcca7(%rip), %rsi      # 0x1030a
callq 0x1120
testq %rax, %rax
je 0x3805
movq %rax, %r13
cmpb $0x0, 0x11be1(%rip)     # 0x1525c
jne 0x369a
movb $0x1, 0x11bd8(%rip)     # 0x1525c
leaq 0xcc6b(%rip), %rsi      # 0x102f6
movq %r13, %rdi
movl $0x6c, %edx
xorl %eax, %eax
callq 0x10b0
movslq %ebx, %rdx
leaq 0x30(%rsp), %rdi
movl $0x1, %esi
movq %r13, %rcx
callq 0x1180
movq %r13, %rdi
callq 0x1050
movq 0x10(%rsp), %r13
cmpw $0x0, 0x2(%r13)
je 0x3754
movb %r15b, 0xf(%rsp)
leaq 0x90(%r13), %rbx
movl $0x1, %edx
movq %rdx, 0x18(%rsp)
movq %rbx, %r13
xorl %r15d, %r15d
cmpw $0x0, 0x14(%r13)
je 0x36f0
xorl %eax, %eax
jmp 0x371a
movq %r13, %rdi
movl %r12d, %esi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x2c42
testb %al, %al
jne 0x3758
leal 0x1(%r12), %esi
movq %r13, %rdi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x2d87
addl $0x2, %r12d
cmpq $0x1, %r15
ja 0x372b
incq %r15
addq $0x30, %r13
testb %al, %al
je 0x36e4
movq 0x10(%rsp), %r13
movzwl 0x2(%r13), %ecx
movq 0x18(%rsp), %rdx
cmpq %rcx, %rdx
jae 0x374d
incq %rdx
addq $0x90, %rbx
testb %al, %al
je 0x36d9
testb %al, %al
setne %al
jmp 0x375f
xorl %eax, %eax
jmp 0x3767
movb $0x1, %al
movq 0x10(%rsp), %r13
movb 0xf(%rsp), %r15b
orb %al, %r15b
cmpb $0x0, 0x11a25(%rip)     # 0x15193
je 0x37e7
testb %al, %al
jne 0x37e7
incl 0x11a12(%rip)           # 0x1518c
leaq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0x33bc
movl %eax, %ebp
leaq 0x11d90(%rip), %rdi     # 0x15520
leaq 0xcb73(%rip), %rsi      # 0x1030a
callq 0x1120
testq %rax, %rax
je 0x3800
movq %rax, %rbx
cmpb $0x0, 0x11ab5(%rip)     # 0x15260
jne 0x37ca
movb $0x1, 0x11aac(%rip)     # 0x15260
leaq 0xcb3b(%rip), %rsi      # 0x102f6
movq %rbx, %rdi
movl $0x6c, %edx
xorl %eax, %eax
callq 0x10b0
movslq %ebp, %rdx
leaq 0x30(%rsp), %rdi
movl $0x1, %esi
movq %rbx, %rcx
callq 0x1180
movq %rbx, %rdi
callq 0x1050
andb $0x1, %r15b
movl %r15d, %eax
addq $0x998, %rsp            # imm = 0x998
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x124a
callq 0x1272