// File: /workspace/github_c_makefile_star2_O3/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, 0x136ae(%rip)    # 0x1a525
jne 0x6e8d
callq 0x4650
testq %rax, %rax
jne 0x6eb1
callq 0x4be1
jmp 0x71a8
movq 0x13164(%rip), %rax     # 0x19ff8
movq (%rax), %rsi
movq 0x130da(%rip), %rax     # 0x19f78
movq (%rax), %rdx
xorl %edi, %edi
callq 0x4230
testq %rax, %rax
je 0x7195
callq 0x45a0
callq 0x4060
callq 0x47d0
movq 0x130c9(%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 0xe942(%rip), %rdi      # 0x15838
callq 0x4050
movq %rax, %rbx
testq %rax, %rax
je 0x7053
callq 0x4030
callq 0x4040
movq 0x130a0(%rip), %r12     # 0x19fb8
cmpl $0x100, (%r12)          # imm = 0x100
movl 0x135fe(%rip), %eax     # 0x1a524
jl 0x700e
btl $0xa, %eax
jb 0x7019
leaq 0xe906(%rip), %rdi      # 0x15843
callq 0x4050
testq %rax, %rax
je 0x6f50
movq %rax, %r14
movb (%rax), %al
testb %al, %al
jne 0x6f59
leaq 0xf7c9(%rip), %r14      # 0x16720
movb $0x63, %al
movl $0x5, %r13d
leaq 0x1d11a(%rip), %r15     # 0x24080
movzbl %al, %ecx
leal -0x30(%rcx), %edx
cmpl $0x9, %edx
jbe 0x6f8f
leal -0x61(%rax), %edx
cmpb $0x5, %dl
ja 0x6f7f
addb $-0x57, %al
movl %eax, %edx
jmp 0x6f8f
leal -0x41(%rax), %edx
addb $-0x37, %al
cmpb $0x6, %dl
movzbl %al, %eax
cmovbl %eax, %ecx
movl %ecx, %edx
movzbl %dl, %eax
shll $0x4, %eax
movl %eax, (%r15,%r13,4)
movzbl -0x9(%r14,%r13,2), %ecx
testl %ecx, %ecx
je 0x719c
leal -0x30(%rcx), %edx
cmpl $0x9, %edx
jbe 0x6fce
leal -0x61(%rcx), %edx
cmpb $0x5, %dl
ja 0x6fbe
addb $-0x57, %cl
movl %ecx, %edx
jmp 0x6fce
leal -0x41(%rcx), %edx
leal -0x37(%rcx), %esi
cmpb $0x6, %dl
movzbl %sil, %edx
cmovael %ecx, %edx
leaq (,%r13,4), %rcx
movzbl %dl, %edx
addl %edx, %eax
movl %eax, (%rcx,%r15)
je 0x6ff2
movswl %ax, %esi
movswl %r13w, %edi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4600
movb -0x8(%r14,%r13,2), %al
testb %al, %al
je 0x7019
leaq 0x1(%r13), %rcx
cmpq $0xf, %r13
movq %rcx, %r13
jbe 0x6f66
jmp 0x7019
orl $0x400, %eax            # imm = 0x400
movl %eax, 0x1350b(%rip)     # 0x1a524
testq %rbx, %rbx
je 0x706d
cmpb $0x23, (%rbx)
jne 0x707c
movq %rbx, %rdi
movl $0x3b, %esi
callq 0x4310
testb $0x4, 0x134ee(%rip)     # 0x1a525
jne 0x7071
cmpl $0x100, (%r12)          # imm = 0x100
jl 0x7071
incq %rbx
movb $0x1, %bpl
testq %rax, %rax
je 0x707e
movb $0x0, (%rax)
jmp 0x707e
leaq 0xf263(%rip), %rdi      # 0x162bd
callq 0x4050
testq %rax, %rax
jne 0x7166
jmp 0x6f07
xorl %ebx, %ebx
jmp 0x707c
leaq 0x1(%rax), %rbx
testq %rax, %rax
cmoveq %rax, %rbx
xorl %ebp, %ebp
movl $0x1, %r14d
leaq 0x16c39(%rip), %r12     # 0x1dcc4
leaq 0x1cfee(%rip), %r13     # 0x24080
movl $0x4, %r15d
testq %rbx, %rbx
je 0x70bf
movzbl (%rbx), %eax
testl %eax, %eax
je 0x70bf
testb %bpl, %bpl
je 0x70cd
leal -0x30(%rax), %ecx
cmpl $0x9, %ecx
jbe 0x70f0
leal -0x61(%rax), %ecx
cmpb $0x5, %cl
ja 0x70e1
addb $-0x57, %al
movl %eax, %ecx
jmp 0x70f0
movl $0x4, (%r12)
movw $0x4, %ax
jmp 0x7141
leal -0x38(%rax), %ecx
addb $-0x30, %al
cmpb $-0x8, %cl
movzbl %al, %eax
cmovbl %r15d, %eax
movsbl %al, %eax
jmp 0x7135
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 0x71a3
leal -0x30(%rcx), %edx
cmpl $0x9, %edx
jbe 0x712d
leal -0x61(%rcx), %edx
cmpb $0x5, %dl
ja 0x711d
addb $-0x57, %cl
movl %ecx, %edx
jmp 0x712d
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 %ax, %esi
movswl %r14w, %edi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4600
incq %r14
addq $0x2138, %r12           # imm = 0x2138
cmpq $0x5, %r14
jne 0x7098
movq 0x12e23(%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 0x4b76
jmp 0x71a8
callq 0x4bbb
jmp 0x71a8
callq 0x4b95
xorl %eax, %eax
jmp 0x7186