// File: /workspace/github_c_makefile_star2_O0/uhlin[P]enhanced-duc/source/main.c
// Function: server_response
static response_code_t
server_response(const char *buf)
{
	char *dump, *cp, *r;
	static const struct responses_tag {
		char *str;
		response_code_t code;
	} responses[] = {
		{ "good",     CODE_GOOD       },
		{ "nochg",    CODE_NOCHG      },
		{ "nohost",   CODE_NOHOST     },
		{ "badauth",  CODE_BADAUTH    },
		{ "badagent", CODE_BADAGENT   },
		{ "!donator", CODE_NOTDONATOR },
		{ "abuse",    CODE_ABUSE      },
		{ "911",      CODE_EMERG      },
	};

	dump = cp = r = NULL;

	if (buf == NULL || strings_match(buf, "")) {
		return CODE_UNKNOWN;
	} else {
		char	*buf_copy = xstrdup(buf);
		char	*buf_ptr = NULL;

		while ((buf_ptr = strpbrk(buf_copy, "\r\n")) != NULL) {
			if (*buf_ptr == '\r') {
				*buf_ptr = 'R';
			} else {
				*buf_ptr = 'N';
			}
		}

		log_debug("server_response: the buffer looks like this: %s",
		    buf_copy);
		free(buf_copy);
	}

	dump = trim(xstrdup(buf));
	if ((cp = strrchr(dump, '\n')) == NULL) {
		free(dump);
		return CODE_UNKNOWN;
	}
	r = strToLower(xstrdup(++cp));
	free(dump);
	log_debug("server_response: r = \"%s\"", r);

	if (!strncmp(r, "good ", 5)) {
		free(r);
		return CODE_GOOD;
	} else if (!strncmp(r, "nochg ", 6)) {
		free(r);
		return CODE_NOCHG;
	}

	for (const struct responses_tag *ar_p = &responses[0];
	     ar_p < &responses[nitems(responses)]; ar_p++) {
		if (strings_match(ar_p->str, r)) {
			free(r);
			return ar_p->code;
		}
	}

	free(r);
	return CODE_UNKNOWN;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x7151
movq -0x10(%rbp), %rdi
leaq 0x4ee5(%rip), %rsi      # 0xc02b
callq 0x6db0
testb $0x1, %al
jne 0x7151
jmp 0x715d
movl $0x8, -0x4(%rbp)
jmp 0x7305
movq -0x10(%rbp), %rdi
callq 0xa610
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x4eac(%rip), %rsi      # 0xc029
callq 0x4760
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x71aa
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
jne 0x71a1
movq -0x38(%rbp), %rax
movb $0x52, (%rax)
jmp 0x71a8
movq -0x38(%rbp), %rax
movb $0x4e, (%rax)
jmp 0x7172
movq -0x30(%rbp), %rsi
leaq 0x4e77(%rip), %rdi      # 0xc02c
movb $0x0, %al
callq 0x6170
movq -0x30(%rbp), %rdi
callq 0x4510
movq -0x10(%rbp), %rdi
callq 0xa610
movq %rax, %rdi
callq 0xa310
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movl $0xa, %esi
callq 0x44a0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x7207
movq -0x18(%rbp), %rdi
callq 0x4510
movl $0x8, -0x4(%rbp)
jmp 0x7305
movq -0x20(%rbp), %rdi
addq $0x1, %rdi
movq %rdi, -0x20(%rbp)
callq 0xa610
movq %rax, %rdi
callq 0xa240
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4510
movq -0x28(%rbp), %rsi
leaq 0x4e24(%rip), %rdi      # 0xc05c
movb $0x0, %al
callq 0x6170
movq -0x28(%rbp), %rdi
leaq 0x4e2c(%rip), %rsi      # 0xc076
movl $0x5, %edx
callq 0x41c0
cmpl $0x0, %eax
jne 0x726e
movq -0x28(%rbp), %rdi
callq 0x4510
movl $0x0, -0x4(%rbp)
jmp 0x7305
movq -0x28(%rbp), %rdi
leaq 0x4e03(%rip), %rsi      # 0xc07c
movl $0x6, %edx
callq 0x41c0
cmpl $0x0, %eax
jne 0x729a
movq -0x28(%rbp), %rdi
callq 0x4510
movl $0x1, -0x4(%rbp)
jmp 0x7305
jmp 0x729c
leaq 0x8a2d(%rip), %rax      # 0xfcd0
movq %rax, -0x40(%rbp)
leaq 0x8a22(%rip), %rax      # 0xfcd0
addq $0x80, %rax
cmpq %rax, -0x40(%rbp)
jae 0x72f5
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x6db0
testb $0x1, %al
jne 0x72d0
jmp 0x72e5
movq -0x28(%rbp), %rdi
callq 0x4510
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x7305
jmp 0x72e7
movq -0x40(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x40(%rbp)
jmp 0x72a7
movq -0x28(%rbp), %rdi
callq 0x4510
movl $0x8, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop