// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/cram/cram_encode.c
// Function: cram_encode_slice
static int cram_encode_slice(cram_fd *fd, cram_container *c,
                             cram_block_compression_hdr *h, cram_slice *s,
                             int embed_ref) {
    int rec, r = 0;
    int64_t last_pos;
    enum cram_DS_ID id;

    /*
     * Slice external blocks:
     * ID 0 => base calls (insertions, soft-clip)
     * ID 1 => qualities
     * ID 2 => names
     * ID 3 => TS (insert size), NP (next frag)
     * ID 4 => tag values
     * ID 6 => tag IDs (TN), if CRAM_V1.0
     * ID 7 => TD tag dictionary, if !CRAM_V1.0
     */

    /* Create cram slice header */
    s->hdr->ref_base_id = embed_ref>0 && s->hdr->ref_seq_span > 0
        ? DS_ref
        : (CRAM_MAJOR_VERS(fd->version) >= 4 ? 0 : -1);
    s->hdr->record_counter = c->num_records + c->record_counter;
    c->num_records += s->hdr->num_records;

    int ntags = c->tags_used ? c->tags_used->n_occupied : 0;
    s->block = calloc(DS_END + ntags*2, sizeof(s->block[0]));
    s->hdr->block_content_ids = malloc(DS_END * sizeof(int32_t));
    if (!s->block || !s->hdr->block_content_ids)
        return -1;

    // Create first fixed blocks, always external.
    // CORE
    if (!(s->block[0] = cram_new_block(CORE, 0)))
        return -1;

    // TN block for CRAM v1
    if (CRAM_MAJOR_VERS(fd->version) == 1) {
        if (h->codecs[DS_TN]->codec == E_EXTERNAL) {
            if (!(s->block[DS_TN] = cram_new_block(EXTERNAL,DS_TN))) return -1;
            h->codecs[DS_TN]->u.external.content_id = DS_TN;
        } else {
            s->block[DS_TN] = s->block[0];
        }
    }

    // Embedded reference
    if (embed_ref>0) {
        if (!(s->block[DS_ref] = cram_new_block(EXTERNAL, DS_ref)))
            return -1;
        s->ref_id = DS_ref; // needed?
        BLOCK_APPEND(s->block[DS_ref],
                     c->ref + s->hdr->ref_seq_start - c->ref_start,
                     s->hdr->ref_seq_span);
    }

    /*
     * All the data-series blocks if appropriate.
     */
    for (id = DS_QS; id < DS_TN; id++) {
        if (cram_allocate_block(h->codecs[id], s, id) < 0)
            return -1;
    }

    /*
     * Add in the external tag blocks too.
     */
    if (c->tags_used) {
        int n;
        s->hdr->num_blocks = DS_END;
        for (n = 0; n < s->naux_block; n++) {
            s->block[s->hdr->num_blocks++] = s->aux_block[n];
            s->aux_block[n] = NULL;
        }
    }

    /* Encode reads */
    last_pos = s->hdr->ref_seq_start;
    for (rec = 0; rec < s->hdr->num_records; rec++) {
        cram_record *cr = &s->crecs[rec];
        if (cram_encode_slice_read(fd, c, h, s, cr, &last_pos) == -1)
            return -1;
    }

    s->block[0]->uncomp_size = s->block[0]->byte + (s->block[0]->bit < 7);
    s->block[0]->comp_size = s->block[0]->uncomp_size;

    // Make sure the fixed blocks point to the correct sources
    if (s->block[DS_IN]) cram_free_block(s->block[DS_IN]);
    s->block[DS_IN] = s->base_blk; s->base_blk = NULL;
    if (s->block[DS_QS]) cram_free_block(s->block[DS_QS]);
    s->block[DS_QS] = s->qual_blk; s->qual_blk = NULL;
    if (s->block[DS_RN]) cram_free_block(s->block[DS_RN]);
    s->block[DS_RN] = s->name_blk; s->name_blk = NULL;
    if (s->block[DS_SC]) cram_free_block(s->block[DS_SC]);
    s->block[DS_SC] = s->soft_blk; s->soft_blk = NULL;

    // Finalise any data transforms.
    for (id = DS_QS; id < DS_TN; id++) {
       if (h->codecs[id] && h->codecs[id]->flush)
           h->codecs[id]->flush(h->codecs[id]);
    }

    // Ensure block sizes are up to date.
    for (id = 1; id < s->hdr->num_blocks; id++) {
        if (!s->block[id] || s->block[id] == s->block[0])
            continue;

        if (s->block[id]->uncomp_size == 0)
            BLOCK_UPLEN(s->block[id]);
    }

    // Compress it all
    if (cram_compress_slice(fd, c, s) == -1)
        return -1;

    // Collapse empty blocks and create hdr_block
    {
        int i, j;

        s->hdr->block_content_ids = realloc(s->hdr->block_content_ids,
                                            s->hdr->num_blocks * sizeof(int32_t));
        if (!s->hdr->block_content_ids)
            return -1;

        for (i = j = 1; i < s->hdr->num_blocks; i++) {
            if (!s->block[i] || s->block[i] == s->block[0])
                continue;
            if (s->block[i]->uncomp_size == 0) {
                cram_free_block(s->block[i]);
                s->block[i] = NULL;
                continue;
            }
            s->block[j] = s->block[i];
            s->hdr->block_content_ids[j-1] = s->block[i]->content_id;
            j++;
        }
        s->hdr->num_content_ids = j-1;
        s->hdr->num_blocks = j;

        if (!(s->hdr_block = cram_encode_slice_header(fd, s)))
            return -1;
    }

    return r ? -1 : 0;

 block_err:
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %r8d, %ebp
movq %rcx, %r12
movq %rdi, 0x10(%rsp)
movq (%rcx), %rbx
testl %r8d, %r8d
jle 0x4666f
movl $0xa, %eax
cmpq $0x0, 0x10(%rbx)
jg 0x46682
xorl %eax, %eax
movq 0x10(%rsp), %rcx
cmpl $0x400, 0xc(%rcx)       # imm = 0x400
setl %al
negl %eax
movl %eax, 0x38(%rbx)
movslq 0x28(%rsi), %rax
movq %rax, %rcx
addq 0x18(%rsi), %rcx
movq %rcx, 0x20(%rbx)
movl 0x18(%rbx), %ecx
addl %eax, %ecx
movl %ecx, 0x28(%rsi)
movq 0x270(%rsi), %rax
testq %rax, %rax
movq %rsi, 0x40(%rsp)
movq %rdx, 0x8(%rsp)
je 0x466c0
movslq 0x8(%rax), %rax
leaq 0x2f(,%rax,2), %rdi
jmp 0x466c5
movl $0x2f, %edi
movl $0x8, %esi
callq 0x4300
movq %rax, %r14
movq %rax, 0x10(%r12)
movl $0xbc, %edi
callq 0x4680
movq %rax, 0x30(%rbx)
testq %r14, %r14
sete %cl
testq %rax, %rax
sete %al
orb %cl, %al
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jne 0x47549
movl $0x5, %edi
xorl %esi, %esi
callq 0x4c675
movq 0x10(%r12), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0x47549
movl $0xffffff00, %eax       # imm = 0xFFFFFF00
movq 0x10(%rsp), %rcx
andl 0xc(%rcx), %eax
cmpl $0x100, %eax            # imm = 0x100
jne 0x46784
movq 0x8(%rsp), %rbx
movq 0x3b8(%rbx), %rax
cmpl $0x1, (%rax)
jne 0x46775
movl $0x4, %edi
movl $0x27, %esi
callq 0x4c675
movq 0x10(%r12), %rcx
movq %rax, 0x138(%rcx)
testq %rax, %rax
je 0x47549
movq 0x3b8(%rbx), %rax
movl $0x27, 0x60(%rax)
jmp 0x46784
movq 0x10(%r12), %rax
movq (%rax), %rcx
movq %rcx, 0x138(%rax)
testl %ebp, %ebp
jle 0x4684b
movl $0x4, %edi
movl $0xa, %esi
callq 0x4c675
movq 0x10(%r12), %rcx
movq %rax, 0x50(%rcx)
testq %rax, %rax
je 0x47549
movl $0xa, 0xc8(%r12)
movq (%r12), %rax
movq 0x10(%r12), %rcx
movq 0x40(%rsp), %rdx
movq 0xe0(%rdx), %r14
addq 0x8(%rax), %r14
movq 0x50(%rcx), %rbx
subq 0xc0(%rdx), %r14
movq 0x10(%rax), %r15
movq 0x30(%rbx), %r13
addq %r15, %r13
movq 0x28(%rbx), %rax
cmpq %r13, %rax
ja 0x46829
leaq 0x320(%rax), %rcx
shrq $0x2, %rcx
addq %rcx, %rax
addq $0x320, %rax            # imm = 0x320
cmpq %r13, %rax
cmovaq %rax, %r13
movq 0x20(%rbx), %rdi
movq %r13, %rsi
callq 0x4840
testq %rax, %rax
je 0x47543
movq %r13, 0x28(%rbx)
movq %rax, 0x20(%rbx)
testq %r15, %r15
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
je 0x4684b
movq 0x20(%rbx), %rdi
addq 0x30(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x43c0
addq %r15, 0x30(%rbx)
xorl %ebx, %ebx
movq 0x8(%rsp), %r14
movq 0x2e0(%r14,%rbx,8), %rdi
leal 0xc(%rbx), %edx
movq %r12, %rsi
callq 0x484e5
testl %eax, %eax
js 0x47549
incq %rbx
cmpq $0x1b, %rbx
jne 0x46852
movq 0x40(%rsp), %rax
cmpq $0x0, 0x270(%rax)
movq (%r12), %rcx
je 0x468e0
movl $0x2f, 0x28(%rcx)
movslq 0xcc(%r12), %rax
testq %rax, %rax
jle 0x468e0
xorl %ecx, %ecx
movq 0xd0(%r12), %rdx
movq (%rdx,%rcx,8), %rdx
movq (%r12), %rsi
movq 0x10(%r12), %rdi
movslq 0x28(%rsi), %r8
leal 0x1(%r8), %r9d
movl %r9d, 0x28(%rsi)
movq %rdx, (%rdi,%r8,8)
movq 0xd0(%r12), %rdx
movq $0x0, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x4689f
movq (%r12), %rcx
cmpl $0x0, 0x18(%rcx)
movq %r12, 0x18(%rsp)
jle 0x46f14
movq 0x8(%rcx), %rax
movq %rax, 0x50(%rsp)
xorl %ecx, %ecx
leaq 0x4(%rsp), %rbp
movq 0x30(%r12), %rbx
movq %rcx, 0x58(%rsp)
leaq (%rcx,%rcx,8), %r14
shlq $0x4, %r14
leaq (%rbx,%r14), %rax
movq %rax, 0x38(%rsp)
movl 0xc(%rbx,%r14), %eax
movl $0xfff, %ecx            # imm = 0xFFF
andl %ecx, %eax
movq 0x10(%rsp), %r13
movl 0x4270(%r13,%rax,4), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rax
movq 0x2f8(%rax), %rsi
movq %r12, %rdi
movq %rbp, %rdx
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %r15d
movl 0x10(%rbx,%r14), %eax
movq 0x8(%rsp), %r14
andl $0x1f, %eax
movl %eax, 0x4(%rsp)
movq 0x300(%r14), %rsi
movq %r12, %rdi
movq %rbp, %rdx
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %ebp
orl %r15d, %ebp
movl 0xc(%r13), %eax
movl $0xffffff00, %ecx       # imm = 0xFFFFFF00
andl %ecx, %eax
cmpl $0x100, %eax            # imm = 0x100
je 0x469ba
movq (%r12), %rax
cmpl $-0x2, 0x4(%rax)
jne 0x469ba
movq 0x388(%r14), %rsi
movq 0x38(%rsp), %rbx
leaq 0x8(%rbx), %rdx
movq %r12, %rdi
movl $0x1, %ecx
callq *0x30(%rsi)
orl %eax, %ebp
jmp 0x469bf
movq 0x38(%rsp), %rbx
movq 0x348(%r14), %rsi
leaq 0x14(%rbx), %rdx
movq %r12, %rdi
movq %rdx, 0x20(%rsp)
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %r15d
movq 0x40(%rsp), %rax
cmpl $0x0, 0x98(%rax)
movl 0xc(%r13), %ecx
movq 0x18(%rbx), %rax
je 0x46a0c
subq 0x50(%rsp), %rax
cmpl $0x400, %ecx            # imm = 0x400
jl 0x46a2a
movq %rax, 0x48(%rsp)
leaq 0x48(%rsp), %rdx
jmp 0x46a33
cmpl $0x400, %ecx            # imm = 0x400
jl 0x46a53
movq %rax, 0x48(%rsp)
movq 0x308(%r14), %rsi
movq %r12, %rdi
leaq 0x48(%rsp), %rdx
jmp 0x46a66
movl %eax, 0x4(%rsp)
leaq 0x4(%rsp), %rdx
movq 0x308(%r14), %rsi
movq %r12, %rdi
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %r13d
movq 0x18(%rbx), %rax
movq %rax, 0x50(%rsp)
jmp 0x46a71
movl %eax, 0x4(%rsp)
movq 0x308(%r14), %rsi
movq %r12, %rdi
leaq 0x4(%rsp), %rdx
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %r13d
orl %ebp, %r15d
movq 0x310(%r14), %rsi
leaq 0x20(%rbx), %rdx
movq %r12, %rdi
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %ebp
orl %r13d, %ebp
orl %r15d, %ebp
movl 0x10(%rbx), %eax
testb $0x2, %al
jne 0x46af5
testb $0x4, %al
je 0x46ab8
movq 0x340(%r14), %rsi
leaq 0x2c(%rbx), %rdx
movq %r12, %rdi
movl $0x1, %ecx
callq *0x30(%rsi)
orl %eax, %ebp
movl 0x10(%rbx), %eax
leaq 0x2c(%rsp), %r15
movq 0x10(%rsp), %r13
testb $0x10, %al
je 0x46be2
cmpl $0x400, 0xc(%r13)       # imm = 0x400
jl 0x46be2
movq 0x330(%r14), %rsi
leaq 0x40(%rbx), %rdx
movq %r12, %rdi
movl $0x1, %ecx
callq *0x30(%rsi)
orl %eax, %ebp
jmp 0x46be2
movl 0x8c(%rbx), %eax
movl %eax, 0x4(%rsp)
movq 0x328(%r14), %rsi
movq %r12, %rdi
leaq 0x4(%rsp), %rdx
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %r13d
movq 0x320(%r14), %rsi
leaq 0x30(%rbx), %rdx
movq %r12, %rdi
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %r15d
orl %r13d, %r15d
orl %ebp, %r15d
movq 0x10(%rsp), %rax
cmpl $0x400, 0xc(%rax)       # imm = 0x400
jl 0x46b87
leaq 0x40(%rbx), %rbp
movq 0x338(%r14), %rsi
leaq 0x38(%rbx), %rdx
movq %r12, %rdi
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %r13d
movq 0x330(%r14), %rsi
movq %r12, %rdi
movq %rbp, %rdx
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %ebp
orl %r13d, %ebp
orl %r15d, %ebp
leaq 0x2c(%rsp), %r15
jmp 0x46bdd
movq %rbx, %r13
movl 0x38(%rbx), %eax
movl %eax, 0x4(%rsp)
movq 0x338(%r14), %rsi
movq %r12, %rdi
leaq 0x4(%rsp), %rbx
movq %rbx, %rdx
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, 0x28(%rsp)
movl 0x40(%r13), %eax
movl %eax, 0x4(%rsp)
movq 0x330(%r14), %rsi
movq %r12, %rdi
movq %rbx, %rdx
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %ebp
orl 0x28(%rsp), %ebp
orl %r15d, %ebp
leaq 0x2c(%rsp), %r15
movq %r13, %rbx
movq 0x10(%rsp), %r13
movl 0xc(%r13), %eax
movl $0xffffff00, %ecx       # imm = 0xFFFFFF00
andl %ecx, %eax
cmpl $0x100, %eax            # imm = 0x100
jne 0x46c5a
movb 0x50(%rbx), %al
movb %al, 0x3(%rsp)
movq 0x3e0(%r14), %rsi
movq %r12, %rdi
leaq 0x3(%rsp), %rdx
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %r13d
orl %ebp, %r13d
cmpl $0x0, 0x50(%rbx)
jle 0x46c7b
xorl %ebx, %ebx
movq 0x38(%rsp), %rbp
movq 0x58(%r12), %rax
movslq 0x5c(%rbp), %rcx
addq %rbx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x2c(%rsp)
movq 0x3b8(%r14), %rsi
movq %r12, %rdi
movq %r15, %rdx
movl $0x1, %ecx
callq *0x30(%rsi)
orl %eax, %r13d
incq %rbx
cmpl 0x50(%rbp), %ebx
jl 0x46c25
jmp 0x46c80
movq 0x380(%r14), %rsi
leaq 0x60(%rbx), %rdx
movq %r12, %rdi
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %r13d
orl %ebp, %r13d
movq %rbx, %rbp
jmp 0x46c80
movq 0x38(%rsp), %rbp
testb $0x4, 0xc(%rbp)
movq %rbp, %rbx
jne 0x46e9e
movq 0x350(%r14), %rsi
leaq 0x88(%rbx), %rdx
movq %r12, %rdi
movq %rdx, 0x60(%rsp)
movl $0x1, %ecx
callq *0x30(%rsi)
orl %r13d, %eax
movl %eax, 0x20(%rsp)
cmpl $0x0, 0x88(%rbx)
je 0x46ec7
xorl %r15d, %r15d
movl $0x0, 0x28(%rsp)
movq 0x48(%r12), %r14
movl 0x84(%rbx), %ebx
addl %r15d, %ebx
shlq $0x4, %rbx
leaq (%r14,%rbx), %rax
movq %rax, 0x30(%rsp)
movb 0x4(%r14,%rbx), %al
movb %al, 0x3(%rsp)
movq 0x8(%rsp), %rbp
movq 0x358(%rbp), %rsi
movq %r12, %rdi
leaq 0x3(%rsp), %rdx
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %r13d
movl (%r14,%rbx), %eax
subl 0x28(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0x360(%rbp), %rsi
movq %r12, %rdi
leaq 0x4(%rsp), %rbp
movq %rbp, %rdx
movl $0x1, %ecx
callq *0x30(%rsi)
movl 0x20(%rsp), %ecx
orl %r13d, %ecx
movl %ecx, %r13d
orl %eax, %r13d
movl (%r14,%rbx), %esi
movl 0x4(%r14,%rbx), %ecx
cmpl $0x57, %ecx
movl %esi, 0x28(%rsp)
jg 0x46d82
leal -0x42(%rcx), %eax
cmpl $0x11, %eax
movq 0x38(%rsp), %rbx
ja 0x472c5
leaq 0x5298e(%rip), %rdx     # 0x996f8
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movl %r13d, 0x20(%rsp)
movq 0x18(%rsp), %r12
jmp 0x46e60
cmpl $0x69, %ecx
movq 0x38(%rsp), %rbx
je 0x46db8
cmpl $0x62, %ecx
je 0x46e73
cmpl $0x58, %ecx
jne 0x472c5
movq 0x30(%rsp), %rax
movb 0x8(%rax), %al
movb %al, 0x3(%rsp)
movq 0x8(%rsp), %rax
movq 0x378(%rax), %rsi
jmp 0x46dd0
movq 0x30(%rsp), %rax
movb 0x8(%rax), %al
movb %al, 0x3(%rsp)
movq 0x8(%rsp), %rax
movq 0x370(%rax), %rsi
movq 0x18(%rsp), %r12
movq %r12, %rdi
leaq 0x3(%rsp), %rdx
jmp 0x46e50
movq 0x30(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rax
movq 0x398(%rax), %rsi
jmp 0x46e45
movq 0x30(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rax
movq 0x3a0(%rax), %rsi
jmp 0x46e45
movq 0x30(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rax
movq 0x390(%rax), %rsi
jmp 0x46e45
movq 0x30(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rax
movq 0x368(%rax), %rsi
movq 0x18(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rdx
movl $0x1, %ecx
callq *0x30(%rsi)
orl %eax, %r13d
movl %r13d, 0x20(%rsp)
incl %r15d
movq 0x60(%rsp), %rax
cmpl (%rax), %r15d
jb 0x46cca
jmp 0x46ec7
movq 0x8(%rsp), %rax
movq 0x3a8(%rax), %rsi
movq 0x18(%rsp), %r12
movq 0x70(%r12), %rax
movq 0x30(%rsp), %rcx
movslq 0x8(%rcx), %rdx
addq 0x20(%rax), %rdx
movl 0xc(%rcx), %ecx
movq %r12, %rdi
jmp 0x46e55
movq 0x20(%rsp), %rax
movl (%rax), %ecx
testl %ecx, %ecx
je 0x46eed
movq 0x70(%r12), %rax
movl 0x64(%rbx), %edx
addq 0x20(%rax), %rdx
movq 0x370(%r14), %rsi
movq %r12, %rdi
callq *0x30(%rsi)
orl %eax, %r13d
jmp 0x46eed
movq 0x8(%rsp), %r14
movq 0x318(%r14), %rsi
subq $-0x80, %rbx
movq %r12, %rdi
movq %rbx, %rdx
movl $0x1, %ecx
callq *0x30(%rsi)
movl %eax, %r13d
orl 0x20(%rsp), %r13d
leaq 0x4(%rsp), %rbp
testl %r13d, %r13d
jne 0x47543
movq 0x58(%rsp), %rcx
incq %rcx
movq (%r12), %rax
movslq 0x18(%rax), %rax
cmpq %rax, %rcx
jl 0x468ff
movq 0x10(%r12), %rax
movq (%rax), %rcx
xorl %edx, %edx
cmpl $0x7, 0x38(%rcx)
setl %dl
addl 0x30(%rcx), %edx
movl %edx, 0x14(%rcx)
movl %edx, 0x10(%rcx)
movq 0x68(%rax), %rdi
testq %rdi, %rdi
je 0x46f41
callq 0x4ceb6
movq 0x10(%r12), %rax
movq 0x80(%r12), %rcx
movq %rcx, 0x68(%rax)
movq $0x0, 0x80(%r12)
movq 0x10(%r12), %rax
movq 0x60(%rax), %rdi
testq %rdi, %rdi
je 0x46f71
callq 0x4ceb6
movq 0x10(%r12), %rax
movq 0x78(%r12), %rcx
movq %rcx, 0x60(%rax)
movq $0x0, 0x78(%r12)
movq 0x10(%r12), %rax
movq 0x58(%rax), %rdi
testq %rdi, %rdi
je 0x46f9b
callq 0x4ceb6
movq 0x10(%r12), %rax
movq 0x68(%r12), %rcx
movq %rcx, 0x58(%rax)
movq $0x0, 0x68(%r12)
movq 0x10(%r12), %rax
movq 0x70(%rax), %rdi
testq %rdi, %rdi
je 0x46fc5
callq 0x4ceb6
movq 0x10(%r12), %rax
movq 0x88(%r12), %rcx
movq %rcx, 0x70(%rax)
movq $0x0, 0x88(%r12)
xorl %ebx, %ebx
movq 0x2e0(%r14,%rbx,8), %rdi
testq %rdi, %rdi
je 0x46ff7
movq 0x48(%rdi), %rax
testq %rax, %rax
je 0x46ff7
callq *%rax
incq %rbx
cmpq $0x1b, %rbx
jne 0x46fdf
movq (%r12), %rax
movl 0x28(%rax), %eax
cmpq $0x2, %rax
movq 0x10(%rsp), %rbp
jb 0x47041
movq 0x10(%r12), %rcx
movl $0x1, %edx
movq (%rcx,%rdx,8), %rsi
testq %rsi, %rsi
je 0x47039
cmpq (%rcx), %rsi
je 0x47039
cmpl $0x0, 0x14(%rsi)
jne 0x47039
movl 0x30(%rsi), %edi
movl %edi, 0x14(%rsi)
movl %edi, 0x10(%rsi)
incq %rdx
cmpq %rdx, %rax
jne 0x4701c
movl 0xc(%rbp), %ebx
movl 0x88(%rbp), %r15d
cmpl $0x6, %r15d
jl 0x4707b
movq 0x10(%r12), %rax
movq (%rax), %rdx
cmpl $0x1f5, 0x14(%rdx)      # imm = 0x1F5
jl 0x4707b
movq %rbp, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x4d32d
xorl %ecx, %ecx
cmpl $0x2, %r15d
setl %cl
movl $0x9e0020, %eax         # imm = 0x9E0020
movl $0x20020, %edx          # imm = 0x20020
cmovgel %eax, %edx
leal 0x600000(%rdx), %r13d
cmpl $0x6, %r15d
cmovll %edx, %r13d
movl 0x234(%rbp), %edx
testl %edx, %edx
movl $0x10010, %eax          # imm = 0x10010
cmovel %eax, %r13d
shll $0x1a, %ecx
addl $0xfe000040, %ecx       # imm = 0xFE000040
xorl %esi, %esi
cmpl $0x301, %ebx            # imm = 0x301
cmovgel %r13d, %eax
cmovgel %ecx, %esi
testl %edx, %edx
cmovel %edx, %eax
xorl %ecx, %ecx
cmpl $0x0, 0x230(%rbp)
movl 0x244(%rbp), %edx
setne %cl
shll $0x2, %ecx
testl %edx, %edx
cmovel %edx, %esi
orl %ecx, %esi
xorl %r14d, %r14d
cmpl $0x0, 0x238(%rbp)
setne %r14b
shll $0x3, %r14d
orl %esi, %r14d
orl %eax, %r14d
movl %r14d, %r12d
orl $0x802, %r12d           # imm = 0x802
movl %r12d, %eax
andl $-0xf, %eax
orl $0x1802, %r14d          # imm = 0x1802
cmpl $0x5, %r15d
cmovgel %r14d, %r12d
cmovgel %r14d, %eax
andl $-0x3, %r14d
movl %r15d, 0x8(%rsp)
cmpl $0x1, %r15d
cmovel %r14d, %r12d
cmovnel %eax, %r14d
movl %r12d, %r15d
cmpl $0x301, %ebx            # imm = 0x301
movq %rbp, %rbx
jl 0x4717b
cmpl $0x0, 0x23c(%rbx)
movl %r12d, %r15d
je 0x4717b
movl 0x88(%rbx), %eax
xorl %ecx, %ecx
cmpl $0x5, %eax
setge %cl
shll $0xd, %ecx
orl $0x80, %ecx
cmpl $0x7, %eax
movl $0xe080, %r15d          # imm = 0xE080
cmovll %ecx, %r15d
orl %r12d, %r15d
leaq 0x88c8(%rbx), %rbp
movq %rbp, %rdi
callq 0x4750
movl $0x1f, %eax
movq 0x40(%rsp), %rdx
movq (%rdx,%rax,8), %rcx
testq %rcx, %rcx
je 0x471b5
cmpl $0x11, 0x100c(%rcx)
jl 0x471b5
movq -0x68(%rbx,%rax,8), %rcx
movl $0x1, 0x220(%rcx)
incq %rax
cmpq $0x4e, %rax
jne 0x47194
movq %rbp, %rdi
callq 0x4340
movq 0x18(%rsp), %rsi
movq 0x10(%rsi), %rax
movq 0x68(%rax), %rdx
movq 0xf8(%rbx), %rcx
movq %rbx, %rdi
movl %r12d, %r8d
movl 0x8(%rsp), %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47543
movl 0x88(%rbx), %eax
testl %eax, %eax
je 0x47275
cmpl $0x1, %eax
jne 0x472e4
movq 0x18(%rsp), %rsi
movq 0x10(%rsi), %rax
movq 0x60(%rax), %rdx
movq 0x10(%rsp), %rdi
movq 0xf0(%rdi), %rcx
movl %r15d, %r8d
movl $0x1, %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47543
xorl %ebx, %ebx
movq 0x18(%rsp), %rsi
movq 0x10(%rsi), %rax
movq 0x8(%rax,%rbx,8), %rdx
testq %rdx, %rdx
je 0x4726c
movq 0x10(%rsp), %rdi
movq 0x98(%rdi,%rbx,8), %rcx
movl %r12d, %r8d
movl $0x1, %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47543
incq %rbx
cmpq $0x9, %rbx
jne 0x47236
andl $0xfe0020, %r13d        # imm = 0xFE0020
xorl $0xfffef7ef, %r13d      # imm = 0xFFFEF7EF
andl %r12d, %r13d
movq 0x10(%rsp), %rax
cmpl $0x301, 0xc(%rax)       # imm = 0x301
jl 0x473ca
cmpl $0x0, 0x240(%rax)
movl 0x8(%rsp), %ebp
je 0x473ce
cmpl $0x0, 0x244(%rax)
movl $0x100, %eax            # imm = 0x100
movl $0x1000000, %ecx        # imm = 0x1000000
cmovel %eax, %ecx
orl %ecx, %r13d
jmp 0x473ce
leaq 0x52b90(%rip), %rsi     # 0x99e5c
leaq 0x52ba0(%rip), %rdx     # 0x99e73
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
jmp 0x47543
movq 0x18(%rsp), %rbx
movq 0x10(%rbx), %rcx
movq 0x60(%rcx), %rdx
movq 0x10(%rsp), %rbp
movq 0xf0(%rbp), %rcx
movq %rbp, %rdi
movq %rbx, %rsi
movl %r15d, %r8d
cmpl $0x2, %eax
jg 0x47507
movl $0x1, %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47543
movq 0x10(%rbx), %rax
movq 0xf0(%rax), %rdx
movq 0x180(%rbp), %rcx
movq %rbp, %rdi
movq %rbx, %rsi
movl %r12d, %r8d
movl $0x1, %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47543
movq 0x10(%rbx), %rax
movq 0x128(%rax), %rdx
testq %rdx, %rdx
je 0x47385
movq 0x10(%rsp), %rdi
movq 0x1b8(%rdi), %rcx
movq %rbx, %rsi
movl %r12d, %r8d
movl $0x1, %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47543
xorl %ebx, %ebx
movq 0x18(%rsp), %rsi
movq 0x10(%rsi), %rax
movq 0x8(%rax,%rbx,8), %rdx
testq %rdx, %rdx
je 0x473bc
movq 0x10(%rsp), %rdi
movq 0x98(%rdi,%rbx,8), %rcx
movl %r12d, %r8d
movl 0x8(%rsp), %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47543
incq %rbx
cmpq $0x9, %rbx
jne 0x47387
jmp 0x47275
movl 0x8(%rsp), %ebp
movq 0x18(%rsp), %rbx
movq 0x10(%rbx), %rax
movq 0x58(%rax), %rdx
movq 0x10(%rsp), %rdi
movq 0xe8(%rdi), %rcx
movq %rbx, %rsi
movl %r13d, %r8d
movl %ebp, %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47543
movq 0x10(%rbx), %rax
movq 0xa0(%rax), %rdx
testq %rdx, %rdx
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
je 0x4743a
cmpq (%rax), %rdx
je 0x4743a
movq 0x10(%rsp), %rdi
movq 0x130(%rdi), %rcx
movq %rbx, %rsi
movl %r12d, %r8d
movl %ebp, %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47549
movq (%rbx), %rax
movl 0x28(%rax), %ecx
cmpl $0x30, %ecx
jl 0x4749d
movl $0x2f, %ebx
movq 0x18(%rsp), %r15
movq 0x18(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq (%rcx,%rbx,8), %rdx
testq %rdx, %rdx
je 0x47491
cmpq (%rcx), %rdx
je 0x47491
cmpl $0x0, (%rdx)
jne 0x47491
movq 0x40(%rdx), %rcx
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movl %r12d, %r8d
movl %ebp, %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47549
movq (%r15), %rax
movl 0x8(%rsp), %ebp
incq %rbx
movslq 0x28(%rax), %rcx
cmpq %rcx, %rbx
jl 0x4744f
cmpl $0x2, %ecx
movq 0x18(%rsp), %r15
jl 0x4755b
movl $0x13, %ebx
movq 0x10(%r15), %rcx
movq -0x90(%rcx,%rbx,8), %rdx
testq %rdx, %rdx
je 0x474eb
cmpq (%rcx), %rdx
je 0x474eb
cmpl $0x0, (%rdx)
jne 0x474eb
movq 0x10(%rsp), %rdi
movq (%rdi,%rbx,8), %rcx
movq %r15, %rsi
movl %r14d, %r8d
movl 0x8(%rsp), %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47549
movq (%r15), %rax
leaq -0x12(%rbx), %rcx
movslq 0x28(%rax), %rsi
cmpq $0x2d, %rcx
ja 0x4755e
leaq -0x11(%rbx), %rcx
incq %rbx
cmpq %rsi, %rcx
jl 0x474b0
jmp 0x4755e
movl 0x8(%rsp), %r15d
movl %r15d, %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47543
movq 0x10(%rbx), %rax
movq 0xf0(%rax), %rdx
movq 0x180(%rbp), %rcx
movq %rbp, %rdi
movq %rbx, %rsi
movl %r12d, %r8d
movl %r15d, %r9d
callq 0x4d32d
testl %eax, %eax
je 0x4760f
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %r13d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %ecx, %rsi
movq 0x30(%rax), %rdi
shlq $0x2, %rsi
callq 0x4840
movq (%r15), %rcx
movq %rax, 0x30(%rcx)
testq %rax, %rax
je 0x47549
movl $0x1, %ebx
cmpl $0x2, 0x28(%rcx)
jl 0x475e6
movl $0x1, %ebx
movl $0x1, %r14d
movq 0x10(%r15), %rax
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x475da
cmpq (%rax), %rdi
je 0x475da
cmpl $0x0, 0x14(%rdi)
je 0x475c6
movslq %ebx, %rbx
movq %rdi, (%rax,%rbx,8)
movq (%r15), %rcx
movq 0x10(%r15), %rax
movq (%rax,%r14,8), %rax
movl 0xc(%rax), %eax
movq 0x30(%rcx), %rdx
movl %eax, -0x4(%rdx,%rbx,4)
incl %ebx
jmp 0x475da
callq 0x4ceb6
movq 0x10(%r15), %rax
movq $0x0, (%rax,%r14,8)
movq (%r15), %rcx
incq %r14
movslq 0x28(%rcx), %rax
cmpq %rax, %r14
jl 0x4758d
leal -0x1(%rbx), %eax
movl %eax, 0x2c(%rcx)
movl %ebx, 0x28(%rcx)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x3ffea
movq %rax, 0x8(%r15)
xorl %r13d, %r13d
cmpq $0x1, %rax
sbbl %r13d, %r13d
jmp 0x47549
movq 0x10(%rbx), %rax
movq 0x128(%rax), %rdx
testq %rdx, %rdx
je 0x47641
movq 0x10(%rsp), %rdi
movq 0x1b8(%rdi), %rcx
movq %rbx, %rsi
movl %r12d, %r8d
movl %r15d, %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47543
xorl %ebx, %ebx
movq 0x18(%rsp), %rsi
movq 0x10(%rsi), %rax
movq 0x8(%rax,%rbx,8), %rdx
testq %rdx, %rdx
je 0x47678
movq 0x10(%rsp), %rdi
movq 0x98(%rdi,%rbx,8), %rcx
movl %r12d, %r8d
movl 0x8(%rsp), %r9d
callq 0x4d32d
testl %eax, %eax
jne 0x47543
incq %rbx
cmpq $0x9, %rbx
jne 0x47643
jmp 0x47275