// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/hfile_libcurl.c
// Function: libcurl_open
static hFILE *
libcurl_open(const char *url, const char *modes, http_headers *headers)
{
    hFILE_libcurl *fp;
    struct curl_slist *list;
    char mode;
    const char *s;
    CURLcode err;
    CURLMcode errm;
    int save, is_recursive;
    kstring_t in_header = {0, 0, NULL};
    long response;

    is_recursive = strchr(modes, 'R') != NULL;

    if ((s = strpbrk(modes, "rwa+")) != NULL) {
        mode = *s;
        if (strpbrk(&s[1], "rwa+")) mode = 'e';
    }
    else mode = '\0';

    if (mode != 'r' && mode != 'w') { errno = EINVAL; goto early_error; }

    fp = (hFILE_libcurl *) hfile_init(sizeof (hFILE_libcurl), modes, 0);
    if (fp == NULL) goto early_error;

    if (headers) {
        fp->headers = *headers;
    } else {
        memset(&fp->headers, 0, sizeof(fp->headers));
        fp->headers.fail_on_error = 1;
    }

    fp->file_size = -1;
    fp->buffer.ptr.rd = NULL;
    fp->buffer.len = 0;
    fp->final_result = (CURLcode) -1;
    fp->paused = fp->closing = fp->finished = fp->perform_again = 0;
    fp->can_seek = 1;
    fp->tried_seek = 0;
    fp->delayed_seek = fp->last_offset = -1;
    fp->preserved = NULL;
    fp->preserved_bytes = fp->preserved_size = 0;
    fp->is_recursive = is_recursive;
    fp->nrunning = 0;
    fp->easy = NULL;

    fp->multi = curl_multi_init();
    if (fp->multi == NULL) { errno = ENOMEM; goto error; }

    fp->easy = curl_easy_init();
    if (fp->easy == NULL) { errno = ENOMEM; goto error; }

    // Make a route to the hFILE_libcurl* given just a CURL* easy handle
    err = curl_easy_setopt(fp->easy, CURLOPT_PRIVATE, fp);

    // Avoid many repeated CWD calls with FTP, instead requesting the filename
    // by full path (but not strictly compliant with RFC1738).
    err |= curl_easy_setopt(fp->easy, CURLOPT_FTP_FILEMETHOD,
                            (long) CURLFTPMETHOD_NOCWD);

    if (mode == 'r') {
        err |= curl_easy_setopt(fp->easy, CURLOPT_WRITEFUNCTION, recv_callback);
        err |= curl_easy_setopt(fp->easy, CURLOPT_WRITEDATA, fp);
        fp->is_read = 1;
    }
    else {
        err |= curl_easy_setopt(fp->easy, CURLOPT_READFUNCTION, send_callback);
        err |= curl_easy_setopt(fp->easy, CURLOPT_READDATA, fp);
        err |= curl_easy_setopt(fp->easy, CURLOPT_UPLOAD, 1L);
        if (append_header(&fp->headers.fixed,
                          "Transfer-Encoding: chunked", 1) < 0)
            goto error;
        fp->is_read = 0;
    }

    err |= curl_easy_setopt(fp->easy, CURLOPT_SHARE, curl.share);
    err |= curl_easy_setopt(fp->easy, CURLOPT_URL, url);
    {
        char* env_curl_ca_bundle = getenv("CURL_CA_BUNDLE");
        if (env_curl_ca_bundle) {
            err |= curl_easy_setopt(fp->easy, CURLOPT_CAINFO, env_curl_ca_bundle);
        }
    }
    err |= curl_easy_setopt(fp->easy, CURLOPT_USERAGENT, curl.useragent.s);
    if (fp->headers.callback) {
        if (add_callback_headers(fp) != 0) goto error;
    }
    if (get_auth_token(fp, url) < 0)
        goto error;
    if ((list = get_header_list(fp)) != NULL)
        err |= curl_easy_setopt(fp->easy, CURLOPT_HTTPHEADER, list);

    if (hts_verbose <= 8 && fp->headers.fail_on_error)
        err |= curl_easy_setopt(fp->easy, CURLOPT_FAILONERROR, 1L);
    if (hts_verbose >= 8)
        err |= curl_easy_setopt(fp->easy, CURLOPT_VERBOSE, 1L);

    if (fp->headers.redirect) {
        err |= curl_easy_setopt(fp->easy, CURLOPT_HEADERFUNCTION, header_callback);
        err |= curl_easy_setopt(fp->easy, CURLOPT_HEADERDATA, (void *)&in_header);
    } else {
        err |= curl_easy_setopt(fp->easy, CURLOPT_FOLLOWLOCATION, 1L);
    }

    if (err != 0) { errno = ENOSYS; goto error; }

    errm = curl_multi_add_handle(fp->multi, fp->easy);
    if (errm != CURLM_OK) { errno = multi_errno(errm); goto error; }
    fp->nrunning++;

    while (! fp->paused && ! fp->finished) {
        if (wait_perform(fp) < 0) goto error_remove;
    }

    curl_easy_getinfo(fp->easy, CURLINFO_RESPONSE_CODE, &response);
    if (fp->headers.http_response_ptr) {
        *fp->headers.http_response_ptr = response;
    }

    if (fp->finished && fp->final_result != CURLE_OK) {
        errno = easy_errno(fp->easy, fp->final_result);
        goto error_remove;
    }

    if (fp->headers.redirect) {
        if (response >= 300 && response < 400) { // redirection
            kstring_t new_url = {0, 0, NULL};

            if (fp->headers.redirect(fp->headers.redirect_data, response,
                                     &in_header, &new_url)) {
                errno = ENOSYS;
                goto error;
            }

            err |= curl_easy_setopt(fp->easy, CURLOPT_URL, new_url.s);
            err |= curl_easy_setopt(fp->easy, CURLOPT_HEADERFUNCTION, NULL);
            err |= curl_easy_setopt(fp->easy, CURLOPT_HEADERDATA, NULL);
            free(ks_release(&in_header));

            if (err != 0) { errno = ENOSYS; goto error; }
            free(ks_release(&new_url));

            if (restart_from_position(fp, 0) < 0) {
                goto error_remove;
            }

            if (fp->headers.http_response_ptr) {
                curl_easy_getinfo(fp->easy, CURLINFO_RESPONSE_CODE,
                                  fp->headers.http_response_ptr);
            }

            if (fp->finished && fp->final_result != CURLE_OK) {
                errno = easy_errno(fp->easy, fp->final_result);
                goto error_remove;
            }
        } else {
            // we no longer need to look at the headers
            err |= curl_easy_setopt(fp->easy, CURLOPT_HEADERFUNCTION, NULL);
            err |= curl_easy_setopt(fp->easy, CURLOPT_HEADERDATA, NULL);
            free(ks_release(&in_header));

            if (err != 0) { errno = ENOSYS; goto error; }
        }
    }

    if (mode == 'r') {
#if LIBCURL_VERSION_NUM >= 0x073700 // 7.55.0
        curl_off_t offset;

        if (curl_easy_getinfo(fp->easy, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T,
                              &offset) == CURLE_OK && offset > 0)
            fp->file_size = (off_t) offset;
#else
        double dval;

        if (curl_easy_getinfo(fp->easy, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
                              &dval) == CURLE_OK && dval >= 0.0)
            fp->file_size = (off_t) (dval + 0.1);
#endif
    }
    fp->base.backend = &libcurl_backend;
    return &fp->base;

error_remove:
    save = errno;
    (void) curl_multi_remove_handle(fp->multi, fp->easy);
    fp->nrunning--;
    errno = save;

error:
    if (fp->headers.redirect) free(in_header.s);
    save = errno;
    if (fp->easy) curl_easy_cleanup(fp->easy);
    if (fp->multi) curl_multi_cleanup(fp->multi);
    free_headers(&fp->headers.extra, 1);
    hfile_destroy((hFILE *) fp);
    errno = save;
    return NULL;

early_error:
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq %rsi, %rdi
movl $0x52, %esi
callq 0x4190
movq %rax, %r12
leaq 0x22e52(%rip), %rsi     # 0xa3b39
movq %rbx, %rdi
callq 0x48f0
testq %rax, %rax
je 0x80d18
movsbl (%rax), %ebp
incq %rax
leaq 0x22e38(%rip), %rsi     # 0xa3b39
movq %rax, %rdi
callq 0x48f0
testq %rax, %rax
movl $0x65, %r15d
cmovel %ebp, %r15d
jmp 0x80d1b
xorl %r15d, %r15d
cmpl $0x72, %r15d
je 0x80d27
cmpl $0x77, %r15d
jne 0x80d63
movq %r14, 0x8(%rsp)
xorl %r14d, %r14d
movl $0xf8, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0xee3c
testq %rax, %rax
je 0x80ee8
movq %rax, %rbx
leaq 0x70(%rax), %r14
testq %r13, %r13
je 0x80d73
movl $0xc, %ecx
movq %r14, %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
jmp 0x80d9d
callq 0x4050
movl $0x16, (%rax)
jmp 0x80ee5
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%r14)
movups %xmm0, 0x40(%r14)
movups %xmm0, 0x30(%r14)
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movl $0x1, 0xc8(%rbx)
testq %r12, %r12
setne %al
movq $-0x1, 0x48(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rbx)
movl $0xffffffff, 0x60(%rbx) # imm = 0xFFFFFFFF
movb 0x64(%rbx), %cl
orb $0x20, %cl
pcmpeqd %xmm1, %xmm1
movdqu %xmm1, 0xd0(%rbx)
shlb $0x6, %al
andb $0x30, %cl
orb %al, %cl
movups %xmm0, 0xe0(%rbx)
xorl %eax, %eax
movq %rax, 0xf0(%rbx)
movb %cl, 0x64(%rbx)
movl $0x0, 0x68(%rbx)
movq %rax, 0x38(%rbx)
callq 0x4820
movq %rax, 0x40(%rbx)
testq %rax, %rax
je 0x80e84
callq 0x4670
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x80e84
movq %rax, %rdi
movl $0x2777, %esi           # imm = 0x2777
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4580
movl %eax, %r12d
movq 0x38(%rbx), %rdi
movl $0x2, %edx
movl $0x8a, %esi
xorl %eax, %eax
callq 0x4580
movl %eax, %ebp
movq 0x38(%rbx), %rdi
cmpl $0x72, %r15d
jne 0x80efd
leaq 0x990(%rip), %rdx       # 0x817e2
movl $0x4e2b, %esi           # imm = 0x4E2B
xorl %eax, %eax
callq 0x4580
movl %eax, %r14d
movq 0x38(%rbx), %rdi
movl $0x2711, %esi           # imm = 0x2711
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4580
movl %eax, %r13d
orl %r14d, %r13d
movb 0x64(%rbx), %al
orb $0x10, %al
jmp 0x80f73
callq 0x4050
movl $0xc, (%rax)
cmpq $0x0, 0xb0(%rbx)
je 0x80ea3
movq 0x40(%rsp), %rdi
callq 0x45c0
callq 0x4050
movq %rax, %r14
movl (%rax), %ebp
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x80ebb
callq 0x4620
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
je 0x80ec9
callq 0x4850
movq %rbx, %rdi
subq $-0x80, %rdi
movl $0x1, %esi
callq 0x82091
movq %rbx, %rdi
callq 0xef0b
movl %ebp, (%r14)
xorl %r14d, %r14d
movq %r14, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r12d, 0x10(%rsp)
leaq 0x924(%rip), %rdx       # 0x8182d
movl $0x4e2c, %esi           # imm = 0x4E2C
xorl %eax, %eax
callq 0x4580
movl %eax, (%rsp)
movq 0x38(%rbx), %rdi
movl $0x2719, %esi           # imm = 0x2719
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4580
movl %eax, %r13d
movq 0x38(%rbx), %rdi
movl $0x1, %edx
movl $0x2e, %esi
xorl %eax, %eax
callq 0x4580
movl %eax, %r12d
leaq 0x22bf1(%rip), %rsi     # 0xa3b3e
movq %r14, %rdi
movl $0x1, %edx
callq 0x81883
testl %eax, %eax
js 0x80e8f
orl (%rsp), %r13d
orl %r12d, %r13d
movb 0x64(%rbx), %al
andb $-0x11, %al
movl 0x10(%rsp), %r12d
orl %r12d, %ebp
orl %r13d, %ebp
movb %al, 0x64(%rbx)
movq 0x38(%rbx), %rdi
movq 0x391b1(%rip), %rdx     # 0xba138
movl $0x2774, %esi           # imm = 0x2774
xorl %eax, %eax
callq 0x4580
movl %eax, %r12d
movq 0x38(%rbx), %rdi
movl $0x2712, %esi           # imm = 0x2712
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x4580
movl %eax, %r14d
orl %r12d, %r14d
orl %ebp, %r14d
leaq 0x22b9e(%rip), %rdi     # 0xa3b59
callq 0x4600
testq %rax, %rax
je 0x80fdb
movq 0x38(%rbx), %rdi
movl $0x2751, %esi           # imm = 0x2751
movq %rax, %rdx
xorl %eax, %eax
callq 0x4580
orl %eax, %r14d
movq 0x38(%rbx), %rdi
movq 0x3914a(%rip), %rdx     # 0xba130
movl $0x2722, %esi           # imm = 0x2722
xorl %eax, %eax
callq 0x4580
movl %eax, %r13d
cmpq $0x0, 0x90(%rbx)
je 0x8100f
movq %rbx, %rdi
callq 0x8194a
testl %eax, %eax
jne 0x80e8f
movq 0x3912a(%rip), %r12     # 0xba140
testq %r12, %r12
je 0x8102e
testb $0x40, 0x64(%rbx)
jne 0x8102e
cmpl $0x0, 0xa8(%rbx)
je 0x8115f
movl $0x70, %eax
cmpl $0x0, 0x78(%rbx)
jne 0x8104b
movl $0x80, %eax
cmpl $0x0, 0x88(%rbx)
je 0x8113e
movq (%rbx,%rax), %rdx
orl %r14d, %r13d
testq %rdx, %rdx
je 0x8106a
movq 0x38(%rbx), %rdi
movl $0x2727, %esi           # imm = 0x2727
xorl %eax, %eax
callq 0x4580
orl %eax, %r13d
leaq 0x3870f(%rip), %r14     # 0xb9780
cmpl $0x8, (%r14)
jg 0x81098
cmpl $0x0, 0xc8(%rbx)
je 0x81098
movq 0x38(%rbx), %rdi
movl $0x1, %edx
movl $0x2d, %esi
xorl %eax, %eax
callq 0x4580
orl %eax, %r13d
cmpl $0x8, (%r14)
jl 0x810b6
movq 0x38(%rbx), %rdi
movl $0x1, %edx
movl $0x29, %esi
xorl %eax, %eax
callq 0x4580
orl %eax, %r13d
cmpq $0x0, 0xb0(%rbx)
movq 0x38(%rbx), %rdi
je 0x810f2
leaq 0x9ee(%rip), %rdx       # 0x81ab9
movl $0x4e6f, %esi           # imm = 0x4E6F
xorl %eax, %eax
callq 0x4580
movl %eax, %ebp
movq 0x38(%rbx), %rdi
leaq 0x30(%rsp), %rdx
movl $0x272d, %esi           # imm = 0x272D
xorl %eax, %eax
callq 0x4580
orl %ebp, %eax
jmp 0x81103
movl $0x1, %edx
movl $0x34, %esi
xorl %eax, %eax
callq 0x4580
orl %r13d, %eax
je 0x81118
callq 0x4050
movl $0x26, (%rax)
jmp 0x80e8f
movq 0x38(%rbx), %rsi
movq 0x40(%rbx), %rdi
callq 0x4940
testl %eax, %eax
je 0x81145
movl %eax, %edi
callq 0x81b62
movl %eax, %ebp
callq 0x4050
movl %ebp, (%rax)
jmp 0x80e8f
xorl %edx, %edx
jmp 0x8104f
incl 0x68(%rbx)
testb $0x5, 0x64(%rbx)
jne 0x811a8
movq %rbx, %rdi
callq 0x81bb2
testl %eax, %eax
jns 0x81148
jmp 0x811f0
cmpl $0x0, 0x38fea(%rip)     # 0xba150
je 0x812fa
leaq 0x17383(%rip), %rsi     # 0x984f6
movq 0x8(%rsp), %rdi
callq 0x40e0
testq %rax, %rax
je 0x8131d
addq $0x3, %rax
leaq 0x174bb(%rip), %rsi     # 0x9864c
movq %rax, 0x48(%rsp)
movq %rax, %rdi
callq 0x4090
movq %rax, 0x10(%rsp)
jmp 0x8132f
movq 0x38(%rbx), %rdi
leaq 0x58(%rsp), %rdx
movl $0x200002, %esi         # imm = 0x200002
xorl %eax, %eax
callq 0x4290
movq 0xc0(%rbx), %rax
testq %rax, %rax
je 0x811d1
movq 0x58(%rsp), %rcx
movq %rcx, (%rax)
testb $0x4, 0x64(%rbx)
je 0x81212
movl 0x60(%rbx), %esi
testl %esi, %esi
je 0x81212
movq 0x38(%rbx), %rdi
callq 0x80a55
movl %eax, %ebp
callq 0x4050
movl %ebp, (%rax)
callq 0x4050
movq %rax, %r14
movl (%rax), %ebp
movq 0x38(%rbx), %rsi
movq 0x40(%rbx), %rdi
callq 0x4160
decl 0x68(%rbx)
movl %ebp, (%r14)
jmp 0x80e8f
movq 0xb0(%rbx), %rax
testq %rax, %rax
je 0x815cd
movq 0x58(%rsp), %rsi
leaq -0x12c(%rsi), %rcx
cmpq $0x63, %rcx
ja 0x81580
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rcx
movaps %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
movq 0xb8(%rbx), %rdi
leaq 0x30(%rsp), %rdx
callq *%rax
movl $0x3, %r13d
movl $0x26, %ebp
testl %eax, %eax
jne 0x812d1
movq 0x38(%rbx), %rdi
movq 0x70(%rsp), %rdx
movl $0x2712, %esi           # imm = 0x2712
xorl %eax, %eax
callq 0x4580
movl %eax, %r14d
movq 0x38(%rbx), %rdi
movl $0x4e6f, %esi           # imm = 0x4E6F
xorl %edx, %edx
xorl %eax, %eax
callq 0x4580
movl %eax, %r12d
orl %r14d, %r12d
movq 0x38(%rbx), %rdi
movl $0x272d, %esi           # imm = 0x272D
xorl %edx, %edx
xorl %eax, %eax
callq 0x4580
movl %eax, %r14d
movq 0x40(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
callq 0x45c0
orl %r12d, %r14d
je 0x81764
callq 0x4050
movl %ebp, (%rax)
testl %r13d, %r13d
je 0x815cd
cmpl $0x3, %r13d
je 0x80e8f
cmpl $0x6, %r13d
jne 0x80ee8
jmp 0x811f0
leaq 0x17207(%rip), %rsi     # 0x98508
movl $0x8, %edx
movq 0x8(%rsp), %rdi
callq 0x4210
testl %eax, %eax
jne 0x8102e
jmp 0x8116c
movq $0x0, 0x48(%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x22841(%rip), %rsi     # 0xa3b77
movq %r12, %rdi
callq 0x40e0
testq %rax, %rax
movl %r14d, 0x1c(%rsp)
movl %r13d, 0x2c(%rsp)
je 0x814fe
movq $0x0, (%rsp)
xorl %ebp, %ebp
movq $0x0, 0x8(%rsp)
movq %rax, %r13
subq %r12, %r13
cmpq $0x7fffffff, %r13       # imm = 0x7FFFFFFF
jg 0x8164c
cmpq $0x7fffffff, 0x10(%rsp) # imm = 0x7FFFFFFF
ja 0x8164c
movq %rbp, 0x20(%rsp)
movq %rax, 0x80(%rsp)
movq 0x8(%rsp), %rbp
movq %rbp, %r14
addq %r13, %r14
jae 0x813b8
callq 0x4050
movl $0x4b, (%rax)
movb $0x1, %r13b
movq %rbp, %r14
movq 0x20(%rsp), %rbp
jmp 0x81435
cmpq $0x1, %r14
movq %r14, %rax
adcq $0x0, %rax
movq 0x20(%rsp), %rbp
cmpq %rax, %rbp
jae 0x81409
movq %rax, %rcx
shrq %rcx
movabsq $0x3fffffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rdx, %r14
movl $0x0, %esi
cmovbeq %rcx, %rsi
addq %rax, %rsi
movq (%rsp), %rdi
movq %rsi, 0x50(%rsp)
callq 0x4840
testq %rax, %rax
jne 0x81412
movb $0x1, %r13b
movq 0x8(%rsp), %r14
jmp 0x81435
movq %rbp, 0x50(%rsp)
movq (%rsp), %rax
movq 0x8(%rsp), %rdi
addq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rax, %r12
callq 0x43c0
shrl $0x1f, %r13d
movq 0x50(%rsp), %rbp
movq %r12, (%rsp)
testb %r13b, %r13b
jne 0x8164c
movq %r14, %rdx
addq 0x10(%rsp), %rdx
jae 0x8145c
callq 0x4050
movl $0x4b, (%rax)
movb $0x1, %al
movq %r14, 0x8(%rsp)
jmp 0x814cb
cmpq $0x1, %rdx
movq %rdx, %rax
adcq $0x0, %rax
cmpq %rax, %rbp
movq (%rsp), %rdi
movq %rdx, 0x8(%rsp)
jae 0x814a7
movq %rax, %rcx
shrq %rcx
movabsq $0x3fffffffffffffff, %rsi # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rsi, %rdx
movl $0x0, %r12d
cmovbeq %rcx, %r12
addq %rax, %r12
movq %r12, %rsi
callq 0x4840
movq %rax, %r13
testq %rax, %rax
jne 0x814ad
jmp 0x81453
movq %rbp, %r12
movq %rdi, %r13
addq %r13, %r14
movq %r14, %rdi
movq 0x48(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0x43c0
xorl %eax, %eax
movq %r12, %rbp
movq %r13, (%rsp)
testb %al, %al
movl 0x1c(%rsp), %r14d
jne 0x8164c
movq 0x80(%rsp), %r12
addq $0x2, %r12
movq %r12, %rdi
leaq 0x22689(%rip), %rsi     # 0xa3b77
callq 0x40e0
testq %rax, %rax
jne 0x81364
jmp 0x81511
movq $0x0, 0x8(%rsp)
xorl %ebp, %ebp
movq $0x0, (%rsp)
movq %rbp, 0x20(%rsp)
movq %r12, %rdi
callq 0x41d0
movq %rax, %rbp
movq 0x8(%rsp), %rcx
addq %rcx, %rax
addq $0x2, %rax
cmpq %rcx, %rax
jbe 0x8156d
cmpq %rax, 0x20(%rsp)
jae 0x81617
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %esi, %esi
testq %rcx, %rcx
cmoveq %rdx, %rsi
addq %rax, %rsi
movq (%rsp), %rdi
callq 0x4840
movq %rax, %r13
testq %rax, %rax
jne 0x8161b
jmp 0x81578
callq 0x4050
movl $0x4b, (%rax)
movb $0x1, %bpl
jmp 0x81647
movq 0x38(%rbx), %rdi
movl $0x4e6f, %esi           # imm = 0x4E6F
xorl %edx, %edx
xorl %eax, %eax
callq 0x4580
movl %eax, %ebp
movq 0x38(%rbx), %rdi
movl $0x272d, %esi           # imm = 0x272D
xorl %edx, %edx
xorl %eax, %eax
callq 0x4580
movl %eax, %r14d
movq 0x40(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
callq 0x45c0
orl %ebp, %r14d
jne 0x81108
cmpl $0x72, %r15d
jne 0x81604
movq 0x38(%rbx), %rdi
leaq 0x60(%rsp), %r14
movl $0x60000f, %esi         # imm = 0x60000F
movq %r14, %rdx
xorl %eax, %eax
callq 0x4290
testl %eax, %eax
sete %cl
movq (%r14), %rax
testq %rax, %rax
setg %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x81604
movq %rax, 0x48(%rbx)
leaq 0x37375(%rip), %rax     # 0xb8980
movq %rax, 0x20(%rbx)
movq %rbx, %r14
jmp 0x80ee8
movq (%rsp), %r13
movq 0x8(%rsp), %r14
leaq (%r14,%r13), %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x43c0
movq %rbp, %rax
addq %r14, %rax
movl 0x1c(%rsp), %r14d
movb $0x0, (%r13,%rax)
shrl $0x1f, %ebp
movq %r13, (%rsp)
testb %bpl, %bpl
je 0x8165a
movq (%rsp), %rdi
callq 0x45c0
jmp 0x80e8f
leaq 0x38af7(%rip), %rdi     # 0xba158
callq 0x4750
movq 0x38adb(%rip), %r12     # 0xba148
movq %r12, %rdi
movq (%rsp), %rsi
callq 0x820fb
cmpl (%r12), %eax
jae 0x8168f
movq 0x20(%r12), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %r13
jmp 0x8172e
movl $0x1, %edi
movl $0x48, %esi
callq 0x4300
testq %rax, %rax
je 0x816c0
movq %rax, %r13
movq %rax, %rdi
addq $0x20, %rdi
xorl %esi, %esi
callq 0x4780
testl %eax, %eax
je 0x816c3
movq %r13, %rdi
callq 0x45c0
xorl %r13d, %r13d
testq %r13, %r13
je 0x8172b
leaq 0x60(%rsp), %r12
movl $0xffffffff, (%r12)     # imm = 0xFFFFFFFF
movq (%rsp), %rsi
movq %rsi, (%r13)
movq $0x0, 0x8(%r13)
movq $0x1, 0x10(%r13)
movq 0x38a54(%rip), %rdi     # 0xba148
movq %r12, %rdx
callq 0x821e8
movl %eax, %ebp
cmpl $0x0, (%r12)
jns 0x81710
movq %r13, %rdi
callq 0x823db
xorl %r13d, %r13d
movq 0x38a31(%rip), %rax     # 0xba148
movq 0x20(%rax), %rax
movl %ebp, %ecx
movq %r13, (%rax,%rcx,8)
movq $0x0, (%rsp)
jmp 0x8172e
xorl %r13d, %r13d
leaq 0x38a23(%rip), %rdi     # 0xba158
callq 0x4340
movq %r13, 0xa0(%rbx)
movq (%rsp), %rdi
callq 0x45c0
movq %rbx, %rdi
callq 0x82412
testl %eax, %eax
movl 0x2c(%rsp), %r13d
jns 0x8102e
jmp 0x80e8f
movq 0x70(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
callq 0x45c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x81d94
testl %eax, %eax
js 0x817d7
movq 0xc0(%rbx), %rdx
testq %rdx, %rdx
je 0x817a9
movq 0x38(%rbx), %rdi
movl $0x200002, %esi         # imm = 0x200002
xorl %eax, %eax
callq 0x4290
xorl %r13d, %r13d
testb $0x4, 0x64(%rbx)
je 0x812d8
movl 0x60(%rbx), %esi
testl %esi, %esi
je 0x812d8
movq 0x38(%rbx), %rdi
callq 0x80a55
movl %eax, %ebp
movl $0x6, %r13d
jmp 0x812d1
movl $0x6, %r13d
jmp 0x812d8