// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/cram/cram_io.c
// Function: cram_get_ref
char *cram_get_ref(cram_fd *fd, int id, hts_pos_t start, hts_pos_t end) {
    ref_entry *r;
    char *seq;
    int ostart = start;

    if (id == -1 || start < 1)
        return NULL;

    /* FIXME: axiomatic query of r->seq being true?
     * Or shortcut for unsorted data where we load once and never free?
     */

    //fd->shared_ref = 1; // hard code for now to simplify things

    pthread_mutex_lock(&fd->ref_lock);

    RP("%d cram_get_ref on fd %p, id %d, range %d..%d\n", gettid(), fd, id, start, end);

    /*
     * Unsorted data implies we want to fetch an entire reference at a time.
     * We just deal with this at the moment by claiming we're sharing
     * references instead, which has the same requirement.
     */
    if (fd->unsorted)
        fd->shared_ref = 1;


    /* Sanity checking: does this ID exist? */
    if (id >= fd->refs->nref) {
        hts_log_error("No reference found for id %d", id);
        pthread_mutex_unlock(&fd->ref_lock);
        return NULL;
    }

    if (!fd->refs || !fd->refs->ref_id[id]) {
        hts_log_error("No reference found for id %d", id);
        pthread_mutex_unlock(&fd->ref_lock);
        return NULL;
    }

    if (!(r = fd->refs->ref_id[id])) {
        hts_log_error("No reference found for id %d", id);
        pthread_mutex_unlock(&fd->ref_lock);
        return NULL;
    }


    /*
     * It has an entry, but may not have been populated yet.
     * Any manually loaded .fai files have their lengths known.
     * A ref entry computed from @SQ lines (M5 or UR field) will have
     * r->length == 0 unless it's been loaded once and verified that we have
     * an on-disk filename for it.
     *
     * 19 Sep 2013: Moved the lock here as the cram_populate_ref code calls
     * open_path_mfile and libcurl, which isn't multi-thread safe unless I
     * rewrite my code to have one curl handle per thread.
     */
    pthread_mutex_lock(&fd->refs->lock);
    if (r->length == 0) {
        if (fd->ref_fn)
            hts_log_warning("Reference file given, but ref '%s' not present",
                            r->name);
        if (cram_populate_ref(fd, id, r) == -1) {
            hts_log_warning("Failed to populate reference \"%s\"",
                            r->name);
            hts_log_warning("See https://www.htslib.org/doc/reference_seqs.html for further suggestions");
            pthread_mutex_unlock(&fd->refs->lock);
            pthread_mutex_unlock(&fd->ref_lock);
            return NULL;
        }
        r = fd->refs->ref_id[id];
        if (fd->unsorted)
            cram_ref_incr_locked(fd->refs, id);
    }


    /*
     * We now know that we the filename containing the reference, so check
     * for limits. If it's over half the reference we'll load all of it in
     * memory as this will speed up subsequent calls.
     */
    if (end < 1)
        end = r->length;
    if (end >= r->length)
        end  = r->length;

    if (end - start >= 0.5*r->length || fd->shared_ref) {
        start = 1;
        end = r->length;
    }

    /*
     * Maybe we have it cached already? If so use it.
     *
     * Alternatively if we don't have the sequence but we're sharing
     * references and/or are asking for the entire length of it, then
     * load the full reference into the refs structure and return
     * a pointer to that one instead.
     */
    if (fd->shared_ref || r->seq || (start == 1 && end == r->length)) {
        char *cp;

        if (id >= 0) {
            if (r->seq) {
                cram_ref_incr_locked(fd->refs, id);
            } else {
                ref_entry *e;
                if (!(e = cram_ref_load(fd->refs, id, r->is_md5))) {
                    pthread_mutex_unlock(&fd->refs->lock);
                    pthread_mutex_unlock(&fd->ref_lock);
                    return NULL;
                }

                /* unsorted data implies cache ref indefinitely, to avoid
                 * continually loading and unloading.
                 */
                if (fd->unsorted)
                    cram_ref_incr_locked(fd->refs, id);
            }

            fd->ref = NULL; /* We never access it directly */
            fd->ref_start = 1;
            fd->ref_end   = r->length;
            fd->ref_id    = id;

            cp = fd->refs->ref_id[id]->seq + ostart-1;
        } else {
            fd->ref = NULL;
            cp = NULL;
        }

        RP("%d cram_get_ref returning for id %d, count %d\n", gettid(), id, (int)r->count);

        pthread_mutex_unlock(&fd->refs->lock);
        pthread_mutex_unlock(&fd->ref_lock);
        return cp;
    }

    /*
     * Otherwise we're not sharing, we don't have a copy of it already and
     * we're only asking for a small portion of it.
     *
     * In this case load up just that segment ourselves, freeing any old
     * small segments in the process.
     */

    /* Unmapped ref ID */
    if (id < 0 || !fd->refs->fn) {
        if (fd->ref_free) {
            free(fd->ref_free);
            fd->ref_free = NULL;
        }
        fd->ref = NULL;
        fd->ref_id = id;
        pthread_mutex_unlock(&fd->refs->lock);
        pthread_mutex_unlock(&fd->ref_lock);
        return NULL;
    }

    /* Open file if it's not already the current open reference */
    if (strcmp(fd->refs->fn, r->fn) || fd->refs->fp == NULL) {
        if (fd->refs->fp)
            if (bgzf_close(fd->refs->fp) != 0)
                return NULL;
        fd->refs->fn = r->fn;
        if (!(fd->refs->fp = bgzf_open_ref(fd->refs->fn, "r", r->is_md5))) {
            pthread_mutex_unlock(&fd->refs->lock);
            pthread_mutex_unlock(&fd->ref_lock);
            return NULL;
        }
    }

    if (!(fd->ref = load_ref_portion(fd->refs->fp, r, start, end))) {
        pthread_mutex_unlock(&fd->refs->lock);
        pthread_mutex_unlock(&fd->ref_lock);
        return NULL;
    }

    if (fd->ref_free)
        free(fd->ref_free);

    fd->ref_id    = id;
    fd->ref_start = start;
    fd->ref_end   = end;
    fd->ref_free = fd->ref;
    seq = fd->ref;

    pthread_mutex_unlock(&fd->refs->lock);
    pthread_mutex_unlock(&fd->ref_lock);

    return seq ? seq + ostart - start : NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1108, %rsp           # imm = 0x1108
movq %rcx, %r13
cmpl $-0x1, %esi
sete %al
testq %rdx, %rdx
setle %cl
orb %al, %cl
je 0x5140f
xorl %r15d, %r15d
jmp 0x51572
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %r14
leaq 0x88f0(%rdi), %rbx
movq %rbx, %rdi
callq 0x4750
cmpl $0x0, 0x88a4(%r14)
je 0x5143b
movl $0x1, 0x248(%r14)
movq 0x50(%r14), %rdi
cmpl %ebp, 0x18(%rdi)
jle 0x5154b
testq %rdi, %rdi
je 0x5154b
movq 0x10(%rdi), %rax
movslq %ebp, %rcx
movq (%rax,%rcx,8), %r12
testq %r12, %r12
je 0x5154b
movq %rcx, 0x18(%rsp)
addq $0x38, %rdi
callq 0x4750
cmpq $0x0, 0x10(%r12)
je 0x51587
testq %r13, %r13
jg 0x51489
movq 0x10(%r12), %r13
movq %r12, (%rsp)
movq 0x10(%r12), %rax
cmpq %rax, %r13
cmovgeq %rax, %r13
movq %r13, %rcx
subq %r15, %rcx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
cvtsi2sd %rax, %xmm1
mulsd 0x44b6c(%rip), %xmm1    # 0x96020
ucomisd %xmm1, %xmm0
jae 0x514c7
cmpl $0x0, 0x248(%r14)
movq %r15, %r12
je 0x514d0
movl $0x1, %r12d
movq %rax, %r13
cmpl $0x0, 0x248(%r14)
jne 0x514f8
movq (%rsp), %rcx
cmpq $0x0, 0x38(%rcx)
jne 0x514f8
movq %r12, %rcx
xorq $0x1, %rcx
xorq %r13, %rax
orq %rcx, %rax
jne 0x5189e
testl %ebp, %ebp
js 0x517e4
movq (%rsp), %rdx
cmpq $0x0, 0x38(%rdx)
movq 0x50(%r14), %rdi
je 0x517f4
movq 0x10(%rdi), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %rax
testq %rax, %rax
movq 0x18(%rsp), %rcx
je 0x51863
cmpq $0x0, 0x38(%rax)
je 0x51863
cmpl %ebp, 0x68(%rdi)
jne 0x51542
movl $0xffffffff, 0x68(%rdi) # imm = 0xFFFFFFFF
incq 0x30(%rax)
jmp 0x51863
leaq 0x4c946(%rip), %rsi     # 0x9de98
leaq 0x4c94c(%rip), %rdx     # 0x9dea5
xorl %r15d, %r15d
movl $0x1, %edi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x14378
movq %rbx, %rdi
callq 0x4340
movq %r15, %rax
addq $0x1108, %rsp           # imm = 0x1108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x80(%r14)
je 0x515af
movq (%r12), %rcx
leaq 0x4c8fc(%rip), %rsi     # 0x9de98
leaq 0x4c91f(%rip), %rdx     # 0x9dec2
movl $0x3, %edi
xorl %eax, %eax
callq 0x14378
leaq 0x4ceac(%rip), %rdi     # 0x9e462
callq 0x4600
movq %rax, 0x28(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
leaq 0x4ce91(%rip), %rdi     # 0x9e46b
callq 0x4600
movq %rax, 0x8(%rsp)
leaq 0x4ce8a(%rip), %rsi     # 0x9e475
leaq 0x4ce95(%rip), %rdx     # 0x9e487
movl $0x4, %edi
movq %r14, %rcx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x14378
movq (%r12), %rcx
testq %rcx, %rcx
je 0x51afc
movq 0x18(%r14), %rax
movq 0x38(%rax), %rdi
leaq 0x49b9b(%rip), %rsi     # 0x9b1bb
leaq 0x4ad62(%rip), %rdx     # 0x9c389
callq 0x881f0
testq %rax, %rax
je 0x51afc
movq %r12, (%rsp)
leaq 0x4ad4c(%rip), %rsi     # 0x9c38c
movq %rax, 0x58(%rsp)
movq %rax, %rdi
xorl %edx, %edx
callq 0x89a0b
testq %rax, %rax
je 0x519b0
movq %rax, 0x20(%rsp)
movq 0x8(%rax), %rcx
addq $0x3, %rcx
leaq 0x4ce09(%rip), %rsi     # 0x9e475
leaq 0x4ce3e(%rip), %rdx     # 0x9e4b1
movl $0x4, %edi
xorl %eax, %eax
callq 0x14378
cmpq $0x0, 0x8(%rsp)
je 0x516ca
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x516ca
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdx
addq $0x3, %rdx
leaq 0x100(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x573b6
testl %eax, %eax
jne 0x516ca
leaq 0x100(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x4420
testl %eax, %eax
je 0x5172e
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdi
addq $0x3, %rdi
movq 0x28(%rsp), %rsi
callq 0x5a615
testq %rax, %rax
je 0x5194b
leaq 0x49dd6(%rip), %rdx     # 0x9b4c7
leaq 0x100(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rcx
movq %rax, 0x10(%rsp)
xorl %eax, %eax
callq 0x4800
movl %eax, %r12d
movq 0x10(%rsp), %rdi
callq 0x45c0
addl $0xfffff000, %r12d      # imm = 0xFFFFF000
cmpl $0xfffff001, %r12d      # imm = 0xFFFFF001
jb 0x5195a
leaq 0x100(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x4420
movb $0x1, %r12b
testl %eax, %eax
jne 0x5194d
movl $0xf000, %eax           # imm = 0xF000
andl 0x88(%rsp), %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x5194d
leaq 0x49e5b(%rip), %rsi     # 0x9b5c4
leaq 0x100(%rsp), %rdi
callq 0xa4a5
testq %rax, %rax
je 0x5194d
movq %rax, 0x10(%rsp)
movq 0xa0(%rsp), %rax
movq (%rsp), %r12
movq %rax, 0x10(%r12)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%r12)
movq 0x50(%r14), %rax
movq (%rax), %rdi
leaq 0x100(%rsp), %rsi
callq 0x5aa65
movq %rax, 0x8(%r12)
movq 0x50(%r14), %rax
movq 0x28(%rax), %rdi
testq %rdi, %rdi
je 0x51de5
callq 0xd4a4
testl %eax, %eax
je 0x51de5
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %r12d, %r12d
jmp 0x5194d
movq $0x0, 0x58(%r14)
xorl %r15d, %r15d
jmp 0x51b96
movl 0x48(%rdx), %edx
movl %ebp, %esi
callq 0x50f80
movq %rax, %r13
testq %rax, %rax
je 0x5183c
cmpl $0x0, 0x88a4(%r14)
je 0x51851
movq 0x50(%r14), %rax
movq 0x10(%rax), %rcx
movl %ebp, %edx
movq (%rcx,%rdx,8), %rcx
testq %rcx, %rcx
je 0x51851
cmpq $0x0, 0x38(%rcx)
je 0x51851
cmpl %ebp, 0x68(%rax)
jne 0x51836
movl $0xffffffff, 0x68(%rax) # imm = 0xFFFFFFFF
incq 0x30(%rcx)
jmp 0x51851
movq 0x50(%r14), %rdi
addq $0x38, %rdi
callq 0x4340
movq %rbx, %rdi
callq 0x4340
testq %r13, %r13
movq (%rsp), %rdx
movq 0x18(%rsp), %rcx
je 0x51407
movq $0x0, 0x58(%r14)
movq $0x1, 0x70(%r14)
movq 0x10(%rdx), %rax
movq %rax, 0x78(%r14)
movl %ebp, 0x68(%r14)
movq 0x50(%r14), %rax
movq 0x10(%rax), %rax
movq (%rax,%rcx,8), %rax
movq 0x38(%rax), %rax
movslq %r15d, %rcx
leaq (%rax,%rcx), %r15
decq %r15
jmp 0x51b96
testl %ebp, %ebp
js 0x5190f
movq 0x50(%r14), %rax
movq 0x20(%rax), %rdi
testq %rdi, %rdi
je 0x5190f
movq %rax, 0x18(%rsp)
movq (%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x46c0
testl %eax, %eax
movq 0x18(%rsp), %rax
je 0x51d35
movq 0x28(%rax), %rdi
testq %rdi, %rdi
je 0x518e4
callq 0xd4a4
testl %eax, %eax
jne 0x51407
movq (%rsp), %rcx
movq 0x8(%rcx), %rdi
movq 0x50(%r14), %rax
movq %rdi, 0x20(%rax)
movl 0x48(%rcx), %esi
callq 0x510b7
movq 0x50(%r14), %rdi
movq %rax, 0x28(%rdi)
testq %rax, %rax
jne 0x51d40
jmp 0x51935
movq 0x60(%r14), %rdi
testq %rdi, %rdi
je 0x51925
callq 0x45c0
movq $0x0, 0x60(%r14)
movq $0x0, 0x58(%r14)
movl %ebp, 0x68(%r14)
movq 0x50(%r14), %rdi
addq $0x38, %rdi
callq 0x4340
movq %rbx, %rdi
callq 0x4340
jmp 0x51407
jmp 0x5195a
testb %r12b, %r12b
movq (%rsp), %r12
je 0x51b01
movl %edx, 0x10(%rsp)
leaq 0x54(%rsp), %rcx
movl $0x0, (%rcx)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdi
addq $0x3, %rdi
movq 0x28(%rsp), %rsi
xorl %edx, %edx
callq 0x5a3e6
testq %rax, %rax
je 0x519b0
movq %rax, %r12
leaq 0x70(%rsp), %rsi
movq %rax, %rdi
callq 0x59a25
movq (%rsp), %rcx
movq %rax, 0x38(%rcx)
testq %rax, %rax
je 0x51bb6
xorl %r12d, %r12d
jmp 0x51bbf
leaq 0x4c722(%rip), %rsi     # 0x9e0d9
movq 0x58(%rsp), %rdi
xorl %edx, %edx
callq 0x89a0b
testq %rax, %rax
je 0x51ba8
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
leaq 0x3(%rax), %r12
leaq 0x46b16(%rip), %rsi     # 0x984f6
movq %r12, %rdi
callq 0x40e0
testq %rax, %rax
je 0x51a24
leaq 0x4cacd(%rip), %rsi     # 0x9e4c1
movl $0x5, %edx
movq %r12, %rdi
callq 0x4210
testl %eax, %eax
je 0x51a24
leaq 0x4ca69(%rip), %rsi     # 0x9e475
leaq 0x4cab4(%rip), %rdx     # 0x9e4c7
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
jmp 0x51ba8
leaq 0x4ca96(%rip), %rsi     # 0x9e4c1
movl $0x5, %edx
movq %r12, %rdi
callq 0x4210
movq 0x8(%rsp), %rsi
addq $0x8, %rsi
testl %eax, %eax
cmovneq %r12, %rsi
movq 0x50(%r14), %rax
movq 0x28(%rax), %rdi
testq %rdi, %rdi
je 0x51a7b
movq %rsi, 0x8(%rsp)
callq 0xd4a4
testl %eax, %eax
movq (%rsp), %r12
jne 0x51afc
movq 0x50(%r14), %rax
movq $0x0, 0x28(%rax)
movq 0x8(%rsp), %rsi
movq 0x50(%r14), %rdi
xorl %edx, %edx
callq 0x51fc7
testq %rax, %rax
je 0x51ba8
movq %rax, %r12
movq %r14, %rdi
callq 0x524ec
movq %r12, 0x50(%r14)
movq 0x28(%r12), %rdi
testq %rdi, %rdi
movq (%rsp), %r12
je 0x51ac1
callq 0xd4a4
testl %eax, %eax
jne 0x51afc
movq 0x50(%r14), %rax
movq $0x0, 0x28(%rax)
movq 0x50(%r14), %rdi
cmpq $0x0, 0x20(%rdi)
je 0x51afc
movq 0x18(%r14), %rsi
callq 0x50914
cmpl $-0x1, %eax
je 0x51afc
movq 0x50(%r14), %rax
movq 0x10(%rax), %rax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x51b01
xorl %edx, %edx
movq 0x18(%rsp), %rcx
cmpq $0x1, (%rax,%rcx,8)
sbbl %edx, %edx
jmp 0x51b01
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpl $-0x1, %edx
je 0x51b5c
movq 0x50(%r14), %rax
movq 0x10(%rax), %rcx
movq 0x18(%rsp), %rdx
movq (%rcx,%rdx,8), %r12
testl %ebp, %ebp
js 0x5147f
cmpl $0x0, 0x88a4(%r14)
je 0x5147f
movl %ebp, %edx
movq (%rcx,%rdx,8), %rcx
testq %rcx, %rcx
je 0x5147f
cmpq $0x0, 0x38(%rcx)
je 0x5147f
cmpl %ebp, 0x68(%rax)
jne 0x51b53
movl $0xffffffff, 0x68(%rax) # imm = 0xFFFFFFFF
incq 0x30(%rcx)
jmp 0x5147f
movq (%r12), %rcx
leaq 0x4c331(%rip), %r12     # 0x9de98
leaq 0x4c383(%rip), %rdx     # 0x9def1
xorl %r15d, %r15d
movl $0x3, %edi
movq %r12, %rsi
xorl %eax, %eax
callq 0x14378
leaq 0x4c38c(%rip), %rdx     # 0x9df13
movl $0x3, %edi
movq %r12, %rsi
xorl %eax, %eax
callq 0x14378
movq 0x50(%r14), %rdi
addq $0x38, %rdi
callq 0x4340
jmp 0x5156a
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq (%rsp), %r12
jmp 0x51b01
movq 0x8(%r12), %rax
movq %rax, 0x38(%rcx)
movq %r12, 0x40(%rcx)
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rcx)
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x48(%rcx)
cmpq $0x0, 0x8(%rsp)
movq %rcx, %r12
je 0x51ed0
cmpl $0x0, 0x54(%rsp)
jne 0x51ed0
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x51ed0
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdx
addq $0x3, %rdx
leaq 0x100(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x573b6
testl %eax, %eax
js 0x51db0
leaq 0x4c845(%rip), %rsi     # 0x9e475
leaq 0x4c8c3(%rip), %rdx     # 0x9e4fa
xorl %r12d, %r12d
leaq 0x100(%rsp), %rcx
movl $0x4, %edi
xorl %eax, %eax
callq 0x14378
leaq 0x100(%rsp), %rdi
callq 0x575dd
leaq 0x47e9d(%rip), %rsi     # 0x99aff
leaq 0x30(%rsp), %rdx
leaq 0x100(%rsp), %rdi
callq 0x15b35
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x51ee1
callq 0x8e160
testq %rax, %rax
je 0x51dba
movq %rax, %r12
movq (%rsp), %rax
movq 0x10(%rax), %rdx
movq 0x38(%rax), %rsi
movq %r12, %rdi
callq 0x8d72b
leaq 0x60(%rsp), %rdi
movq %r12, %rsi
callq 0x8e039
movq %r12, %rdi
callq 0x8e188
leaq 0x70(%rsp), %r12
movq %r12, %rdi
leaq 0x60(%rsp), %rsi
callq 0x8e192
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdi
addq $0x3, %rdi
movl $0x20, %edx
movq %r12, %rsi
callq 0x4210
testl %eax, %eax
je 0x51e14
leaq 0x4c77e(%rip), %rsi     # 0x9e475
leaq 0x4c814(%rip), %rdx     # 0x9e512
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
movq 0x8(%rsp), %rdi
callq 0xf730
movq 0x40(%rsp), %rdi
callq 0x4200
movq 0x40(%rsp), %rdi
callq 0x45c0
xorl %eax, %eax
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x51ec1
cmpq $0x0, 0x28(%rax)
je 0x518ce
movq 0x50(%r14), %rax
movq 0x28(%rax), %rdi
movq (%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x511b0
movq %rax, 0x58(%r14)
testq %rax, %rax
je 0x51931
movq 0x60(%r14), %rdi
testq %rdi, %rdi
je 0x51d72
callq 0x45c0
movl %ebp, 0x68(%r14)
movq %r12, 0x70(%r14)
movq %r13, 0x78(%r14)
movq 0x50(%r14), %rdi
movq 0x58(%r14), %r13
movq %r13, 0x60(%r14)
addq $0x38, %rdi
callq 0x4340
movq %rbx, %rdi
callq 0x4340
movslq %r15d, %r15
addq %r13, %r15
subq %r12, %r15
testq %r13, %r13
cmoveq %r13, %r15
jmp 0x51572
xorl %eax, %eax
xorl %r12d, %r12d
jmp 0x51ec1
movq 0x8(%rsp), %rdi
callq 0xf730
movq 0x40(%rsp), %rdi
callq 0x4200
movq 0x40(%rsp), %rdi
callq 0x45c0
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %eax, %eax
jmp 0x51ec1
movq 0x50(%r14), %rax
movq 0x10(%rsp), %rcx
movq %rcx, 0x28(%rax)
movq 0x8(%r12), %rcx
movq %rcx, 0x20(%rax)
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x48(%r12)
xorl %r12d, %r12d
xorl %edx, %edx
jmp 0x5194d
movq (%rsp), %rax
movq 0x10(%rax), %rdx
movq 0x38(%rax), %rsi
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x4db29
movq %rax, 0x28(%rsp)
movq %r12, %rdi
callq 0xf6d0
testl %eax, %eax
js 0x51e7f
movq (%rsp), %rax
movq 0x28(%rsp), %rcx
cmpq 0x10(%rax), %rcx
jne 0x51e7f
movq 0x40(%rsp), %rdi
movl $0x124, %esi            # imm = 0x124
callq 0x4430
testl %eax, %eax
js 0x51e7f
movq 0x40(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x42c0
testl %eax, %eax
js 0x51e7f
movl 0x10(%rsp), %r12d
movb $0x1, %al
jmp 0x51ec1
callq 0x4050
movl (%rax), %edi
callq 0x4150
leaq 0x4c5e3(%rip), %rsi     # 0x9e475
leaq 0x4c6a5(%rip), %rdx     # 0x9e53e
leaq 0x100(%rsp), %rcx
movl $0x1, %edi
movq %rax, %r8
xorl %eax, %eax
callq 0x14378
movq 0x40(%rsp), %rdi
callq 0x4200
movb $0x1, %al
movl 0x10(%rsp), %r12d
movl %r12d, %edx
testb %al, %al
movq (%rsp), %r12
je 0x51b01
movq 0x40(%rsp), %rdi
callq 0x45c0
xorl %edx, %edx
jmp 0x51b01
leaq 0x30(%rsp), %rdi
callq 0x4a42
jmp 0x51dde