// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/samtools-0.1.18/razf.c
// Function: razf_open_w
static RAZF* razf_open_w(int fd){
	RAZF *rz;
#ifdef _WIN32
	setmode(fd, O_BINARY);
#endif
	rz = calloc(1, sizeof(RAZF));
	rz->mode = 'w';
#ifdef _USE_KNETFILE
    rz->x.fpw = fd;
#else
	rz->filedes = fd;
#endif
	rz->stream = calloc(sizeof(z_stream), 1);
	rz->inbuf  = malloc(RZ_BUFFER_SIZE);
	rz->outbuf = malloc(RZ_BUFFER_SIZE);
	rz->index = calloc(sizeof(ZBlockIndex), 1);
	deflateInit2(rz->stream, RZ_COMPRESS_LEVEL, Z_DEFLATED, WINDOW_BITS + 16, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
	rz->stream->avail_out = RZ_BUFFER_SIZE;
	rz->stream->next_out  = rz->outbuf;
	rz->header = calloc(sizeof(gz_header), 1);
	rz->header->os    = 0x03; //Unix
	rz->header->text  = 0;
	rz->header->time  = 0;
	rz->header->extra = malloc(7);
	strncpy((char*)rz->header->extra, "RAZF", 4);
	rz->header->extra[4] = 1; // obsolete field
	// block size = RZ_BLOCK_SIZE, Big-Endian
	rz->header->extra[5] = RZ_BLOCK_SIZE >> 8;
	rz->header->extra[6] = RZ_BLOCK_SIZE & 0xFF;
	rz->header->extra_len = 7;
	rz->header->name = rz->header->comment  = 0;
	rz->header->hcrc = 0;
	deflateSetHeader(rz->stream, rz->header);
	rz->block_pos = rz->block_off = 0;
	return rz;
}

// Assembly:
subq $0x28, %rsp
movl %edi, 0x24(%rsp)
movl $0x1, %edi
movl $0x98, %esi
callq 0x194a0
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movb $0x77, (%rax)
movl 0x24(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x8(%rax)
movl $0x70, %edi
movl $0x1, %esi
callq 0x194a0
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x10(%rax)
movl $0x1000, %edi           # imm = 0x1000
callq 0x19ef8
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x60(%rax)
movl $0x1000, %edi           # imm = 0x1000
callq 0x19ef8
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x68(%rax)
movl $0x18, %edi
movl $0x1, %esi
callq 0x194a0
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rdi
movl $0x6, %esi
movl $0x8, %r8d
movl $0x1f, %ecx
xorl %r9d, %r9d
leaq 0xa6d87(%rip), %rax     # 0x5a2e0c
movl %r8d, %edx
movq %rax, (%rsp)
movl $0x70, 0x8(%rsp)
callq 0x3afc70
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movl $0x1000, 0x20(%rax)     # imm = 0x1000
movq 0x18(%rsp), %rax
movq 0x68(%rax), %rcx
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x18(%rax)
movl $0x50, %edi
movl $0x1, %esi
callq 0x194a0
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x78(%rax)
movq 0x18(%rsp), %rax
movq 0x78(%rax), %rax
movl $0x3, 0x14(%rax)
movq 0x18(%rsp), %rax
movq 0x78(%rax), %rax
movl $0x0, (%rax)
movq 0x18(%rsp), %rax
movq 0x78(%rax), %rax
movq $0x0, 0x8(%rax)
movl $0x7, %edi
callq 0x19ef8
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq 0x78(%rax), %rax
movq %rcx, 0x18(%rax)
movq 0x18(%rsp), %rax
movq 0x78(%rax), %rax
movq 0x18(%rax), %rdi
leaq 0xc0d90(%rip), %rsi     # 0x5bcec8
movl $0x4, %edx
callq 0x19330
movq 0x18(%rsp), %rax
movq 0x78(%rax), %rax
movq 0x18(%rax), %rax
movb $0x1, 0x4(%rax)
movq 0x18(%rsp), %rax
movq 0x78(%rax), %rax
movq 0x18(%rax), %rax
movb $-0x80, 0x5(%rax)
movq 0x18(%rsp), %rax
movq 0x78(%rax), %rax
movq 0x18(%rax), %rax
movb $0x0, 0x6(%rax)
movq 0x18(%rsp), %rax
movq 0x78(%rax), %rax
movl $0x7, 0x20(%rax)
movq 0x18(%rsp), %rax
movq 0x78(%rax), %rax
movq $0x0, 0x38(%rax)
movq 0x18(%rsp), %rax
movq 0x78(%rax), %rax
movq $0x0, 0x28(%rax)
movq 0x18(%rsp), %rax
movq 0x78(%rax), %rax
movl $0x0, 0x44(%rax)
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x18(%rsp), %rax
movq 0x78(%rax), %rsi
callq 0x3b0f40
movq 0x18(%rsp), %rax
movq $0x0, 0x50(%rax)
movq 0x18(%rsp), %rax
movq $0x0, 0x48(%rax)
movq 0x18(%rsp), %rax
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)