// File: /workspace/github_c_makefile_star2_O0/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
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, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
movzwl 0x2(%rcx), %ecx
cmpl %ecx, %eax
jg 0x2964
movl $0x0, -0x18(%rbp)
cmpl $0x3, -0x18(%rbp)
jge 0x2957
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movw $0x0, 0x14(%rax)
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x28fe
jmp 0x2959
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x28e8
movl $0x0, -0x14(%rbp)
cmpl $0xc, -0x14(%rbp)
jge 0x2988
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb $-0x1, (%rax,%rcx)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x296b
movl $0x0, -0x14(%rbp)
cmpl $0x3c, -0x14(%rbp)
jge 0x29db
movslq -0x14(%rbp), %rcx
leaq 0x198b0(%rip), %rax     # 0x1c250
movq (%rax,%rcx,8), %rdi
movl -0x14(%rbp), %esi
movq -0x10(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x14e0
cmpb $0x0, %al
je 0x29bb
movb $0x1, -0x25(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0x1988a(%rip), %rax     # 0x1c250
movq (%rax,%rcx,8), %rax
movw $0x1, 0x14(%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x298f
movl $0x3d, -0x20(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x3c, -0x14(%rbp)
jge 0x2a29
movslq -0x14(%rbp), %rcx
leaq 0x19856(%rip), %rax     # 0x1c250
movq (%rax,%rcx,8), %rdi
movl -0x20(%rbp), %esi
movq -0x10(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x16e0
cmpb $0x0, %al
je 0x2a15
movb $0x1, -0x25(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x29e9
cmpb $0x0, -0x25(%rbp)
jne 0x2af9
movl 0x1973f(%rip), %eax     # 0x1c178
addl $0x1, %eax
movl %eax, 0x19736(%rip)     # 0x1c178
movq -0x8(%rbp), %rdi
leaq -0x990(%rbp), %rsi
callq 0x2120
movl %eax, -0x1c(%rbp)
leaq 0x199d4(%rip), %rdi     # 0x1c430
leaq 0x15a6b(%rip), %rsi     # 0x184ce
callq 0x10d0
movq %rax, -0x998(%rbp)
cmpq $0x0, -0x998(%rbp)
jne 0x2aa2
movq 0x19578(%rip), %rax     # 0x1bff8
movq (%rax), %rdi
leaq 0x15a47(%rip), %rsi     # 0x184d1
leaq 0x1999f(%rip), %rdx     # 0x1c430
movb $0x0, %al
callq 0x1080
movl $0x1, %edi
callq 0x1120
cmpl $0x0, 0x196a3(%rip)     # 0x1c14c
je 0x2ad1
movl $0x0, 0x19697(%rip)     # 0x1c14c
movq -0x998(%rbp), %rdi
movsbl 0x1967d(%rip), %edx     # 0x1c140
leaq 0x159f0(%rip), %rsi     # 0x184ba
movb $0x0, %al
callq 0x1080
leaq -0x990(%rbp), %rdi
movslq -0x1c(%rbp), %rdx
movq -0x998(%rbp), %rcx
movl $0x1, %esi
callq 0x1130
movq -0x998(%rbp), %rdi
callq 0x1050
cmpb $0x0, -0x25(%rbp)
je 0x2b0f
movsbl 0x1967d(%rip), %eax     # 0x1c183
cmpl $0x0, %eax
je 0x2c49
cmpb $0x0, -0x25(%rbp)
jne 0x2b22
movq -0x10(%rbp), %rax
movq %rax, -0x9b0(%rbp)
jmp 0x2b54
movl $0x0, -0x14(%rbp)
cmpl $0xc, -0x14(%rbp)
jge 0x2b46
movslq -0x14(%rbp), %rax
movb $-0x1, -0x9a4(%rbp,%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2b29
leaq -0x9a4(%rbp), %rax
movq %rax, -0x9b0(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
movzwl 0x2(%rcx), %ecx
cmpl %ecx, %eax
jg 0x2c47
movl $0x0, -0x18(%rbp)
cmpl $0x3, -0x18(%rbp)
jge 0x2c37
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
cmpw $0x0, 0x14(%rax)
jne 0x2c27
movq -0x8(%rbp), %rdi
movslq -0x14(%rbp), %rax
imulq $0x90, %rax, %rax
addq %rax, %rdi
movslq -0x18(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movl -0x20(%rbp), %esi
movq -0x9b0(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x14e0
cmpb $0x0, %al
je 0x2bde
movb $0x1, -0x26(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movslq -0x14(%rbp), %rax
imulq $0x90, %rax, %rax
addq %rax, %rdi
movslq -0x18(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movl -0x20(%rbp), %esi
movq -0x9b0(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x16e0
cmpb $0x0, %al
je 0x2c1e
movb $0x1, -0x26(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x2c29
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2b75
jmp 0x2c39
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2b5b
jmp 0x2c49
movsbl 0x19533(%rip), %eax     # 0x1c183
cmpl $0x0, %eax
je 0x2d29
cmpb $0x0, -0x26(%rbp)
jne 0x2d29
movl 0x19513(%rip), %eax     # 0x1c17c
addl $0x1, %eax
movl %eax, 0x1950a(%rip)     # 0x1c17c
movq -0x8(%rbp), %rdi
leaq -0x990(%rbp), %rsi
callq 0x2120
movl %eax, -0x1c(%rbp)
leaq 0x19874(%rip), %rdi     # 0x1c500
leaq 0x1583b(%rip), %rsi     # 0x184ce
callq 0x10d0
movq %rax, -0x998(%rbp)
cmpq $0x0, -0x998(%rbp)
jne 0x2cd2
movq 0x19348(%rip), %rax     # 0x1bff8
movq (%rax), %rdi
leaq 0x15817(%rip), %rsi     # 0x184d1
leaq 0x1983f(%rip), %rdx     # 0x1c500
movb $0x0, %al
callq 0x1080
movl $0x1, %edi
callq 0x1120
cmpl $0x0, 0x19477(%rip)     # 0x1c150
je 0x2d01
movl $0x0, 0x1946b(%rip)     # 0x1c150
movq -0x998(%rbp), %rdi
movsbl 0x1944d(%rip), %edx     # 0x1c140
leaq 0x157c0(%rip), %rsi     # 0x184ba
movb $0x0, %al
callq 0x1080
leaq -0x990(%rbp), %rdi
movslq -0x1c(%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, -0x9b1(%rbp)
jne 0x2d4a
movsbl -0x26(%rbp), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x9b1(%rbp)
movb -0x9b1(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
addq $0x9c0, %rsp            # imm = 0x9C0
popq %rbp
retq
nop