// File: /workspace/github_c_makefile_star2_O3/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, -0x8(%rsp)
movzwl 0x2(%rdi), %ecx
movb $0x3a, (%rsi)
cmpl $0x3e, %ecx
ja 0x3234
leal 0x3f(%rcx), %edx
leaq 0x2(%rsi), %rax
jmp 0x3253
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)
movl %ecx, %edi
xorl %edx, %edx
decl %edi
je 0x326e
movl %edi, %r8d
sarl %r8d
incl %edx
cmpl $0x1, %edi
movl %r8d, %edi
ja 0x3261
testl %ecx, %ecx
je 0x33aa
movq %rsi, -0x10(%rsp)
leal -0x1(%rdx), %r8d
movl %ecx, %edi
xorl %r10d, %r10d
movl $0x6, %ecx
xorl %r11d, %r11d
xorl %ebp, %ebp
leaq 0x1(%r10), %rbx
leaq (%rbx,%rbx,8), %r14
shlq $0x4, %r14
addq -0x8(%rsp), %r14
leaq -0x1(%r10), %r15
movq %r14, %r12
movzwl 0x2(%r12), %r13d
decq %r13
cmpq %r13, %r10
jl 0x336f
movl %ebp, %r9d
addl %r11d, %r11d
cmpq %r9, %r10
je 0x3321
decl %ecx
je 0x32cd
orl $0x1, %r11d
jmp 0x32df
addb $0x40, %r11b
movb %r11b, (%rax)
incq %rax
movl $0x6, %ecx
xorl %r11d, %r11d
movslq %ebp, %r9
cmpq %r9, %r15
jle 0x3339
testl %edx, %edx
je 0x331b
movl %edx, %ebp
movl %r10d, %r9d
xorl %esi, %esi
btl %r8d, %r9d
setb %sil
leal (%rsi,%r11,2), %r11d
decl %ecx
jne 0x3314
addb $0x3f, %r11b
movb %r11b, (%rax)
incq %rax
movl $0x6, %ecx
xorl %r11d, %r11d
addl %r9d, %r9d
decl %ebp
jne 0x32f0
addl %r11d, %r11d
movl %r10d, %ebp
decl %ecx
jne 0x333c
addb $0x3f, %r11b
movb %r11b, (%rax)
incq %rax
movl $0x6, %ecx
xorl %r11d, %r11d
jmp 0x333c
movl %r10d, %ebp
testl %edx, %edx
je 0x336f
movl %edx, %r9d
xorl %esi, %esi
btl %r8d, %r13d
setb %sil
leal (%rsi,%r11,2), %r11d
decl %ecx
jne 0x3367
addb $0x3f, %r11b
movb %r11b, (%rax)
incq %rax
movl $0x6, %ecx
xorl %r11d, %r11d
addl %r13d, %r13d
decl %r9d
jne 0x3343
movq 0x20(%r12), %r12
cmpq %r14, %r12
jne 0x32a6
movq %rbx, %r10
cmpq %rdi, %rbx
jne 0x328e
cmpl $0x6, %ecx
je 0x33a5
shll %cl, %r11d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
notl %edx
orl %r11d, %edx
addb $0x3f, %dl
movb %dl, (%rax)
incq %rax
movq -0x10(%rsp), %rsi
movb $0xa, (%rax)
subl %esi, %eax
incl %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq