// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/samtools-0.1.18/knetfile.c
// Function: kftp_get_response
static int kftp_get_response(knetFile *ftp)
{
#ifndef _WIN32
	unsigned char c;
#else
	char c;
#endif
	int n = 0;
	char *p;
	if (socket_wait(ftp->ctrl_fd, 1) <= 0) return 0;
	while (netread(ftp->ctrl_fd, &c, 1)) { // FIXME: this is *VERY BAD* for unbuffered I/O
		//fputc(c, stderr);
		if (n >= ftp->max_response) {
			ftp->max_response = ftp->max_response? ftp->max_response<<1 : 256;
			ftp->response = realloc(ftp->response, ftp->max_response);
		}
		ftp->response[n++] = c;
		if (c == '\n') {
			if (n >= 4 && isdigit(ftp->response[0]) && isdigit(ftp->response[1]) && isdigit(ftp->response[2])
				&& ftp->response[3] != '-') break;
			n = 0;
			continue;
		}
	}
	if (n < 2) return -1;
	ftp->response[n-2] = 0;
	return strtol(ftp->response, &p, 0);
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movl $0x0, 0x10(%rsp)
movq 0x18(%rsp), %rax
movl 0x20(%rax), %edi
movl $0x1, %esi
callq 0x4842f0
cmpl $0x0, %eax
jg 0x482d75
movl $0x0, 0x24(%rsp)
jmp 0x482f0c
jmp 0x482d77
movq 0x18(%rsp), %rax
movl 0x20(%rax), %edi
leaq 0x17(%rsp), %rsi
movl $0x1, %edx
callq 0x30190
cmpq $0x0, %rax
je 0x482ecb
movl 0x10(%rsp), %eax
movq 0x18(%rsp), %rcx
cmpl 0x38(%rcx), %eax
jl 0x482dfb
movq 0x18(%rsp), %rax
cmpl $0x0, 0x38(%rax)
je 0x482dc1
movq 0x18(%rsp), %rax
movl 0x38(%rax), %eax
shll %eax
movl %eax, 0x4(%rsp)
jmp 0x482dcc
movl $0x100, %eax            # imm = 0x100
movl %eax, 0x4(%rsp)
jmp 0x482dcc
movl 0x4(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x38(%rax)
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0x18(%rsp), %rax
movslq 0x38(%rax), %rsi
callq 0x340d0
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x48(%rax)
movb 0x17(%rsp), %dl
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rax
movl 0x10(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x10(%rsp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movzbl 0x17(%rsp), %eax
cmpl $0xa, %eax
jne 0x482ec6
cmpl $0x4, 0x10(%rsp)
jl 0x482eb9
callq 0x311d0
movq (%rax), %rax
movq 0x18(%rsp), %rcx
movq 0x48(%rcx), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x482eb9
callq 0x311d0
movq (%rax), %rax
movq 0x18(%rsp), %rcx
movq 0x48(%rcx), %rcx
movsbl 0x1(%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x482eb9
callq 0x311d0
movq (%rax), %rax
movq 0x18(%rsp), %rcx
movq 0x48(%rcx), %rcx
movsbl 0x2(%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x482eb9
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rax
movsbl 0x3(%rax), %eax
cmpl $0x2d, %eax
je 0x482eb9
jmp 0x482ecb
movl $0x0, 0x10(%rsp)
jmp 0x482d77
jmp 0x482d77
cmpl $0x2, 0x10(%rsp)
jge 0x482edc
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0x482f0c
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rax
movl 0x10(%rsp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x31c30
movl %eax, 0x24(%rsp)
movl 0x24(%rsp), %eax
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)