// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/htsfile.c
// Function: copy_raw
static void copy_raw(const char *srcfilename, const char *destfilename)
{
    hFILE *src = hopen(srcfilename, "r");
    if (src == NULL) {
        error("can't open \"%s\"", srcfilename);
        return;
    }

    size_t bufsize = 1048576;
    char *buffer = malloc(bufsize);
    if (buffer == NULL) {
        error("can't allocate copy buffer");
        hclose_abruptly(src);
        return;
    }

    hFILE *dest = hopen(destfilename, "w");
    if (dest == NULL) {
        error("can't create \"%s\"", destfilename);
        hclose_abruptly(src);
        free(buffer);
        return;
    }

    ssize_t n;
    while ((n = hread(src, buffer, bufsize)) > 0)
        if (hwrite(dest, buffer, n) != n) {
            error("writing to \"%s\" failed", destfilename);
            hclose_abruptly(dest);
            dest = NULL;
            break;
        }

    if (n < 0) {
        error("reading from \"%s\" failed", srcfilename);
        hclose_abruptly(src);
        src = NULL;
    }

    if (dest && hclose(dest) < 0) error("closing \"%s\" failed", destfilename);
    if (src && hclose(src) < 0)   error("closing \"%s\" failed", srcfilename);
    free(buffer);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
leaq 0xfe2b8(%rip), %rsi     # 0x1043c3
movb $0x0, %al
callq 0x89c0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x6134
movq -0x8(%rbp), %rsi
leaq 0xfdf56(%rip), %rdi     # 0x10407e
movb $0x0, %al
callq 0x5b00
jmp 0x628e
movq $0x100000, -0x20(%rbp)  # imm = 0x100000
movq -0x20(%rbp), %rdi
callq 0x4690
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x616c
leaq 0xfe158(%rip), %rdi     # 0x1042af
movb $0x0, %al
callq 0x5b00
movq -0x18(%rbp), %rdi
callq 0x7ae0
jmp 0x628e
movq -0x10(%rbp), %rdi
leaq 0xfdeb5(%rip), %rsi     # 0x10402c
movb $0x0, %al
callq 0x89c0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x61b2
movq -0x10(%rbp), %rsi
leaq 0xfe136(%rip), %rdi     # 0x1042ca
movb $0x0, %al
callq 0x5b00
movq -0x18(%rbp), %rdi
callq 0x7ae0
movq -0x28(%rbp), %rdi
callq 0x45c0
jmp 0x628e
jmp 0x61b4
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x66b0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jle 0x620d
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x6760
cmpq -0x38(%rbp), %rax
je 0x620b
movq -0x10(%rbp), %rsi
leaq 0xfe0eb(%rip), %rdi     # 0x1042dc
movb $0x0, %al
callq 0x5b00
movq -0x30(%rbp), %rdi
callq 0x7ae0
movq $0x0, -0x30(%rbp)
jmp 0x620d
jmp 0x61b4
cmpq $0x0, -0x38(%rbp)
jge 0x6237
movq -0x8(%rbp), %rsi
leaq 0xfe0d4(%rip), %rdi     # 0x1042f3
movb $0x0, %al
callq 0x5b00
movq -0x18(%rbp), %rdi
callq 0x7ae0
movq $0x0, -0x18(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x625e
movq -0x30(%rbp), %rdi
callq 0x7a30
cmpl $0x0, %eax
jge 0x625e
movq -0x10(%rbp), %rsi
leaq 0xfde7c(%rip), %rdi     # 0x1040d3
movb $0x0, %al
callq 0x5b00
cmpq $0x0, -0x18(%rbp)
je 0x6285
movq -0x18(%rbp), %rdi
callq 0x7a30
cmpl $0x0, %eax
jge 0x6285
movq -0x8(%rbp), %rsi
leaq 0xfde55(%rip), %rdi     # 0x1040d3
movb $0x0, %al
callq 0x5b00
movq -0x28(%rbp), %rdi
callq 0x45c0
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)