// File: /workspace/github_c_makefile_star2_O3/uhlin[P]enhanced-duc/source/settings.c
// Function: get_answer
char *
get_answer(const char *desc, enum setting_type type, const char *defaultAnswer)
{
	const size_t sz = 390;
	char *answer = xcalloc(sz, 1);

	log_assert_arg_nonnull("get_answer", "desc", desc);
	log_assert_arg_nonnull("get_answer", "defaultAnswer", defaultAnswer);

	(void) fputs(MAGENTA, stdout);
	(void) puts(desc);
	(void) fputs(NORMAL, stdout);

	(void) printf("Ans [%s]: ", defaultAnswer);
	(void) fflush(stdout);

	if (!strncmp(desc, "Your password.", 14))
		toggle_echo(OFF);
	const bool fgets_fail = fgets(answer, sz, stdin) == NULL;
	const int errno_save = errno;
	if (!strncmp(desc, "Your password.", 14)) {
		toggle_echo(ON);
		putchar('\n');
	}

	if (fgets_fail)
		fatal(errno_save, "get_answer: fatal: fgets fail");

	const bool input_too_big = strchr(answer, '\n') == NULL;
	int c = EOF;

	if (input_too_big) {
		fprintf(stderr, "%s get_answer: input too big!\n", GfxFailure);
		while (c = getchar(), c != '\n' && c != EOF)
			/* discard */;
		free(answer);
		return NULL;
	}

	/* trim newline */
	answer[strcspn(answer, "\n")] = '\0';

	if (strings_match(answer, "")) {
		free(answer);
		answer = xstrdup(defaultAnswer);
	}
	if (!is_setting_ok(answer, type)) {
		free(answer);
		return NULL;
	}
	return answer;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %r15
movl $0x186, %edi            # imm = 0x186
movl $0x1, %esi
callq 0x873e
testq %r15, %r15
je 0x7766
testq %r14, %r14
je 0x777d
movq %rax, %rbx
movq 0x6969(%rip), %r12      # 0xdf80
movq (%r12), %rsi
leaq 0x2181(%rip), %rdi      # 0x97a3
callq 0x44f0
movq %r15, %rdi
callq 0x46d0
movq (%r12), %rsi
leaq 0x216f(%rip), %rdi      # 0x97a9
callq 0x44f0
leaq 0x3086(%rip), %rdi      # 0xa6cc
movq %r14, %rsi
xorl %eax, %eax
callq 0x4060
movq (%r12), %rdi
callq 0x4520
leaq 0x3077(%rip), %rsi      # 0xa6d7
movl $0xe, %edx
movq %r15, %rdi
callq 0x41d0
testl %eax, %eax
jne 0x767b
movl $0x1, %edi
callq 0x8546
movq 0x691e(%rip), %rax      # 0xdfa0
movq (%rax), %rdx
movq %rbx, %rdi
movl $0x186, %esi            # imm = 0x186
callq 0x4700
movq %rax, %r13
callq 0x4050
movl (%rax), %r12d
leaq 0x3033(%rip), %rsi      # 0xa6d7
movl $0xe, %edx
movq %r15, %rdi
callq 0x41d0
testl %eax, %eax
jne 0x76c6
xorl %edi, %edi
callq 0x8546
movl $0xa, %edi
callq 0x4630
testq %r13, %r13
je 0x779e
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4180
testq %rax, %rax
je 0x7736
leaq 0x27c2(%rip), %rsi      # 0x9eaa
movq %rbx, %rdi
callq 0x40a0
movb $0x0, (%rbx,%rax)
cmpb $0x0, (%rbx)
jne 0x770c
movq %rbx, %rdi
callq 0x4540
movq %r14, %rdi
callq 0x86ae
movq %rax, %rbx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x77af
testb %al, %al
jne 0x7724
movq %rbx, %rdi
callq 0x4540
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x6883(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
leaq 0x2fbd(%rip), %rsi      # 0xa704
leaq 0x33d2(%rip), %rdx      # 0xab20
xorl %eax, %eax
callq 0x4680
callq 0x4620
cmpl $-0x1, %eax
je 0x771a
cmpl $0xa, %eax
jne 0x7755
jmp 0x771a
leaq 0x2a6e(%rip), %rsi      # 0xa1db
leaq 0x2f3a(%rip), %rdx      # 0xa6ae
leaq 0x2f3e(%rip), %rcx      # 0xa6b9
jmp 0x7792
leaq 0x2a57(%rip), %rsi      # 0xa1db
leaq 0x2f23(%rip), %rdx      # 0xa6ae
leaq 0x2f2c(%rip), %rcx      # 0xa6be
movl $0x16, %edi
xorl %eax, %eax
callq 0x55ac
leaq 0x2f41(%rip), %rsi      # 0xa6e6
movl %r12d, %edi
xorl %eax, %eax
callq 0x55ac