// File: /workspace/github_c_makefile_star2_O1/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 0x320c
leaq 0x1(%rsi), %rdx
movl $0x2, %eax
movl %ecx, %edi
jmp 0x322b
movw $0x3f7e, 0x1(%rsi)      # imm = 0x3F7E
movl %ecx, %eax
shrl $0x6, %eax
addb $0x3f, %al
leaq 0x4(%rsi), %rdx
movb %al, 0x3(%rsi)
movl %ecx, %edi
andb $0x3f, %dil
movl $0x5, %eax
addb $0x3f, %dil
movb %dil, (%rdx)
xorl %edx, %edx
movl %ecx, %edi
movl $0x0, %r8d
decl %edi
je 0x3254
xorl %r8d, %r8d
movl %edi, %r9d
sarl %r9d
incl %r8d
cmpl $0x1, %edi
movl %r9d, %edi
ja 0x3246
movq %rsi, -0x10(%rsp)
addq %rsi, %rax
testl %ecx, %ecx
je 0x3365
leal -0x1(%r8), %r9d
movl %ecx, %edi
xorl %r11d, %r11d
movl $0x6, %ecx
xorl %edx, %edx
xorl %ebp, %ebp
leaq 0x1(%r11), %rbx
leaq (%rbx,%rbx,8), %r14
shlq $0x4, %r14
addq -0x8(%rsp), %r14
leaq -0x1(%r11), %r15
movq %r14, %r12
movzwl 0x2(%r12), %r13d
decq %r13
cmpq %r13, %r11
jl 0x3349
movl %ebp, %r10d
addl %edx, %edx
cmpq %r10, %r11
je 0x3301
decl %ecx
je 0x32b3
orl $0x1, %edx
jmp 0x32c2
addb $0x40, %dl
movb %dl, (%rax)
incq %rax
movl $0x6, %ecx
xorl %edx, %edx
movslq %ebp, %r10
cmpq %r10, %r15
jle 0x3316
testl %r8d, %r8d
je 0x32fc
movl %r8d, %ebp
movl %r11d, %r10d
xorl %esi, %esi
btl %r9d, %r10d
setb %sil
leal (%rsi,%rdx,2), %edx
decl %ecx
jne 0x32f5
addb $0x3f, %dl
movb %dl, (%rax)
incq %rax
movl $0x6, %ecx
xorl %edx, %edx
addl %r10d, %r10d
decl %ebp
jne 0x32d5
addl %edx, %edx
movl %r11d, %ebp
decl %ecx
jne 0x3319
addb $0x3f, %dl
movb %dl, (%rax)
incq %rax
movl $0x6, %ecx
xorl %edx, %edx
jmp 0x3319
movl %r11d, %ebp
testl %r8d, %r8d
je 0x3349
movl %r8d, %r10d
xorl %esi, %esi
btl %r9d, %r13d
setb %sil
leal (%rsi,%rdx,2), %edx
decl %ecx
jne 0x3341
addb $0x3f, %dl
movb %dl, (%rax)
incq %rax
movl $0x6, %ecx
xorl %edx, %edx
addl %r13d, %r13d
decl %r10d
jne 0x3321
movq 0x20(%r12), %r12
cmpq %r14, %r12
jne 0x328e
movq %rbx, %r11
cmpq %rdi, %rbx
jne 0x3276
jmp 0x336a
movl $0x6, %ecx
cmpl $0x6, %ecx
je 0x3386
shll %cl, %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
shll %cl, %esi
notl %esi
orl %edx, %esi
addb $0x3f, %sil
movb %sil, (%rax)
incq %rax
movq -0x10(%rsp), %rcx
movb $0xa, (%rax)
subl %ecx, %eax
incl %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq