// File: /workspace/github_c_makefile_star2_O2/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 $0xa8, %rsp
movq %rdi, %rbx
leaq 0xe0(%rsp), %rdi
movslq (%rdi), %rax
movl %eax, %ecx
subl %edx, %ecx
xorl %r8d, %r8d
testl %eax, %eax
movl $0x0, %r9d
cmovgl %eax, %r9d
movl %ecx, (%rbx)
shlq $0x2, %r9
leaq (%rsp,%rax,4), %r10
leaq (%rsp,%rax,8), %r11
addq $0x40, %r11
cmpq %r8, %r9
je 0x2e9d
movl 0x4(%rdi,%r8), %ebp
movl %ebp, (%r10,%r8)
movl %ebp, (%rsp,%r8)
movq 0x20(%rdi,%r8,2), %r14
movq %r14, (%r11,%r8,2)
movq %r14, 0x40(%rsp,%r8,2)
addq $0x4, %r8
jmp 0x2e77
movslq %esi, %rdi
movl (%rsp,%rdi,4), %r8d
testl %r8d, %r8d
je 0x3175
leaq 0x4(%rbx), %r14
movslq %ecx, %r12
cmpl $0x1, %edx
je 0x2f4a
testl %edx, %edx
jne 0x2f56
cmpl $0x2, %ecx
je 0x2fda
cmpl $0x1, %ecx
je 0x2f4f
cmpl $0x2, %r8d
jl 0x310e
decl %r8d
movl %r8d, 0x4(%rbx)
leaq (%rsp,%rdi,4), %r8
addq $0x8, %r8
movl -0x4(%r8), %r9d
incl %r9d
movl %r9d, 0x8(%rbx)
leal -0x1(%rcx), %r9d
addl %ecx, %esi
decl %esi
movslq %esi, %r10
movl (%rsp,%r10,4), %r11d
incl %r11d
movslq %r9d, %rsi
movl %r11d, 0x4(%rbx,%rsi,4)
movq 0x40(%rsp,%r10,8), %r9
movq %r9, 0x20(%rbx,%rsi,8)
leaq (%rsp,%rdi,8), %rdi
addq $0x50, %rdi
xorl %r9d, %r9d
leaq 0x2(%r9), %r10
cmpq %rsi, %r10
jge 0x3021
movl (%r8,%r9,4), %r10d
movl %r10d, 0xc(%rbx,%r9,4)
movq (%rdi,%r9,8), %r10
movq %r10, 0x30(%rbx,%r9,8)
incq %r9
jmp 0x2f26
cmpl $0x1, %eax
jne 0x2f71
movl (%rsp), %esi
incl %esi
jmp 0x2f69
cmpl %edx, %eax
jne 0x3195
movl (%rsp), %esi
movl 0x4(%rsp), %edi
addl %edi, %esi
incl %esi
movl %esi, (%r14)
jmp 0x3024
cmpl $0x2, %ecx
je 0x3006
cmpl $0x1, %ecx
je 0x2f5e
leal 0x1(%rsi), %edi
movslq %edi, %rdi
addl (%rsp,%rdi,4), %r8d
movl %r8d, 0x4(%rbx)
leal (%rcx,%rsi), %edi
movslq %edi, %r8
movl (%rsp,%r8,4), %r9d
incl %r9d
leaq -0x1(%r12), %rdi
movl %r9d, (%rbx,%r12,4)
movq 0x40(%rsp,%r8,8), %r8
movq %r8, 0x18(%rbx,%r12,8)
movl %esi, %esi
pushq $0x2
popq %r8
leaq -0x1(%r8), %r9
cmpq %rdi, %r9
jge 0x3021
leal (%rsi,%r8), %r9d
movslq %r9d, %r9
movl (%rsp,%r9,4), %r10d
movl %r10d, (%rbx,%r8,4)
movq 0x40(%rsp,%r9,8), %r9
movq %r9, 0x18(%rbx,%r8,8)
incq %r8
jmp 0x2fb3
incl %esi
movslq %esi, %rsi
cmpl $0x2, %r8d
jl 0x2ff7
decl %r8d
movl %r8d, 0x4(%rbx)
movl (%rsp,%rsi,4), %esi
addl $0x2, %esi
movl %esi, 0x8(%rbx)
jmp 0x3021
andl $0x0, 0x8(%rbx)
movl (%rsp,%rsi,4), %esi
addl $0x2, %esi
movl %esi, 0x4(%rbx)
jmp 0x3024
addl 0x4(%rsp,%rdi,4), %r8d
movl %r8d, 0x4(%rbx)
movl 0x8(%rsp,%rdi,4), %esi
incl %esi
movl %esi, 0x8(%rbx)
movq 0x50(%rsp,%rdi,8), %rsi
movq %rsi, 0x28(%rbx)
movl (%r14), %esi
testl %esi, %esi
je 0x30c2
cmpl %edx, %eax
jne 0x304d
movl $0xfffe, 0x8(%rbx)      # imm = 0xFFFE
movb $0x1, 0x58(%rbx)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xfffe, 0x4(%rbx,%r12,4) # imm = 0xFFFE
movq %r14, %rdi
callq 0x2d7d
movb %al, 0x58(%rbx)
leaq 0x8(%rbx), %r13
pushq $0x1
popq %rbp
pushq $0x4
popq %r15
cmpq %r12, %rbp
jge 0x303b
xorl %eax, %eax
leaq (%rax,%rbp), %rcx
cmpq %r12, %rcx
jge 0x3089
movl (%r13,%rax,4), %ecx
movl %ecx, (%rsp,%rax,4)
incq %rax
jmp 0x3073
xorl %ecx, %ecx
cmpq %rcx, %r15
je 0x30a0
movl (%r14,%rcx), %edx
movl %edx, (%rsp,%rax,4)
incq %rax
addq $0x4, %rcx
jmp 0x308b
movl %eax, %eax
movl $0xfffe, (%rsp,%rax,4)  # imm = 0xFFFE
movq %rsp, %rdi
callq 0x2d7d
movb %al, 0x58(%rbx,%rbp)
incq %rbp
addq $0x4, %r13
addq $0x4, %r15
jmp 0x306c
andl $0x0, (%rsp)
decl %ecx
xorl %esi, %esi
testl %ecx, %ecx
movl $0x0, %edi
cmovgl %ecx, %edi
cmpq %rsi, %rdi
je 0x30e8
movl 0x8(%rbx,%rsi,4), %r8d
movl %r8d, 0x4(%rbx,%rsi,4)
incq %rsi
jmp 0x30d4
movslq %ecx, %rcx
andl $0x0, (%r14,%rcx,4)
pushq $0x6
popq %rsi
leaq -0x5(%rsi), %rdi
cmpq %rcx, %rdi
jge 0x302c
movq (%rbx,%rsi,8), %rdi
movq %rdi, -0x8(%rbx,%rsi,8)
incq %rsi
jmp 0x30f3
andl $0x0, (%rbx,%r12,4)
leal 0x1(%rsi), %edi
movslq %edi, %rdi
movl (%rsp,%rdi,4), %edi
incl %edi
movl %edi, 0x4(%rbx)
leal (%rcx,%rsi), %edi
decl %edi
movslq %edi, %r8
movl (%rsp,%r8,4), %r9d
incl %r9d
leaq -0x2(%r12), %rdi
movl %r9d, -0x4(%rbx,%r12,4)
movq 0x40(%rsp,%r8,8), %r8
movq %r8, 0x10(%rbx,%r12,8)
movl %esi, %esi
pushq $0x2
popq %r8
leaq -0x1(%r8), %r9
cmpq %rdi, %r9
jge 0x3021
leal (%rsi,%r8), %r9d
movslq %r9d, %r9
movl (%rsp,%r9,4), %r10d
movl %r10d, (%rbx,%r8,4)
movq 0x40(%rsp,%r9,8), %r9
movq %r9, 0x18(%rbx,%r8,8)
incq %r8
jmp 0x314a
movq 0xfe7c(%rip), %rax      # 0x12ff8
movq (%rax), %rcx
leaq 0xb1ba(%rip), %rdi      # 0xe340
pushq $0x34
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
pushq $0x5
jmp 0x31b3
movq 0xfe5c(%rip), %rax      # 0x12ff8
movq (%rax), %rcx
leaq 0xb1cf(%rip), %rdi      # 0xe375
pushq $0x2e
popq %rsi
pushq $0x1
popq %rdx
callq 0x1150
pushq $0x6
popq %rdi
callq 0x1140