// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/hfile_libcurl.c
// Function: libcurl_close
static int libcurl_close(hFILE *fpv)
{
    hFILE_libcurl *fp = (hFILE_libcurl *) fpv;
    CURLcode err;
    CURLMcode errm;
    int save_errno = 0;

    // Before closing the file, unpause it and perform on it so that uploads
    // have the opportunity to signal EOF to the server -- see send_callback().

    fp->buffer.len = 0;
    fp->closing = 1;
    fp->paused = 0;
    if (!fp->finished) {
        err = curl_easy_pause(fp->easy, CURLPAUSE_CONT);
        if (err != CURLE_OK) save_errno = easy_errno(fp->easy, err);
    }

    while (save_errno == 0 && ! fp->paused && ! fp->finished)
        if (wait_perform(fp) < 0) save_errno = errno;

    if (fp->finished && fp->final_result != CURLE_OK)
        save_errno = easy_errno(fp->easy, fp->final_result);

    errm = curl_multi_remove_handle(fp->multi, fp->easy);
    if (errm != CURLM_OK && save_errno == 0) save_errno = multi_errno(errm);
    fp->nrunning--;

    curl_easy_cleanup(fp->easy);
    curl_multi_cleanup(fp->multi);

    if (fp->headers.callback) // Tell callback to free any data it needs to
        fp->headers.callback(fp->headers.callback_data, NULL);
    free_headers(&fp->headers.fixed, 1);
    free_headers(&fp->headers.extra, 1);

    free(fp->preserved);

    if (save_errno) { errno = save_errno; return -1; }
    else return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, 0x58(%rax)
movq -0x18(%rbp), %rax
movb 0x64(%rax), %cl
andb $-0x3, %cl
orb $0x2, %cl
movb %cl, 0x64(%rax)
movq -0x18(%rbp), %rax
movb 0x64(%rax), %cl
andb $-0x2, %cl
orb $0x0, %cl
movb %cl, 0x64(%rax)
movq -0x18(%rbp), %rax
movb 0x64(%rax), %al
shrb $0x2, %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xd2d78
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
xorl %esi, %esi
callq 0x4970
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0xd2d76
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
movl -0x1c(%rbp), %esi
callq 0xced50
movl %eax, -0x24(%rbp)
jmp 0xd2d78
jmp 0xd2d7a
xorl %eax, %eax
cmpl $0x0, -0x24(%rbp)
movb %al, -0x25(%rbp)
jne 0xd2db5
movq -0x18(%rbp), %rax
movb 0x64(%rax), %al
andb $0x1, %al
movzbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x25(%rbp)
jne 0xd2db5
movq -0x18(%rbp), %rax
movb 0x64(%rax), %al
shrb $0x2, %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x25(%rbp)
movb -0x25(%rbp), %al
testb $0x1, %al
jne 0xd2dbe
jmp 0xd2dd8
movq -0x18(%rbp), %rdi
callq 0xd0470
cmpl $0x0, %eax
jge 0xd2dd6
callq 0x4050
movl (%rax), %eax
movl %eax, -0x24(%rbp)
jmp 0xd2d7a
movq -0x18(%rbp), %rax
movb 0x64(%rax), %al
shrb $0x2, %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0xd2e0d
movq -0x18(%rbp), %rax
cmpl $0x0, 0x60(%rax)
je 0xd2e0d
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x18(%rbp), %rax
movl 0x60(%rax), %esi
callq 0xced50
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x4140
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0xd2e3c
cmpl $0x0, -0x24(%rbp)
jne 0xd2e3c
movl -0x20(%rbp), %edi
callq 0xd03d0
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movl 0x68(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x68(%rax)
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x4600
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x4830
movq -0x18(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0xd2e8d
movq -0x18(%rbp), %rax
movq 0x90(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x98(%rcx), %rdi
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movq -0x18(%rbp), %rdi
addq $0x70, %rdi
movl $0x1, %esi
callq 0xd0d20
movq -0x18(%rbp), %rdi
addq $0x70, %rdi
addq $0x10, %rdi
movl $0x1, %esi
callq 0xd0d20
movq -0x18(%rbp), %rax
movq 0xe0(%rax), %rdi
callq 0x45a0
cmpl $0x0, -0x24(%rbp)
je 0xd2ee4
movl -0x24(%rbp), %eax
movl %eax, -0x2c(%rbp)
callq 0x4050
movl -0x2c(%rbp), %ecx
movl %ecx, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd2eeb
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)