// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/knetfile.c
// Function: kftp_connect_file
int kftp_connect_file(knetFile *fp)
{
	int ret;
	long long file_size;
	if (fp->fd != -1) {
		netclose(fp->fd);
		if (fp->no_reconnect) kftp_get_response(fp);
	}
	kftp_pasv_prep(fp);
    kftp_send_cmd(fp, fp->size_cmd, 1);
#ifndef _WIN32
    if ( sscanf(fp->response,"%*d %lld", &file_size) != 1 )
    {
        fprintf(stderr,"[kftp_connect_file] %s\n", fp->response);
        return -1;
    }
#else
	const char *p = fp->response;
	while (*p != ' ') ++p;
	while (*p < '0' || *p > '9') ++p;
	file_size = strtoint64(p);
#endif
	fp->file_size = file_size;
	if (fp->offset>=0) {
		char tmp[32];
#ifndef _WIN32
		sprintf(tmp, "REST %lld\r\n", (long long)fp->offset);
#else
		strcpy(tmp, "REST ");
		int64tostr(tmp + 5, fp->offset);
		strcat(tmp, "\r\n");
#endif
		kftp_send_cmd(fp, tmp, 1);
	}
	kftp_send_cmd(fp, fp->retr, 0);
	kftp_pasv_connect(fp);
	ret = kftp_get_response(fp);
	if (ret != 150) {
		fprintf(stderr, "[kftp_connect_file] %s\n", fp->response);
		netclose(fp->fd);
		fp->fd = -1;
		return -1;
	}
	fp->is_ready = 1;
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rdi, %rbx
movl 0x4(%rdi), %edi
cmpl $-0x1, %edi
je 0x1578a
callq 0x3270
cmpl $0x0, 0x3c(%rbx)
je 0x1578a
movq %rbx, %rdi
callq 0x1546e
leaq 0x4(%rbx), %r14
leaq 0x76b4(%rip), %rsi      # 0x1ce49
movq %rbx, %rdi
movl $0x1, %edx
callq 0x1559d
leaq 0x48(%rbx), %r15
movq 0x48(%rbx), %rdi
incq %rdi
movzbl -0x1(%rdi), %eax
testl %eax, %eax
je 0x1580d
cmpl $0x28, %eax
jne 0x157aa
leaq 0x14(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0x1c(%rsp), %r9
leaq 0x20(%rsp), %r10
leaq 0x24(%rsp), %r11
leaq 0x7676(%rip), %rsi      # 0x1ce50
leaq 0x10(%rsp), %r12
movq %r12, %rdx
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x3410
addq $0x10, %rsp
movaps (%r12), %xmm0
movups %xmm0, 0x24(%rbx)
movl 0x10(%r12), %eax
shll $0x8, %eax
movzwl %ax, %eax
addl 0x14(%r12), %eax
movl %eax, 0x34(%rbx)
movq 0x58(%rbx), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x1559d
movq 0x48(%rbx), %rdi
leaq 0x74c5(%rip), %rsi      # 0x1ccee
leaq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x3410
cmpl $0x1, %eax
jne 0x158fb
movq 0x8(%rsp), %rax
movq %rax, 0x68(%rbx)
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
js 0x15876
leaq 0x74b8(%rip), %rsi      # 0x1cd0f
leaq 0x10(%rsp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x3510
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x1559d
movq 0x50(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1559d
cmpl $0x0, 0x34(%rbx)
je 0x15905
movl 0x24(%rbx), %edx
movl 0x28(%rbx), %ecx
movl 0x2c(%rbx), %r8d
movl 0x30(%rbx), %r9d
leaq 0x7604(%rip), %rsi      # 0x1cea3
leaq 0x10(%rsp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x3510
movl 0x34(%rbx), %edx
leaq 0x517e(%rip), %rsi      # 0x1aa36
leaq 0x66(%rsp), %r13
movq %r13, %rdi
xorl %eax, %eax
callq 0x3510
movq %r12, %rdi
movq %r13, %rsi
callq 0x15378
movl %eax, 0x4(%rbx)
movq %rbx, %rdi
callq 0x1546e
cmpl $0x96, %eax
jne 0x1590c
movl $0x1, 0x40(%rbx)
xorl %eax, %eax
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %r15, %rdi
callq 0x44a8
jmp 0x15917
callq 0x44cc
jmp 0x158d5
movq %r15, %rdi
movq %r14, %rsi
callq 0x44ee
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x158ed