// File: /workspace/github_c_makefile_star2_O1/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 0x889a
testq %r15, %r15
je 0x7861
testq %r14, %r14
je 0x7878
movq %rax, %rbx
movq 0x686e(%rip), %r12      # 0xdf80
movq (%r12), %rsi
leaq 0x2086(%rip), %rdi      # 0x97a3
callq 0x44f0
movq %r15, %rdi
callq 0x46d0
movq (%r12), %rsi
leaq 0x2074(%rip), %rdi      # 0x97a9
callq 0x44f0
leaq 0x2f8e(%rip), %rdi      # 0xa6cf
movq %r14, %rsi
xorl %eax, %eax
callq 0x4060
movq (%r12), %rdi
callq 0x4520
leaq 0x2f7f(%rip), %rsi      # 0xa6da
movl $0xe, %edx
movq %r15, %rdi
callq 0x41d0
testl %eax, %eax
jne 0x7776
movl $0x1, %edi
callq 0x86a3
movq 0x6823(%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 0x2f3b(%rip), %rsi      # 0xa6da
movl $0xe, %edx
movq %r15, %rdi
callq 0x41d0
testl %eax, %eax
jne 0x77c1
xorl %edi, %edi
callq 0x86a3
movl $0xa, %edi
callq 0x4630
testq %r13, %r13
je 0x7899
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4180
testq %rax, %rax
je 0x7831
leaq 0x26c7(%rip), %rsi      # 0x9eaa
movq %rbx, %rdi
callq 0x40a0
movb $0x0, (%rbx,%rax)
cmpb $0x0, (%rbx)
jne 0x7807
movq %rbx, %rdi
callq 0x4540
movq %r14, %rdi
callq 0x880a
movq %rax, %rbx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x78aa
testb %al, %al
jne 0x781f
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 0x6788(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
leaq 0x2ec5(%rip), %rsi      # 0xa707
leaq 0x32e7(%rip), %rdx      # 0xab30
xorl %eax, %eax
callq 0x4680
callq 0x4620
cmpl $-0x1, %eax
je 0x7815
cmpl $0xa, %eax
jne 0x7850
jmp 0x7815
leaq 0x2973(%rip), %rsi      # 0xa1db
leaq 0x2e42(%rip), %rdx      # 0xa6b1
leaq 0x2e46(%rip), %rcx      # 0xa6bc
jmp 0x788d
leaq 0x295c(%rip), %rsi      # 0xa1db
leaq 0x2e2b(%rip), %rdx      # 0xa6b1
leaq 0x2e34(%rip), %rcx      # 0xa6c1
movl $0x16, %edi
xorl %eax, %eax
callq 0x563c
leaq 0x2e49(%rip), %rsi      # 0xa6e9
movl %r12d, %edi
xorl %eax, %eax
callq 0x563c