// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/razf.c
// Function: razf_write
int razf_write(RAZF* rz, const void *data, int size){
	int ori_size, n;
	int64_t next_block;
	ori_size = size;
	next_block = ((rz->in / RZ_BLOCK_SIZE) + 1) * RZ_BLOCK_SIZE;
	while(rz->in + rz->buf_len + size >= next_block){
		n = next_block - rz->in - rz->buf_len;
		_razf_buffered_write(rz, data, n);
		data += n;
		size -= n;
		razf_flush(rz);
		add_zindex(rz, rz->in, rz->out);
		next_block = ((rz->in / RZ_BLOCK_SIZE) + 1) * RZ_BLOCK_SIZE;
	}
	_razf_buffered_write(rz, data, size);
	return ori_size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x20(%rdi), %rcx
leaq 0x7fff(%rcx), %r12
testq %rcx, %rcx
cmovnsq %rcx, %r12
movq %rsi, %r15
andq $-0x8000, %r12          # imm = 0x8000
addq $0x8000, %r12           # imm = 0x8000
movslq 0x84(%rdi), %rax
addq %rcx, %rax
movslq %edx, %rcx
addq %rax, %rcx
cmpq %r12, %rcx
movl %edx, 0x4(%rsp)
jge 0x1227d
movl %edx, %ebp
jmp 0x1242d
movl $0x1000, %r13d          # imm = 0x1000
movl %edx, %ebp
subq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
movl %r12d, %edx
callq 0x1244d
movl 0x84(%r14), %edx
testl %edx, %edx
je 0x122b8
movq 0x60(%r14), %rsi
movq %r14, %rdi
callq 0x13300
movq $0x0, 0x80(%r14)
movq 0x10(%r14), %rax
movl 0x20(%rax), %eax
testl %eax, %eax
je 0x122e7
movl 0x8(%r14), %edi
movq 0x68(%r14), %rsi
movl $0x1000, %edx           # imm = 0x1000
subl %eax, %edx
callq 0x3190
movq 0x10(%r14), %rax
movl %r13d, 0x20(%rax)
movq 0x68(%r14), %rcx
movq %rcx, 0x18(%rax)
movq 0x10(%r14), %rdi
movl 0x20(%rdi), %ebx
movl $0x3, %esi
callq 0x3250
movq 0x10(%r14), %rax
movl 0x20(%rax), %eax
subl %eax, %ebx
addq 0x28(%r14), %rbx
movq %rbx, 0x28(%r14)
testl %eax, %eax
jne 0x12347
movl 0x8(%r14), %edi
movq 0x68(%r14), %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x3190
movq 0x10(%r14), %rdi
movl %r13d, 0x20(%rdi)
movq 0x68(%r14), %rax
movq %rax, 0x18(%rdi)
movl $0x3, %esi
callq 0x3250
movq 0x10(%r14), %rax
movl 0x20(%rax), %eax
movl $0x1000, %ebx           # imm = 0x1000
jmp 0x122ff
movq %rbx, 0x48(%r14)
movq $0x0, 0x50(%r14)
movq 0x18(%r14), %rax
movq 0x28(%r14), %rbx
movl 0x14(%rax), %ecx
cmpl %ecx, 0x10(%rax)
jne 0x123b5
cvtsi2sd %ecx, %xmm0
mulsd 0x93c9(%rip), %xmm0     # 0x1b738
addsd 0x93c9(%rip), %xmm0     # 0x1b740
cvttsd2si %xmm0, %ecx
movl %ecx, 0x14(%rax)
movq (%rax), %rdi
movslq %ecx, %rsi
shlq $0x2, %rsi
callq 0x3430
movq 0x18(%r14), %rcx
movq %rax, (%rcx)
movq 0x8(%rcx), %rdi
movslq 0x14(%rcx), %rax
shrq $0x11, %rax
leaq 0x8(,%rax,8), %rsi
callq 0x3430
movq 0x18(%r14), %rcx
movq %rax, 0x8(%rcx)
movq 0x18(%r14), %rax
movslq 0x10(%rax), %rcx
testl $0x1ffff, %ecx          # imm = 0x1FFFF
jne 0x123d4
movq 0x8(%rax), %rdx
movq %rcx, %rsi
shrq $0xe, %rsi
movq %rbx, (%rdx,%rsi)
movslq %r12d, %rdx
addq %rdx, %r15
subl %r12d, %ebp
movq (%rax), %rdx
movq 0x8(%rax), %rsi
movq %rcx, %rdi
shrq $0x11, %rdi
subl (%rsi,%rdi,8), %ebx
movl %ebx, (%rdx,%rcx,4)
incl 0x10(%rax)
movq 0x20(%r14), %rcx
leaq 0x7fff(%rcx), %r12
testq %rcx, %rcx
cmovnsq %rcx, %r12
andq $-0x8000, %r12          # imm = 0x8000
addq $0x8000, %r12           # imm = 0x8000
movslq 0x84(%r14), %rax
addq %rcx, %rax
movslq %ebp, %rcx
addq %rax, %rcx
cmpq %r12, %rcx
jge 0x12285
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x1244d
movl 0x4(%rsp), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq