// File: /workspace/github_c_makefile_star2_O2/mishun[P]plantri/fullgen.c
// Function: sparse6code
int
sparse6code( PLANMAP map, FLAECHENTYP *code)
/* Make sparse6 code, including final '\n'. */
{
    FLAECHENTYP *p;
    int nb,i,j,lastj,x,k,r,rr,topbit;
    int nv;
    KANTE *merke, *lauf;

    nv = map[0][0].name;

    p = code;
    *p++ = ':';

    if (nv <= 62)
        *p++ = 63 + nv;
    else
    {
        *p++ = 63 + 63;
        *p++ = 63 + 0;
        *p++ = 63 + (nv >> 6);
        *p++ = 63 + (nv & 0x3F);
    }

    for (i = nv-1, nb = 0; i != 0 ; i >>= 1, ++nb) {}
    topbit = 1 << (nb-1);
    k = 6;
    x = 0;

    lastj = 0;
    for (j = 0; j < nv; ++j)
    {
        merke = lauf = map[j+1];
        do
        {
            i = lauf->name - 1;
            if (i <= j)
            {
                if (j == lastj)
                {
                    x <<= 1;
                    if (--k == 0)
                    {
                        *p++ = 63 + x;
                        k = 6;
                        x = 0;
                    }
                }
                else
                {
                    x = (x << 1) | 1;
                    if (--k == 0)
                    {
                        *p++ = 63 + x;
                        k = 6;
                        x = 0;
                    }
                    if (j > lastj+1)
                    {
                        for (r = 0, rr = j; r < nb; ++r, rr <<= 1)
                        {
                            if (rr & topbit) x = (x << 1) | 1;
                            else             x <<= 1;
                            if (--k == 0)
                            {
                                *p++ = 63 + x;
                                k = 6;
                                x = 0;
                            }
                        }
                        x <<= 1;
                        if (--k == 0)
                        {
                            *p++ = 63 + x;
                            k = 6;
                            x = 0;
                        }
                    }
                    lastj = j;
                }
                for (r = 0, rr = i; r < nb; ++r, rr <<= 1)
                {
                    if (rr & topbit) x = (x << 1) | 1;
                    else             x <<= 1;
                    if (--k == 0)
                    {
                        *p++ = 63 + x;
                        k = 6;
                        x = 0;
                    }
                }
            }
            lauf = lauf->next;
        } while (lauf != merke);
    }

    if (k != 6) *p++ = 63 + ((x << k) | ((1 << k) - 1));

    *p++ = '\n';
    return p - code;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, -0x10(%rsp)
movzwl 0x2(%rdi), %ecx
movb $0x3a, (%rsi)
cmpl $0x3e, %ecx
ja 0x18ef
leal 0x3f(%rcx), %edx
leaq 0x2(%rsi), %rax
jmp 0x190e
movb $0x3f, 0x2(%rsi)
movl %ecx, %eax
shrl $0x6, %eax
addb $0x3f, %al
movb %al, 0x3(%rsi)
movl %ecx, %edx
andb $0x3f, %dl
addb $0x3f, %dl
leaq 0x5(%rsi), %rax
movb %dl, 0x4(%rsi)
movb $0x7e, %dl
movb %dl, 0x1(%rsi)
leal -0x1(%rcx), %edi
xorl %edx, %edx
testl %edi, %edi
je 0x1920
sarl %edi
incl %edx
jmp 0x1916
movq %rsi, -0x18(%rsp)
leal -0x1(%rdx), %r8d
movl %ecx, %ecx
movq %rcx, -0x8(%rsp)
movl $0x6, %r10d
xorl %r11d, %r11d
xorl %r9d, %r9d
xorl %r14d, %r14d
movl %r10d, %ecx
cmpq -0x8(%rsp), %r11
je 0x1a37
leaq 0x1(%r11), %rbx
imulq $0x90, %rbx, %r15
addq -0x10(%rsp), %r15
leaq -0x1(%r11), %r12
movq %r15, %r13
movzwl 0x2(%r13), %ebp
decq %rbp
cmpq %rbp, %r11
jge 0x197f
movq 0x20(%r13), %r13
cmpq %r15, %r13
jne 0x1964
jmp 0x1a2f
movl %r9d, %esi
addl %r14d, %r14d
cmpq %rsi, %r11
je 0x19ea
decl %ecx
je 0x1994
orl $0x1, %r14d
jmp 0x19a4
addb $0x40, %r14b
movb %r14b, (%rax)
incq %rax
xorl %r14d, %r14d
movl %r10d, %ecx
movslq %r9d, %rsi
cmpq %rsi, %r12
jle 0x19e2
movl %edx, %r9d
movl %r11d, %esi
addl %r14d, %r14d
subl $0x1, %r9d
jb 0x19e7
xorl %edi, %edi
btl %r8d, %esi
setb %dil
orl %r14d, %edi
decl %ecx
jne 0x19db
addb $0x3f, %dil
movb %dil, (%rax)
incq %rax
xorl %edi, %edi
movl %r10d, %ecx
addl %esi, %esi
movl %edi, %r14d
jmp 0x19b2
movl %r11d, %r9d
jmp 0x19fe
movl %r11d, %r9d
decl %ecx
jne 0x19fe
addb $0x3f, %r14b
movb %r14b, (%rax)
incq %rax
xorl %r14d, %r14d
movl %r10d, %ecx
movl %edx, %esi
subl $0x1, %esi
jb 0x1971
xorl %edi, %edi
btl %r8d, %ebp
setb %dil
leal (%rdi,%r14,2), %r14d
decl %ecx
jne 0x1a2b
addb $0x3f, %r14b
movb %r14b, (%rax)
incq %rax
xorl %r14d, %r14d
movl %r10d, %ecx
addl %ebp, %ebp
jmp 0x1a00
movq %rbx, %r11
jmp 0x1942
cmpl $0x6, %ecx
je 0x1a53
shll %cl, %r14d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
notl %edx
orl %r14d, %edx
addb $0x3f, %dl
movb %dl, (%rax)
incq %rax
movq -0x18(%rsp), %rcx
movb $0xa, (%rax)
subl %ecx, %eax
incl %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq