// File: /workspace/github_c_makefile_star2_O1/jarun[P]nnn/src/nnn.c
// Function: initcurses
static bool initcurses(void *oldmask)
{
#ifdef NOMOUSE
	(void) oldmask;
#endif

	if (g_state.picker) {
		if (!newterm(NULL, stderr, stdin)) {
			msg("newterm!");
			return FALSE;
		}
	} else if (!initscr()) {
		msg("initscr!");
		DPRINTF_S(getenv("TERM"));
		return FALSE;
	}

	cbreak();
	noecho();
	nonl();
	//intrflush(stdscr, FALSE);
	keypad(stdscr, TRUE);
#ifndef NOMOUSE
#if NCURSES_MOUSE_VERSION <= 1
	mousemask(BUTTON1_PRESSED | BUTTON1_DOUBLE_CLICKED | BUTTON2_PRESSED | BUTTON3_PRESSED,
		  (mmask_t *)oldmask);
#else
	mousemask(BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED | BUTTON4_PRESSED
		  | BUTTON5_PRESSED, (mmask_t *)oldmask);
#endif
	mouseinterval(0);
#endif
	curs_set(FALSE); /* Hide cursor */

	char *colors = getenv(env_cfg[NNN_COLORS]);

	if (colors || !getenv("NO_COLOR")) {
		uint_t *pcode;
		bool ext = FALSE;

		start_color();
		use_default_colors();

		/* Initialize file colors */
		if (COLORS >= COLOR_256) {
			if (!(g_state.oldcolor || init_fcolors())) {
				exitcurses();
				msg(env_cfg[NNN_FCOLORS]);
				return FALSE;
			}
		} else
			g_state.oldcolor = 1;

		DPRINTF_D(COLORS);
		DPRINTF_D(COLOR_PAIRS);

		if (colors && *colors == '#') {
			char *sep = strchr(colors, ';');

			if (!g_state.oldcolor && COLORS >= COLOR_256) {
				++colors;
				ext = TRUE;

				/*
				 * If fallback colors are specified, set the separator
				 * to NULL so we don't interpret separator and fallback
				 * if fewer than CTX_MAX xterm 256 colors are specified.
				 */
				if (sep)
					*sep = '\0';
			} else {
				colors = sep; /* Detect if 8 colors fallback is appended */
				if (colors)
					++colors;
			}
		}

		/* Get and set the context colors */
		for (uchar_t i = 0; i < CTX_MAX; ++i) {
			pcode = &g_ctx[i].color;

			if (colors && *colors) {
				if (ext) {
					*pcode = xchartohex(*colors) << 4;
					if (*++colors)
						fcolors[i + 1] = *pcode += xchartohex(*colors);
					else { /* Each color code must be 2 hex symbols */
						exitcurses();
						msg(env_cfg[NNN_COLORS]);
						return FALSE;
					}
				} else {
					*pcode = (*colors < '0' || *colors > '7') ? 4 : *colors - '0';
					fcolors[i + 1] = *pcode;
				}
				++colors;
			} else
				*pcode = 4;

			init_pair(i + 1, *pcode, -1);
		}
	}
#ifdef ICONS_ENABLED
	if (!g_state.oldcolor) {
		for (uint_t i = 0; i < ELEMENTS(init_colors); ++i)
			init_pair(C_UND + 1 + init_colors[i], init_colors[i], -1);
	}
#endif

	settimeout(); /* One second */
	set_escdelay(25);
	return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
testb $0x10, 0x13635(%rip)    # 0x1a525
jne 0x6f06
callq 0x4650
testq %rax, %rax
jne 0x6f2a
callq 0x4bed
jmp 0x7233
movq 0x130eb(%rip), %rax     # 0x19ff8
movq (%rax), %rsi
movq 0x13061(%rip), %rax     # 0x19f78
movq (%rax), %rdx
xorl %edi, %edi
callq 0x4230
testq %rax, %rax
je 0x7227
callq 0x45a0
callq 0x4060
callq 0x47d0
movq 0x13050(%rip), %rax     # 0x19f90
movq (%rax), %rdi
movl $0x1, %esi
callq 0x4410
movl $0x210842, %edi         # imm = 0x210842
movq %rbx, %rsi
callq 0x4770
xorl %edi, %edi
callq 0x44a0
xorl %edi, %edi
callq 0x4140
leaq 0xe8af(%rip), %rdi      # 0x1581e
callq 0x4050
movq %rax, %rbx
testq %rax, %rax
je 0x70e7
callq 0x4030
callq 0x4040
movq 0x13027(%rip), %r12     # 0x19fb8
cmpl $0x100, (%r12)          # imm = 0x100
movl 0x13585(%rip), %eax     # 0x1a524
jl 0x70a2
btl $0xa, %eax
jb 0x70ad
leaq 0xe873(%rip), %rdi      # 0x15829
callq 0x4050
testq %rax, %rax
je 0x6fc8
movq %rax, %r14
cmpb $0x0, (%rax)
jne 0x6fcf
leaq 0xf731(%rip), %r14      # 0x16700
movb (%r14), %cl
testb %cl, %cl
sete %al
je 0x7094
movl $0x5, %r13d
leaq 0x1d096(%rip), %r15     # 0x24080
movzbl %cl, %edx
leal -0x30(%rdx), %esi
cmpl $0x9, %esi
jbe 0x7017
leal -0x61(%rcx), %esi
cmpb $0x5, %sil
ja 0x7005
addb $-0x57, %cl
movl %ecx, %esi
jmp 0x7017
leal -0x41(%rcx), %esi
addb $-0x37, %cl
cmpb $0x6, %sil
movzbl %cl, %ecx
cmovbl %ecx, %edx
movl %edx, %esi
movzbl %sil, %ecx
shll $0x4, %ecx
movl %ecx, (%r15,%r13,4)
movzbl -0x9(%r14,%r13,2), %edx
testl %edx, %edx
je 0x7094
leal -0x30(%rdx), %eax
cmpl $0x9, %eax
jbe 0x7051
leal -0x61(%rdx), %eax
cmpb $0x5, %al
ja 0x7042
addb $-0x57, %dl
movl %edx, %eax
jmp 0x7051
leal -0x41(%rdx), %eax
leal -0x37(%rdx), %esi
cmpb $0x6, %al
movzbl %sil, %eax
cmovael %edx, %eax
leaq (,%r13,4), %rdx
movzbl %al, %eax
addl %eax, %ecx
movl %ecx, (%rdx,%r15)
je 0x7075
movswl %cx, %esi
movswl %r13w, %edi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4600
movb -0x8(%r14,%r13,2), %cl
testb %cl, %cl
sete %dl
cmpq $0x10, %r13
leaq 0x1(%r13), %r13
setae %al
orb %dl, %al
cmpb $0x1, %al
jne 0x6fea
testb $0x1, %al
jne 0x70ad
callq 0x4ba1
jmp 0x7233
orl $0x400, %eax            # imm = 0x400
movl %eax, 0x13477(%rip)     # 0x1a524
testq %rbx, %rbx
je 0x7101
cmpb $0x23, (%rbx)
jne 0x7110
movq %rbx, %rdi
movl $0x3b, %esi
callq 0x4310
testb $0x4, 0x1345a(%rip)     # 0x1a525
jne 0x7105
cmpl $0x100, (%r12)          # imm = 0x100
jl 0x7105
incq %rbx
movb $0x1, %bpl
testq %rax, %rax
je 0x7112
movb $0x0, (%rax)
jmp 0x7112
leaq 0xf1b5(%rip), %rdi      # 0x162a3
callq 0x4050
testq %rax, %rax
jne 0x71f8
jmp 0x6f80
xorl %ebx, %ebx
jmp 0x7110
leaq 0x1(%rax), %rbx
testq %rax, %rax
cmoveq %rax, %rbx
xorl %ebp, %ebp
movl $0x1, %r14d
leaq 0x16ba5(%rip), %r12     # 0x1dcc4
leaq 0x1cf5a(%rip), %r13     # 0x24080
movl $0x4, %r15d
testq %rbx, %rbx
je 0x7153
movzbl (%rbx), %eax
testl %eax, %eax
je 0x7153
testb %bpl, %bpl
je 0x715d
leal -0x30(%rax), %ecx
cmpl $0x9, %ecx
jbe 0x7180
leal -0x61(%rax), %ecx
cmpb $0x5, %cl
ja 0x7171
addb $-0x57, %al
movl %eax, %ecx
jmp 0x7180
movl $0x4, (%r12)
jmp 0x71d1
leal -0x38(%rax), %ecx
addb $-0x30, %al
cmpb $-0x8, %cl
movzbl %al, %eax
cmovbl %r15d, %eax
movsbl %al, %eax
jmp 0x71c5
leal -0x41(%rax), %ecx
leal -0x37(%rax), %edx
cmpb $0x6, %cl
movzbl %dl, %ecx
cmovael %eax, %ecx
movzbl %cl, %eax
shll $0x4, %eax
movl %eax, (%r12)
movzbl 0x1(%rbx), %ecx
testl %ecx, %ecx
je 0x722e
leal -0x30(%rcx), %edx
cmpl $0x9, %edx
jbe 0x71bd
leal -0x61(%rcx), %edx
cmpb $0x5, %dl
ja 0x71ad
addb $-0x57, %cl
movl %ecx, %edx
jmp 0x71bd
leal -0x41(%rcx), %edx
leal -0x37(%rcx), %esi
cmpb $0x6, %dl
movzbl %sil, %edx
cmovael %ecx, %edx
incq %rbx
movzbl %dl, %ecx
addl %ecx, %eax
movl %eax, (%r12)
movl %eax, (%r13,%r14,4)
incq %rbx
movswl (%r12), %esi
movswl %r14w, %edi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4600
incq %r14
addq $0x2138, %r12           # imm = 0x2138
cmpq $0x5, %r14
jne 0x712c
movq 0x12d91(%rip), %rax     # 0x19f90
movq (%rax), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x4560
movl $0x19, %edi
callq 0x4390
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4b82
jmp 0x7233
callq 0x4bc7
xorl %eax, %eax
jmp 0x7218