// File: /workspace/github_c_makefile_star2_O1/mishun[P]plantri/fullgen.c
// Function: berechne_sequenz
void berechne_sequenz(SEQUENZ *sq, SEQUENZ altsq, int start,int f_ecke)
/* berechnet die neue sequenz startend bei der Kante start */
/* geht fest davon aus, dass 2 mal nach innen hintereinander nicht vorkommt */
/* zwei der Kanten-Eintraege koennen noch nicht belegt werden (die ersten beiden) */
/* start ist der laufindex */
{
int i, j, k, laenge,alt_laenge;
int *sequenz; 
int puffer[13];
char *kan;
KANTE **sqkanten;
KANTE *kpuffer[13];


sequenz=sq->sequenz;
kan=sq->k_marks;
sqkanten=sq->kanten;

alt_laenge=altsq.laenge;
sq->laenge= alt_laenge-f_ecke;
laenge=sq->laenge;

for (i=0; i<alt_laenge; i++) { puffer[i]=puffer[i+alt_laenge]=altsq.sequenz[i];
			       kpuffer[i]=kpuffer[i+alt_laenge]=altsq.kanten[i]; }

if (puffer[start]==0) { fprintf(stderr,"Berechne_sequenz should not be called for 0-gaps ! \n");
                        exit(5); }

if (f_ecke==0)
  { if (laenge==1) sequenz[0]=puffer[0]+1;
    else 
    if (laenge==2)
         { if (puffer[start]>1) { sequenz[0]=puffer[start]-1; sequenz[1]=puffer[start+1]+2; }
	      else { sequenz[1]=0; sequenz[0]=puffer[start+1]+2; }
	 }
    else /* d.h. laenge > 2 */
      { if (puffer[start]>1)
	  {
	    sequenz[0]= puffer[start]-1;
	    sequenz[1]= puffer[start+1]+1;
	    sequenz[laenge-1]=puffer[start+laenge-1]+1;
	    sqkanten[laenge-1]=kpuffer[start+laenge-1];
	    for (j=2; j<laenge-1; j++) { sequenz[j]=puffer[start+j];
					 sqkanten[j]=kpuffer[start+j]; }
	  }
	else /* d.h. die luecke hat laenge 1 */
	  {
	    sequenz[laenge-1]= 0;
	    sequenz[0]= puffer[start+1]+1;
	    sequenz[laenge-2]=puffer[start+laenge-1]+1;
	    sqkanten[laenge-2]=kpuffer[start+laenge-1];
	    for (j=1; j<laenge-2; j++) { sequenz[j]=puffer[start+j+1];
					 sqkanten[j]=kpuffer[start+j+1]; }
	  }
      } /* ende laenge > 2 */
  } /* ende 0 Fuenfecke */

else
if (f_ecke==1)
  { if (laenge==0) sequenz[0]=puffer[0]+1;
    else
    if (laenge==1) sequenz[0]=puffer[0]+puffer[1]+1;
    else 
    if (laenge==2)
          { sequenz[0]=puffer[start] + puffer[start+1]; sequenz[1]=puffer[start+2]+1;
	    sqkanten[1]=kpuffer[start+2];}
    else /* d.h. laenge > 2 */
      { sequenz[0]= puffer[start]+puffer[start+1];
	sequenz[laenge-1]=puffer[start+laenge]+1;
	sqkanten[laenge-1]=kpuffer[start+laenge];
	for (j=1; j<laenge-1; j++) { sequenz[j]=puffer[start+j+1];
				     sqkanten[j]=kpuffer[start+j+1]; }
      }
  } /* ende 1 Fuenfecke */

else /* d.h. f_ecke==2 */
  { if (laenge==0) sequenz[0]=puffer[0]+puffer[1]+1;
    else { fprintf(stderr,"ERROR: Two 5-gons not leading to 0-Sequence !\n");
	   exit(6); }
  } /* ende 2 Fuenfecke */

if (sequenz[0]==0) /* nur im Fall eines einzelnen 6-Ecks moeglich */
  { puffer[0]=sequenz[0];
    for (i=0; i<laenge-1; i++) sequenz[i]=sequenz[i+1]; sequenz[laenge-1]=puffer[0];
    for (i=1; i<laenge-1; i++) sqkanten[i]=sqkanten[i+1]; }



if (laenge==0) { sequenz[1]=leer; kan[0]=1; return; }

sequenz[laenge]=leer;

kan[0]=sequenz_kanonisch(sequenz);

for (i=1; i < laenge; i++)
  { for (j=i, k=0; j<laenge; j++, k++) puffer[k]=sequenz[j];
    for (j=0; j<i; j++, k++) puffer[k]=sequenz[j];
    puffer[k]=leer;
    kan[i]=sequenz_kanonisch(puffer);
  }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %edx, %r15d
movq %rdi, %r14
movslq 0x110(%rsp), %r12
movl %r12d, %r13d
subl %edx, %r13d
movl %r13d, (%rdi)
testq %r12, %r12
jle 0x49b7
leaq 0x110(%rsp), %rax
leaq (%rsp,%r12,8), %rcx
addq $0x70, %rcx
leaq (,%r12,4), %rdx
leaq (%rsp,%r12,4), %rdi
addq $0x10, %rdi
xorl %r8d, %r8d
movl 0x4(%rax,%r8), %r9d
movl %r9d, (%rdi,%r8)
movl %r9d, 0x10(%rsp,%r8)
movq 0x20(%rax,%r8,2), %r9
movq %r9, (%rcx,%r8,2)
movq %r9, 0x70(%rsp,%r8,2)
addq $0x4, %r8
cmpq %r8, %rdx
jne 0x4992
movslq %esi, %rax
movl 0x10(%rsp,%rax,4), %ecx
testl %ecx, %ecx
je 0x4d8d
leaq 0x4(%r14), %rdx
movq %rdx, 0x8(%rsp)
cmpl $0x1, %r15d
je 0x4a7d
testl %r15d, %r15d
jne 0x4a8e
cmpl $0x2, %r13d
je 0x4cb9
cmpl $0x1, %r13d
je 0x4a86
cmpl $0x2, %ecx
jl 0x4d14
decl %ecx
movl %ecx, 0x4(%r14)
movl 0x14(%rsp,%rax,4), %ecx
incl %ecx
movl %ecx, 0x8(%r14)
leal -0x1(%r13), %ecx
leal (%rsi,%r13), %edx
decl %edx
movslq %edx, %rdx
movl 0x10(%rsp,%rdx,4), %esi
incl %esi
movslq %ecx, %rdi
movl %esi, 0x4(%r14,%rdi,4)
movq 0x70(%rsp,%rdx,8), %rdx
movq %rdx, 0x20(%r14,%rdi,8)
cmpl $0x4, %r13d
jl 0x4aaa
cmpl $0x4, %ecx
movl $0x3, %edx
cmovgel %ecx, %edx
leaq (%rsp,%rax,4), %rcx
addq $0x18, %rcx
leaq (%rsp,%rax,8), %rax
addq $0x80, %rax
leaq -0x8(,%rdx,4), %rdx
xorl %esi, %esi
movl (%rcx,%rsi), %edi
movl %edi, 0xc(%r14,%rsi)
movq (%rax,%rsi,2), %rdi
movq %rdi, 0x30(%r14,%rsi,2)
addq $0x4, %rsi
cmpq %rsi, %rdx
jne 0x4a61
jmp 0x4aaa
cmpl %r15d, %r12d
jne 0x4c39
movl 0x10(%rsp), %eax
incl %eax
jmp 0x4aa3
cmpl %r15d, %r12d
jne 0x4d92
movl 0x10(%rsp), %eax
movl 0x14(%rsp), %ecx
addl %ecx, %eax
incl %eax
movq 0x8(%rsp), %rcx
movl %eax, (%rcx)
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x4b16
movl $0x0, 0x10(%rsp)
leal -0x1(%r13), %ebx
cmpl $0x2, %r13d
jl 0x4ae3
leaq 0x8(%r14), %rsi
cmpl $0x2, %ebx
movl $0x1, %edx
cmovgel %ebx, %edx
shlq $0x2, %rdx
movq 0x8(%rsp), %rdi
callq 0x1100
movslq %ebx, %rax
movq 0x8(%rsp), %rcx
movl $0x0, (%rcx,%rax,4)
cmpl $0x3, %r13d
jl 0x4b16
leaq 0x28(%r14), %rdi
leaq 0x30(%r14), %rsi
cmpl $0x3, %ebx
movl $0x2, %edx
cmovgel %ebx, %edx
decl %edx
shlq $0x3, %rdx
callq 0x1100
cmpl %r15d, %r12d
jne 0x4b2d
movl $0xfffe, 0x8(%r14)      # imm = 0xFFFE
movb $0x1, 0x58(%r14)
jmp 0x4c27
movq %r15, 0x50(%rsp)
movslq %r13d, %rax
movl $0xfffe, 0x4(%r14,%rax,4) # imm = 0xFFFE
movq 0x8(%rsp), %rdi
callq 0x486e
movq %r14, 0x58(%rsp)
movb %al, 0x58(%r14)
cmpl $0x2, %r13d
jl 0x4c27
leal -0x2(%r12), %eax
movl %eax, 0x4c(%rsp)
movl %r13d, %r15d
movq 0x50(%rsp), %r14
notl %r14d
addl %r12d, %r14d
movq %r14, 0x60(%rsp)
movq 0x58(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x68(%rsp)
movl $0x1, %ebp
xorl %ebx, %ebx
leaq 0x10(%rsp), %r12
leaq 0x4(,%rbx,4), %r13
movq 0x68(%rsp), %rax
leaq (%rax,%rbx,4), %rsi
movq 0x50(%rsp), %rax
addl %ebx, %eax
movl 0x4c(%rsp), %ecx
subl %eax, %ecx
leaq 0x4(,%rcx,4), %rdx
movq %r12, %r14
movq %r12, %rdi
callq 0x10d0
xorl %r12d, %r12d
leaq (%r12,%rbp), %rax
incq %rax
incq %r12
cmpq %r15, %rax
jb 0x4bc5
leaq (%rsp,%r12,4), %rdi
addq $0x10, %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0x10d0
xorl %eax, %eax
decq %rax
movq %rbp, %rcx
addq %rax, %rcx
jne 0x4beb
subl %eax, %r12d
movl $0xfffe, 0x10(%rsp,%r12,4) # imm = 0xFFFE
movq %r14, %r12
movq %r14, %rdi
callq 0x486e
movq 0x58(%rsp), %rcx
movb %al, 0x58(%rcx,%rbp)
incq %rbp
incq %rbx
cmpq 0x60(%rsp), %rbx
jne 0x4b91
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x2, %r13d
je 0x4cf1
cmpl $0x1, %r13d
je 0x4a97
addl 0x14(%rsp,%rax,4), %ecx
movl %ecx, 0x4(%r14)
leal (%rsi,%r13), %eax
cltq
movl 0x10(%rsp,%rax,4), %ecx
incl %ecx
movslq %r13d, %rdx
movl %ecx, (%r14,%rdx,4)
movq 0x70(%rsp,%rax,8), %rax
movq %rax, 0x18(%r14,%rdx,8)
cmpl $0x3, %r13d
jl 0x4aaa
leal -0x1(%r13), %ecx
cmpl $0x3, %ecx
movl $0x2, %eax
cmovgel %ecx, %eax
addl $0x2, %esi
decq %rax
xorl %ecx, %ecx
leal (%rsi,%rcx), %edx
movslq %edx, %rdx
movl 0x10(%rsp,%rdx,4), %edi
movl %edi, 0x8(%r14,%rcx,4)
movq 0x70(%rsp,%rdx,8), %rdx
movq %rdx, 0x28(%r14,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x4c93
jmp 0x4aaa
incl %esi
movslq %esi, %rax
cmpl $0x2, %ecx
jl 0x4cd9
decl %ecx
movl %ecx, 0x4(%r14)
movl 0x10(%rsp,%rax,4), %eax
addl $0x2, %eax
movl %eax, 0x8(%r14)
jmp 0x4aaa
movl $0x0, 0x8(%r14)
movl 0x10(%rsp,%rax,4), %eax
addl $0x2, %eax
movl %eax, 0x4(%r14)
jmp 0x4aaa
addl 0x14(%rsp,%rax,4), %ecx
movl %ecx, 0x4(%r14)
movl 0x18(%rsp,%rax,4), %ecx
incl %ecx
movl %ecx, 0x8(%r14)
movq 0x80(%rsp,%rax,8), %rax
movq %rax, 0x28(%r14)
jmp 0x4aaa
movslq %r13d, %rcx
movl $0x0, (%r14,%rcx,4)
movl 0x14(%rsp,%rax,4), %eax
incl %eax
movl %eax, 0x4(%r14)
leal (%rsi,%r13), %eax
decl %eax
cltq
movl 0x10(%rsp,%rax,4), %edx
incl %edx
movl %edx, -0x4(%r14,%rcx,4)
movq 0x70(%rsp,%rax,8), %rax
movq %rax, 0x10(%r14,%rcx,8)
cmpl $0x4, %r13d
jl 0x4aaa
leal -0x2(%r13), %ecx
cmpl $0x3, %ecx
movl $0x2, %eax
cmovgel %ecx, %eax
addl $0x2, %esi
decq %rax
xorl %ecx, %ecx
leal (%rsi,%rcx), %edx
movslq %edx, %rdx
movl 0x10(%rsp,%rdx,4), %edi
movl %edi, 0x8(%r14,%rcx,4)
movq 0x70(%rsp,%rdx,8), %rdx
movq %rdx, 0x28(%r14,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x4d67
jmp 0x4aaa
callq 0x1502
callq 0x14dd