// File: /workspace/github_c_makefile_star2_O0/skoren[P]bacValidation/bamcat.c
// Function: bgzf_compress
static int bgzf_compress(void *_dst, int *dlen, void *src, int slen, int level)
{
	uint32_t crc;
	z_stream zs;
	uint8_t *dst = (uint8_t*)_dst;

	// compress the body
	zs.zalloc = NULL; zs.zfree = NULL;
	zs.next_in  = src;
	zs.avail_in = slen;
	zs.next_out = dst + BLOCK_HEADER_LENGTH;
	zs.avail_out = *dlen - BLOCK_HEADER_LENGTH - BLOCK_FOOTER_LENGTH;
	if (deflateInit2(&zs, level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) return -1; // -15 to disable zlib header/footer
	if (deflate(&zs, Z_FINISH) != Z_STREAM_END) return -1;
	if (deflateEnd(&zs) != Z_OK) return -1;
	*dlen = zs.total_out + BLOCK_HEADER_LENGTH + BLOCK_FOOTER_LENGTH;
	// write the header
	memcpy(dst, g_magic, BLOCK_HEADER_LENGTH); // the last two bytes are a place holder for the length of the block
	packInt16(&dst[16], *dlen - 1); // write the compressed length; -1 to fit 2 bytes
	// write the footer
	crc = crc32(crc32(0L, NULL, 0L), src, slen);
	packInt32((uint8_t*)&dst[*dlen - 8], crc);
	packInt32((uint8_t*)&dst[*dlen - 4], slen);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x98(%rbp)
movq -0xa8(%rbp), %rax
addq $0x12, %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl $0x12, %eax
subl $0x8, %eax
movl %eax, -0x80(%rbp)
movl -0x28(%rbp), %esi
leaq -0xa0(%rbp), %rdi
movl $0x8, %r8d
movl $0xfffffff1, %ecx       # imm = 0xFFFFFFF1
xorl %r9d, %r9d
leaq 0x4e07(%rip), %rax      # 0x126a4
movl %r8d, %edx
movq %rax, (%rsp)
movl $0x70, 0x8(%rsp)
callq 0x3070
cmpl $0x0, %eax
je 0xd8c2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd9b9
leaq -0xa0(%rbp), %rdi
movl $0x4, %esi
callq 0x3170
cmpl $0x1, %eax
je 0xd8e4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd9b9
leaq -0xa0(%rbp), %rdi
callq 0x31e0
cmpl $0x0, %eax
je 0xd901
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xd9b9
movq -0x78(%rbp), %rax
addq $0x12, %rax
addq $0x8, %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0xa8(%rbp), %rax
movq 0x4f9d(%rip), %rcx      # 0x128c0
movq %rcx, (%rax)
movq 0x4f9b(%rip), %rcx      # 0x128c8
movq %rcx, 0x8(%rax)
movw 0x4f98(%rip), %cx       # 0x128d0
movw %cx, 0x10(%rax)
movq -0xa8(%rbp), %rdi
addq $0x10, %rdi
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movzwl %ax, %esi
callq 0xd9d0
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
movq %rsi, %rdi
callq 0x3260
movq %rax, %rdi
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %edx
callq 0x3260
movl %eax, -0x2c(%rbp)
movq -0xa8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl $0x8, %eax
cltq
addq %rax, %rdi
movl -0x2c(%rbp), %esi
callq 0xda00
movq -0xa8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl $0x4, %eax
cltq
addq %rax, %rdi
movl -0x24(%rbp), %esi
callq 0xda00
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)