// File: /workspace/github_c_makefile_star2_O3/mishun[P]plantri/fullgen.c
// Function: dualcode
int dualcode( PLANMAP map )

{
/* berechnet das Dual und schreibt es als planarcode auf stdout */

int flaechenzahl, knotenzahl, codelaenge=1,i,j, nextnumber=2;
FLAECHENTYP code[(S+13)*7]; /* In main wird schon abgefangen, wenn das nicht in
			       unsigned char passt */
KANTE *startedge[S+13];
KANTE *run, *merke;
static int write_header=1;

if (write_header)
  { write_header=0;
    fprintf(stdout,">>planar_code %ce<<", my_endianness);
  }
    

knotenzahl=map[0][0].name;
code[0]=flaechenzahl= 2 + (map[0][0].name / 2);


for (i=1; i<= knotenzahl; i++) for (j=0; j<3; j++) map[i][j].dummy=0;
/* dummy gibt die Nummer der Flaeche rechts der Kante an */

belegedummies(map[1],1);
startedge[1]=map[1];

for (i=1; i<=flaechenzahl; i++)
  { merke=startedge[i]; 
    if (merke->invers->dummy) { code[codelaenge]=merke->invers->dummy;
				codelaenge++; }
    else { code[codelaenge]= nextnumber; codelaenge++;
	   startedge[nextnumber]=merke->invers;
	   belegedummies(merke->invers,nextnumber);
	   nextnumber++; }
    for (run=merke->invers->prev; run != merke; run=run->invers->prev)
      { if (run->invers->dummy) { code[codelaenge]=run->invers->dummy;
				    codelaenge++; }
        else { code[codelaenge]= nextnumber; codelaenge++;
	     startedge[nextnumber]=run->invers;
	     belegedummies(run->invers,nextnumber);
	     nextnumber++; }
      }
    code[codelaenge]=0; codelaenge++;
  }

fwrite(code,sizeof(FLAECHENTYP),codelaenge,stdout);

return(codelaenge);
}

// Assembly:
pushq %rbx
subq $0x900, %rsp            # imm = 0x900
movq %rdi, %rbx
cmpb $0x0, 0x12254(%rip)     # 0x15258
jne 0x302a
movb $0x1, 0x1224b(%rip)     # 0x15258
movq 0x11fc4(%rip), %rax     # 0x14fd8
movq (%rax), %rdi
leaq 0xd2d8(%rip), %rsi      # 0x102f6
movl $0x6c, %edx
xorl %eax, %eax
callq 0x10b0
movzwl 0x2(%rbx), %ecx
movl %ecx, %eax
shrl %eax
leal 0x2(%rax), %edx
movb %dl, (%rsp)
testl %ecx, %ecx
je 0x30df
incq %rcx
leaq 0xc8(%rbx), %rdx
movl $0x1, %esi
movdqa 0xcfb9(%rip), %xmm0     # 0x10010
movdqa 0xcfc1(%rip), %xmm1     # 0x10020
movdqa 0xcfc9(%rip), %xmm2     # 0x10030
pshufd $0xf5, %xmm2, %xmm3     # xmm3 = xmm2[1,1,3,3]
movdqa 0xcfcc(%rip), %xmm4     # 0x10040
xorl %edi, %edi
movdqa %xmm0, %xmm5
movdqa %xmm5, %xmm6
pxor %xmm1, %xmm6
movdqa %xmm2, %xmm7
pcmpgtd %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm6     # xmm6 = xmm6[1,1,3,3]
pcmpeqd %xmm3, %xmm6
pand %xmm7, %xmm6
movd %xmm6, %r8d
testb $0x1, %r8b
je 0x30ab
movq $0x0, -0x30(%rdx,%rdi)
pextrw $0x4, %xmm6, %r8d
testb $0x1, %r8b
je 0x30bf
movq $0x0, (%rdx,%rdi)
paddq %xmm4, %xmm5
addq $0x60, %rdi
cmpq $0xc0, %rdi
jne 0x307a
incq %rsi
addq $0x90, %rdx
cmpq %rcx, %rsi
jne 0x3074
leaq 0x90(%rbx), %rcx
movq $0x1, 0x98(%rbx)
movq 0xb8(%rbx), %rdx
movq 0x18(%rdx), %rdx
cmpq %rcx, %rdx
je 0x310f
movq $0x1, 0x8(%rdx)
movq 0x28(%rdx), %rdx
jmp 0x30f8
movq %rcx, 0x438(%rsp)
addq $0x3, %rax
movl $0x2, %ecx
movl $0x1, %esi
movl $0x1, %edx
movq 0x430(%rsp,%rdx,8), %rdi
movq 0x28(%rdi), %r8
movq 0x8(%r8), %r10
movslq %esi, %r9
testq %r10, %r10
je 0x3148
movb %r10b, (%rsp,%r9)
jmp 0x3174
movb %cl, (%rsp,%r9)
movslq %ecx, %r9
movq %r8, 0x430(%rsp,%r9,8)
movq %r9, 0x8(%r8)
movq 0x28(%r8), %r10
movq 0x18(%r10), %r10
cmpq %r8, %r10
je 0x3172
movq %r9, 0x8(%r10)
movq 0x28(%r10), %r10
jmp 0x315f
incl %ecx
leal 0x1(%rsi), %r9d
movq 0x18(%r8), %r8
cmpq %rdi, %r8
je 0x31d2
movslq %r9d, %r9
movq %r9, %rsi
movq 0x28(%r8), %r8
movq 0x8(%r8), %r9
testq %r9, %r9
je 0x319a
movb %r9b, (%rsp,%rsi)
jmp 0x31c5
movb %cl, (%rsp,%rsi)
movslq %ecx, %r9
movq %r8, 0x430(%rsp,%r9,8)
movq %r9, 0x8(%r8)
movq 0x28(%r8), %r10
movq 0x18(%r10), %r10
cmpq %r8, %r10
je 0x31c3
movq %r9, 0x8(%r10)
movq 0x28(%r10), %r10
jmp 0x31b0
incl %ecx
leaq 0x1(%rsi), %r9
movq 0x18(%r8), %r8
cmpq %rdi, %r8
jne 0x3184
movslq %r9d, %rdi
movb $0x0, (%rsp,%rdi)
addl $0x2, %esi
incq %rdx
cmpq %rax, %rdx
jne 0x312a
movslq %esi, %rbx
movq 0x11de6(%rip), %rax     # 0x14fd8
movq (%rax), %rcx
movq %rsp, %rdi
movl $0x1, %esi
movq %rbx, %rdx
callq 0x1180
movl %ebx, %eax
addq $0x900, %rsp            # imm = 0x900
popq %rbx
retq