// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/bgzf.c
// Function: bgzf_write_init
static BGZF *bgzf_write_init(const char *mode)
{
    BGZF *fp;
    fp = (BGZF*)calloc(1, sizeof(BGZF));
    fp->is_write = 1;
    int compress_level = mode2level(mode);
    if ( compress_level==-2 )
    {
        fp->is_compressed = 0;
        return fp;
    }
    fp->is_compressed = 1;
    fp->uncompressed_block = malloc(BGZF_MAX_BLOCK_SIZE);
    fp->compressed_block = malloc(BGZF_MAX_BLOCK_SIZE);
    fp->compress_level = compress_level < 0? Z_DEFAULT_COMPRESSION : compress_level; // Z_DEFAULT_COMPRESSION==-1
    if (fp->compress_level > 9) fp->compress_level = Z_DEFAULT_COMPRESSION;
    if ( strchr(mode,'g') )
    {
        // gzip output
        fp->is_gzip = 1;
        fp->gz_stream = (z_stream*)calloc(1,sizeof(z_stream));
        fp->gz_stream->zalloc = NULL;
        fp->gz_stream->zfree  = NULL;
        if ( deflateInit2(fp->gz_stream, fp->compress_level, Z_DEFLATED, 15|16, 8, Z_DEFAULT_STRATEGY)!=Z_OK ) return NULL;
    }
    return fp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0x1, %edi
movl $0x60, %esi
callq 0x6460
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
andl $0xfffcffff, %ecx       # imm = 0xFFFCFFFF
orl $0x10000, %ecx          # imm = 0x10000
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
callq 0x9e8d0
movl %eax, -0x1c(%rbp)
cmpl $-0x2, -0x1c(%rbp)
jne 0x9b353
movq -0x18(%rbp), %rax
movl (%rax), %ecx
andl $0x9fffffff, %ecx       # imm = 0x9FFFFFFF
orl $0x0, %ecx
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9b4a4
movq -0x18(%rbp), %rax
movl (%rax), %ecx
andl $0x9fffffff, %ecx       # imm = 0x9FFFFFFF
orl $0x20000000, %ecx       # imm = 0x20000000
movl %ecx, (%rax)
movl $0x10000, %edi          # imm = 0x10000
callq 0x69c0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movl $0x10000, %edi          # imm = 0x10000
callq 0x69c0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
cmpl $0x0, -0x1c(%rbp)
jge 0x9b3a1
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x20(%rbp)
jmp 0x9b3a7
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %edx
movq -0x18(%rbp), %rax
movl (%rax), %ecx
andl $0x1ff, %edx            # imm = 0x1FF
shll $0x14, %edx
andl $0xe00fffff, %ecx       # imm = 0xE00FFFFF
orl %edx, %ecx
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movl (%rax), %eax
shll $0x3, %eax
sarl $0x17, %eax
cmpl $0x9, %eax
jle 0x9b3e8
movq -0x18(%rbp), %rax
movl (%rax), %ecx
andl $0xe00fffff, %ecx       # imm = 0xE00FFFFF
orl $0x1ff00000, %ecx       # imm = 0x1FF00000
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movl $0x67, %esi
callq 0x6260
cmpq $0x0, %rax
je 0x9b49c
movq -0x18(%rbp), %rax
movl (%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, (%rax)
movl $0x1, %edi
movl $0x70, %esi
callq 0x6460
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq $0x0, 0x40(%rax)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq $0x0, 0x48(%rax)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %esi
shll $0x3, %esi
sarl $0x17, %esi
movl $0x8, %r8d
movl $0x1f, %ecx
xorl %r9d, %r9d
leaq 0x4722a(%rip), %rax     # 0xe26a1
movl %r8d, %edx
movq %rax, (%rsp)
movl $0x70, 0x8(%rsp)
callq 0x60a0
cmpl $0x0, %eax
je 0x9b49a
movq $0x0, -0x8(%rbp)
jmp 0x9b4a4
jmp 0x9b49c
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nop