// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/kopen.c
// Function: kftp_get_response
static int kftp_get_response(ftpaux_t *aux)
{
	unsigned char c;
	int n = 0;
	char *p;
	if (socket_wait(aux->ctrl_fd, 1) <= 0) return 0;
	while (read(aux->ctrl_fd, &c, 1)) { // FIXME: this is *VERY BAD* for unbuffered I/O
		if (n >= aux->max_response) {
			aux->max_response = aux->max_response? aux->max_response<<1 : 256;
			aux->response = realloc(aux->response, aux->max_response);
		}
		aux->response[n++] = c;
		if (c == '\n') {
			if (n >= 4 && isdigit(aux->response[0]) && isdigit(aux->response[1]) && isdigit(aux->response[2])
				&& aux->response[3] != '-') break;
			n = 0;
			continue;
		}
	}
	if (n < 2) return -1;
	aux->response[n-2] = 0;
	return strtol(aux->response, &p, 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edi
movl $0x1, %esi
callq 0x7640
cmpl $0x0, %eax
jg 0x7405
movl $0x0, -0x4(%rbp)
jmp 0x758b
jmp 0x7407
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edi
leaq -0x11(%rbp), %rsi
movl $0x1, %edx
callq 0x34f0
cmpq $0x0, %rax
je 0x7551
movl -0x18(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jl 0x748c
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x7447
movq -0x10(%rbp), %rax
movl (%rax), %eax
shll %eax
movl %eax, -0x24(%rbp)
jmp 0x7451
movl $0x100, %eax            # imm = 0x100
movl %eax, -0x24(%rbp)
jmp 0x7451
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movslq (%rax), %rsi
leaq 0x3021f(%rip), %rdx     # 0x3768f
movl $0x9d, %ecx
leaq 0x302f2(%rip), %r8      # 0x3776e
callq 0x31d40
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movb -0x11(%rbp), %dl
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x18(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movzbl -0x11(%rbp), %eax
cmpl $0xa, %eax
jne 0x754c
cmpl $0x4, -0x18(%rbp)
jl 0x7540
callq 0x3310
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x7540
callq 0x3310
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movsbl 0x1(%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x7540
callq 0x3310
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movsbl 0x2(%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x7540
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x3(%rax), %eax
cmpl $0x2d, %eax
je 0x7540
jmp 0x7551
movl $0x0, -0x18(%rbp)
jmp 0x7407
jmp 0x7407
cmpl $0x2, -0x18(%rbp)
jge 0x7560
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x758b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x18(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x34c0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)