// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x9c0, %rsp            # imm = 0x9C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x25(%rbp)
movb $0x0, -0x26(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x2(%rax), %eax
subl $0x14, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x24(%rbp)
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
movzwl 0x2(%rcx), %ecx
cmpl %ecx, %eax
jg 0x2434
movl $0x0, -0x1c(%rbp)
cmpl $0x3, -0x1c(%rbp)
jge 0x2427
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movw $0x0, 0x14(%rax)
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x23ce
jmp 0x2429
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x23b8
movl $0x0, -0x18(%rbp)
cmpl $0xc, -0x18(%rbp)
jge 0x2458
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $-0x1, (%rax,%rcx)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x243b
movl $0x0, -0x18(%rbp)
xorl %eax, %eax
cmpl $0x3c, -0x18(%rbp)
movb %al, -0x9b1(%rbp)
jge 0x247c
cmpb $0x0, -0x25(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0x9b1(%rbp)
movb -0x9b1(%rbp), %al
testb $0x1, %al
jne 0x2488
jmp 0x24c9
movslq -0x18(%rbp), %rcx
leaq 0x19dbd(%rip), %rax     # 0x1c250
movq (%rax,%rcx,8), %rdi
movl -0x18(%rbp), %esi
movq -0x10(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x14e0
movb %al, -0x25(%rbp)
movslq -0x18(%rbp), %rcx
leaq 0x19d9c(%rip), %rax     # 0x1c250
movq (%rax,%rcx,8), %rax
movw $0x1, 0x14(%rax)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x245f
movl $0x3d, -0x20(%rbp)
movl $0x0, -0x18(%rbp)
xorl %eax, %eax
cmpl $0x3c, -0x18(%rbp)
movb %al, -0x9b2(%rbp)
jge 0x24f4
cmpb $0x0, -0x25(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0x9b2(%rbp)
movb -0x9b2(%rbp), %al
testb $0x1, %al
jne 0x2500
jmp 0x2535
movslq -0x18(%rbp), %rcx
leaq 0x19d45(%rip), %rax     # 0x1c250
movq (%rax,%rcx,8), %rdi
movl -0x20(%rbp), %esi
movq -0x10(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x16e0
movb %al, -0x25(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x24d7
cmpb $0x0, -0x25(%rbp)
jne 0x2605
movl 0x19c33(%rip), %eax     # 0x1c178
addl $0x1, %eax
movl %eax, 0x19c2a(%rip)     # 0x1c178
movq -0x8(%rbp), %rdi
leaq -0x990(%rbp), %rsi
callq 0x2120
movl %eax, -0x14(%rbp)
leaq 0x19ec8(%rip), %rdi     # 0x1c430
leaq 0x15f5f(%rip), %rsi     # 0x184ce
callq 0x10d0
movq %rax, -0x998(%rbp)
cmpq $0x0, -0x998(%rbp)
jne 0x25ae
movq 0x19a6c(%rip), %rax     # 0x1bff8
movq (%rax), %rdi
leaq 0x15f3b(%rip), %rsi     # 0x184d1
leaq 0x19e93(%rip), %rdx     # 0x1c430
movb $0x0, %al
callq 0x1080
movl $0x1, %edi
callq 0x1120
cmpl $0x0, 0x19b8f(%rip)     # 0x1c144
je 0x25dd
movl $0x0, 0x19b83(%rip)     # 0x1c144
movq -0x998(%rbp), %rdi
movsbl 0x19b71(%rip), %edx     # 0x1c140
leaq 0x15ee4(%rip), %rsi     # 0x184ba
movb $0x0, %al
callq 0x1080
leaq -0x990(%rbp), %rdi
movslq -0x14(%rbp), %rdx
movq -0x998(%rbp), %rcx
movl $0x1, %esi
callq 0x1130
movq -0x998(%rbp), %rdi
callq 0x1050
cmpb $0x0, -0x25(%rbp)
je 0x261b
movsbl 0x19b71(%rip), %eax     # 0x1c183
cmpl $0x0, %eax
je 0x2793
cmpb $0x0, -0x25(%rbp)
jne 0x262e
movq -0x10(%rbp), %rax
movq %rax, -0x9b0(%rbp)
jmp 0x2660
movl $0x0, -0x18(%rbp)
cmpl $0xc, -0x18(%rbp)
jge 0x2652
movslq -0x18(%rbp), %rax
movb $-0x1, -0x9a4(%rbp,%rax)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2635
leaq -0x9a4(%rbp), %rax
movq %rax, -0x9b0(%rbp)
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %ecx
movq -0x8(%rbp), %rax
movzwl 0x2(%rax), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x9b3(%rbp)
jg 0x268d
cmpb $0x0, -0x26(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0x9b3(%rbp)
movb -0x9b3(%rbp), %al
testb $0x1, %al
jne 0x269c
jmp 0x2791
movl $0x0, -0x1c(%rbp)
xorl %eax, %eax
cmpl $0x3, -0x1c(%rbp)
movb %al, -0x9b4(%rbp)
jge 0x26c0
cmpb $0x0, -0x26(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0x9b4(%rbp)
movb -0x9b4(%rbp), %al
testb $0x1, %al
jne 0x26cf
jmp 0x2781
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
cmpw $0x0, 0x14(%rax)
jne 0x2771
movq -0x8(%rbp), %rdi
movslq -0x18(%rbp), %rax
imulq $0x90, %rax, %rax
addq %rax, %rdi
movslq -0x1c(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movl -0x20(%rbp), %esi
movq -0x9b0(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x14e0
movb %al, -0x26(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpb $0x0, -0x26(%rbp)
jne 0x276f
movq -0x8(%rbp), %rdi
movslq -0x18(%rbp), %rax
imulq $0x90, %rax, %rax
addq %rax, %rdi
movslq -0x1c(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movl -0x20(%rbp), %esi
movq -0x9b0(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x16e0
movb %al, -0x26(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x2771
jmp 0x2773
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x26a3
jmp 0x2783
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2667
jmp 0x2793
movsbl 0x199e9(%rip), %eax     # 0x1c183
cmpl $0x0, %eax
je 0x2873
cmpb $0x0, -0x26(%rbp)
jne 0x2873
movl 0x199c9(%rip), %eax     # 0x1c17c
addl $0x1, %eax
movl %eax, 0x199c0(%rip)     # 0x1c17c
movq -0x8(%rbp), %rdi
leaq -0x990(%rbp), %rsi
callq 0x2120
movl %eax, -0x14(%rbp)
leaq 0x19d2a(%rip), %rdi     # 0x1c500
leaq 0x15cf1(%rip), %rsi     # 0x184ce
callq 0x10d0
movq %rax, -0x998(%rbp)
cmpq $0x0, -0x998(%rbp)
jne 0x281c
movq 0x197fe(%rip), %rax     # 0x1bff8
movq (%rax), %rdi
leaq 0x15ccd(%rip), %rsi     # 0x184d1
leaq 0x19cf5(%rip), %rdx     # 0x1c500
movb $0x0, %al
callq 0x1080
movl $0x1, %edi
callq 0x1120
cmpl $0x0, 0x19925(%rip)     # 0x1c148
je 0x284b
movl $0x0, 0x19919(%rip)     # 0x1c148
movq -0x998(%rbp), %rdi
movsbl 0x19903(%rip), %edx     # 0x1c140
leaq 0x15c76(%rip), %rsi     # 0x184ba
movb $0x0, %al
callq 0x1080
leaq -0x990(%rbp), %rdi
movslq -0x14(%rbp), %rdx
movq -0x998(%rbp), %rcx
movl $0x1, %esi
callq 0x1130
movq -0x998(%rbp), %rdi
callq 0x1050
movsbl -0x25(%rbp), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x9b5(%rbp)
jne 0x2894
movsbl -0x26(%rbp), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x9b5(%rbp)
movb -0x9b5(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
addq $0x9c0, %rsp            # imm = 0x9C0
popq %rbp
retq
nopl (%rax,%rax)