// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/bgzf.c
// Function: bgzf_read_init
static BGZF *bgzf_read_init(hFILE *hfpr, const char *filename)
{
    BGZF *fp;
    uint8_t magic[18];
    ssize_t n = hpeek(hfpr, magic, 18);
    if (n < 0) return NULL;

    fp = (BGZF*)calloc(1, sizeof(BGZF));
    if (fp == NULL) return NULL;

    fp->is_write = 0;
    fp->uncompressed_block = malloc(2 * BGZF_MAX_BLOCK_SIZE);
    if (fp->uncompressed_block == NULL) { free(fp); return NULL; }
    fp->compressed_block = (char *)fp->uncompressed_block + BGZF_MAX_BLOCK_SIZE;
    fp->is_compressed = (n==18 && magic[0]==0x1f && magic[1]==0x8b);
    fp->is_gzip = ( !fp->is_compressed || ((magic[3]&4) && memcmp(&magic[12], "BC\2\0",4)==0) ) ? 0 : 1;
    if (fp->is_compressed && (magic[3]&4) && memcmp(&magic[12], "RAZF", 4)==0) {
        hts_log_error("Cannot decompress legacy RAZF format");
        razf_info(hfpr, filename);
        free(fp->uncompressed_block);
        free(fp);
        errno = EFTYPE;
        return NULL;
    }
#ifdef BGZF_CACHE
    if (!(fp->cache = malloc(sizeof(*fp->cache)))) {
        free(fp->uncompressed_block);
        free(fp);
        return NULL;
    }
    if (!(fp->cache->h = kh_init(cache))) {
        free(fp->uncompressed_block);
        free(fp->cache);
        free(fp);
        return NULL;
    }
    fp->cache->last_pos = 0;
#endif
    return fp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movl $0x12, %edx
callq 0x140b0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jge 0xc21a
movq $0x0, -0x8(%rbp)
jmp 0xc475
movl $0x1, %edi
movl $0x70, %esi
callq 0x42f0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xc241
movq $0x0, -0x8(%rbp)
jmp 0xc475
movq -0x20(%rbp), %rax
movl (%rax), %ecx
andl $0xfffdffff, %ecx       # imm = 0xFFFDFFFF
orl $0x0, %ecx
movl %ecx, (%rax)
movl $0x20000, %edi          # imm = 0x20000
callq 0x4650
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0xc288
movq -0x20(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0xc475
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rcx
addq $0x10000, %rcx          # imm = 0x10000
movq -0x20(%rbp), %rax
movq %rcx, 0x30(%rax)
xorl %eax, %eax
cmpq $0x12, -0x48(%rbp)
movb %al, -0x49(%rbp)
jne 0xc2c8
movzbl -0x40(%rbp), %ecx
xorl %eax, %eax
cmpl $0x1f, %ecx
movb %al, -0x49(%rbp)
jne 0xc2c8
movzbl -0x3f(%rbp), %eax
cmpl $0x8b, %eax
sete %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
andl $0x1, %edx
shll $0x1e, %edx
andl $0xbfffffff, %ecx       # imm = 0xBFFFFFFF
orl %edx, %ecx
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
shrl $0x1e, %ecx
andl $0x1, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x4a(%rbp)
je 0xc331
movzbl -0x3d(%rbp), %ecx
andl $0x4, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x4b(%rbp)
je 0xc32b
leaq -0x40(%rbp), %rax
addq $0xc, %rax
movl (%rax), %eax
subl $0x24342, %eax          # imm = 0x24342
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
sete %al
movb %al, -0x4b(%rbp)
movb -0x4b(%rbp), %al
movb %al, -0x4a(%rbp)
movb -0x4a(%rbp), %cl
movl $0x1, %edx
xorl %eax, %eax
testb $0x1, %cl
cmovnel %eax, %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
andl $0x1, %edx
shll $0x1f, %edx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl %edx, %ecx
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xc3e3
movzbl -0x3d(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0xc3e3
leaq -0x40(%rbp), %rax
addq $0xc, %rax
movl (%rax), %eax
subl $0x465a4152, %eax       # imm = 0x465A4152
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xc3e3
movl $0x1, %edi
leaq 0xe2d5c(%rip), %rsi     # 0xef0f6
leaq 0xe2d64(%rip), %rdx     # 0xef105
movb $0x0, %al
callq 0x1b030
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x11e30
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x45a0
movq -0x20(%rbp), %rdi
callq 0x45a0
callq 0x4050
movl $0x8, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0xc475
movl $0x10, %edi
callq 0x4650
movq -0x20(%rbp), %rcx
movq %rax, 0x38(%rcx)
cmpq $0x0, %rax
jne 0xc41b
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x45a0
movq -0x20(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0xc475
callq 0x11f40
movq -0x20(%rbp), %rcx
movq 0x38(%rcx), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0xc45e
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x45a0
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x45a0
movq -0x20(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0xc475
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movl $0x0, 0x8(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nop