// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x918, %rsp            # imm = 0x918
movq %rdi, %rbx
cmpb $0x0, 0x11b23(%rip)     # 0x13238
jne 0x1739
movb $0x1, 0x11b1a(%rip)     # 0x13238
movq 0x118b3(%rip), %rax     # 0x12fd8
movq (%rax), %rdi
leaq 0xcb5b(%rip), %rsi      # 0xe28a
pushq $0x6c
popq %rdx
xorl %eax, %eax
callq 0x10a0
movzwl 0x2(%rbx), %r14d
leaq 0x1(%r14), %rax
shrl %r14d
movl %r14d, %ecx
addb $0x2, %cl
movb %cl, 0x20(%rsp)
leaq 0x98(%rbx), %rcx
pushq $0x1
popq %rdx
cmpq %rax, %rdx
je 0x1780
xorl %esi, %esi
cmpq $0x90, %rsi
je 0x1774
andq $0x0, (%rcx,%rsi)
addq $0x30, %rsi
jmp 0x1760
incq %rdx
addq $0x90, %rcx
jmp 0x1759
movabsq $0x100000000, %r15      # imm = 0x100000000
addq $0x90, %rbx
pushq $0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x16e2
movq %rbx, 0x458(%rsp)
leaq 0x3(%r14), %rax
movq %rax, 0x8(%rsp)
pushq $0x2
popq %rcx
pushq $0x1
popq %rax
movslq %ebp, %r14
cmpq 0x8(%rsp), %rax
je 0x189c
movq %rax, 0x10(%rsp)
movq 0x450(%rsp,%rax,8), %r13
movq 0x28(%r13), %rdi
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x17e4
movb %al, 0x20(%rsp,%r14)
jmp 0x1803
movb %cl, 0x20(%rsp,%r14)
movslq %ecx, %rcx
movq %rdi, 0x450(%rsp,%rcx,8)
movq %rcx, %rbx
movl %ebx, %esi
callq 0x16e2
movq %rbx, %rcx
incl %ecx
leaq 0x28(%r13), %r12
leal 0x2(%r14), %ebp
leaq 0x21(%rsp), %rax
leaq (%rax,%r14), %rbx
shlq $0x20, %r14
addq %r15, %r14
movq %r13, 0x18(%rsp)
movq (%r12), %rax
movq 0x18(%rax), %r12
cmpq %r13, %r12
je 0x1885
movq 0x28(%r12), %rdi
movq 0x8(%rdi), %rax
testq %rax, %rax
jne 0x1875
movslq %ecx, %r15
movq %rdi, 0x450(%rsp,%r15,8)
movl %ebp, %r13d
movq %r14, %rbp
movq %rcx, %r14
movl %r15d, %esi
callq 0x16e2
incl %r15d
movl %r14d, %eax
movq %rbp, %r14
movl %r13d, %ebp
movl %r15d, %ecx
movabsq $0x100000000, %r15      # imm = 0x100000000
movq 0x18(%rsp), %r13
addq $0x28, %r12
movb %al, (%rbx)
incl %ebp
addq %r15, %r14
incq %rbx
jmp 0x1820
sarq $0x20, %r14
movb $0x0, 0x20(%rsp,%r14)
movq 0x10(%rsp), %rax
incq %rax
jmp 0x17b5
movq 0x11735(%rip), %rax     # 0x12fd8
movq (%rax), %rcx
leaq 0x20(%rsp), %rdi
pushq $0x1
popq %rsi
movq %r14, %rdx
callq 0x1150
movl %r14d, %eax
addq $0x918, %rsp            # imm = 0x918
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq