// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x186, -0x28(%rbp)     # imm = 0x186
movl $0x186, %edi            # imm = 0x186
movl $0x1, %esi
callq 0xa6d0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdx
leaq 0x3bb4(%rip), %rdi      # 0xc83d
leaq 0x3bb8(%rip), %rsi      # 0xc848
callq 0x8ea0
movq -0x20(%rbp), %rdx
leaq 0x3b9d(%rip), %rdi      # 0xc83d
leaq 0x3ba6(%rip), %rsi      # 0xc84d
callq 0x8ea0
movq 0x72cd(%rip), %rax      # 0xff80
movq (%rax), %rsi
leaq 0x2c66(%rip), %rdi      # 0xb923
callq 0x44d0
movq -0x10(%rbp), %rdi
callq 0x46b0
movq 0x72ae(%rip), %rax      # 0xff80
movq (%rax), %rsi
leaq 0x2c4d(%rip), %rdi      # 0xb929
callq 0x44d0
movq -0x20(%rbp), %rsi
leaq 0x3b6f(%rip), %rdi      # 0xc85b
movb $0x0, %al
callq 0x4060
movq 0x7286(%rip), %rax      # 0xff80
movq (%rax), %rdi
callq 0x44f0
movq -0x10(%rbp), %rdi
leaq 0x3b59(%rip), %rsi      # 0xc866
movl $0xe, %edx
callq 0x41c0
cmpl $0x0, %eax
jne 0x8d26
movl $0x1, %edi
callq 0xa420
movq -0x30(%rbp), %rdi
movq 0x726f(%rip), %rax      # 0xffa0
movq (%rax), %rdx
movl $0x186, %esi            # imm = 0x186
callq 0x46e0
cmpq $0x0, %rax
sete %al
andb $0x1, %al
movb %al, -0x31(%rbp)
callq 0x4050
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x3b07(%rip), %rsi      # 0xc866
movl $0xe, %edx
callq 0x41c0
cmpl $0x0, %eax
jne 0x8d7f
xorl %edi, %edi
callq 0xa420
movl $0xa, %edi
callq 0x4600
testb $0x1, -0x31(%rbp)
je 0x8d96
movl -0x38(%rbp), %edi
leaq 0x3ae6(%rip), %rsi      # 0xc875
movb $0x0, %al
callq 0x5fa0
movq -0x30(%rbp), %rdi
movl $0xa, %esi
callq 0x4170
cmpq $0x0, %rax
sete %al
andb $0x1, %al
movb %al, -0x39(%rbp)
movl $0xffffffff, -0x40(%rbp) # imm = 0xFFFFFFFF
testb $0x1, -0x39(%rbp)
je 0x8e17
movq 0x71fc(%rip), %rax      # 0xffc0
movq (%rax), %rdi
leaq 0x3ac5(%rip), %rsi      # 0xc893
leaq 0x3edb(%rip), %rdx      # 0xccb0
movb $0x0, %al
callq 0x4650
callq 0x45f0
movl %eax, -0x40(%rbp)
xorl %eax, %eax
cmpl $0xa, -0x40(%rbp)
movb %al, -0x41(%rbp)
je 0x8df9
cmpl $-0x1, -0x40(%rbp)
setne %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x8e02
jmp 0x8e04
jmp 0x8ddc
movq -0x30(%rbp), %rdi
callq 0x4510
movq $0x0, -0x8(%rbp)
jmp 0x8e91
movq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x3200(%rip), %rsi      # 0xc02a
callq 0x40a0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movb $0x0, (%rax,%rcx)
movq -0x30(%rbp), %rdi
leaq 0x31e6(%rip), %rsi      # 0xc02b
callq 0x8c20
testb $0x1, %al
jne 0x8e50
jmp 0x8e66
movq -0x30(%rbp), %rdi
callq 0x4510
movq -0x20(%rbp), %rdi
callq 0xa610
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x8f20
testb $0x1, %al
jne 0x8e89
movq -0x30(%rbp), %rdi
callq 0x4510
movq $0x0, -0x8(%rbp)
jmp 0x8e91
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)