// File: /workspace/github_c_makefile_star2_O2/jarun[P]nnn/src/nnn.c
// Function: redraw
static void redraw(char *path)
{
	getmaxyx(stdscr, xlines, xcols);

	int ncols = (xcols <= PATH_MAX) ? xcols : PATH_MAX;
	int i, j = 1;

	// Fast redraw
	if (g_state.move) {
		g_state.move = 0;

		if (ndents && (last_curscroll == curscroll))
			return draw_line(ncols);
	}

	DPRINTF_S(__func__);

	/* Clear screen */
	erase();

	/* Enforce scroll/cursor invariants */
	move_cursor(cur, 1);

	/* Fail redraw if < than 10 columns, context info prints 10 chars */
	if (ncols <= MIN_DISPLAY_COL) {
		printmsg(messages[MSG_FEW_COLUMNS]);
		return;
	}

	//DPRINTF_D(cur);
	DPRINTF_S(path);

	for (i = 0; i < CTX_MAX; ++i) { /* 8 chars printed for contexts - "1 2 3 4 " */
		if (!g_ctx[i].c_cfg.ctxactive)
			addch(i + '1');
		else
			addch((i + '1') | (COLOR_PAIR(i + 1) | A_BOLD
				/* active: underline, current: reverse */
				| ((cfg.curctx != i) ? A_UNDERLINE : A_REVERSE)));

		addch(' ');
	}

	attron(A_UNDERLINE | COLOR_PAIR(cfg.curctx + 1));

	/* Print path */
	bool in_home = set_tilde_in_path(path);
	char *ptr = in_home ? &path[homelen - 1] : path;

	i = (int)xstrlen(ptr);
	if ((i + MIN_DISPLAY_COL) <= ncols)
		addnstr(ptr, ncols - MIN_DISPLAY_COL);
	else {
		char *base = xmemrchr((uchar_t *)ptr, '/', i);

		if (in_home) {
			addch(*ptr);
			++ptr;
			i = 1;
		} else
			i = 0;

		if (ptr && (base != ptr)) {
			while (ptr < base) {
				if (*ptr == '/') {
					i += 2; /* 2 characters added */
					if (ncols < i + MIN_DISPLAY_COL) {
						base = NULL; /* Can't print more characters */
						break;
					}

					addch(*ptr);
					addch(*(++ptr));
				}
				++ptr;
			}
		}

		if (base)
			addnstr(base, ncols - (MIN_DISPLAY_COL + i));
	}

	if (in_home)
		reset_tilde_in_path(path);

	attroff(A_UNDERLINE | COLOR_PAIR(cfg.curctx + 1));

	/* Go to first entry */
	if (curscroll > 0) {
		move(1, 0);
#ifdef ICONS_ENABLED
		addstr(ICON_ARROW_UP);
#else
		addch('^');
#endif
	}

	if (g_state.oldcolor) {
		attron(COLOR_PAIR(cfg.curctx + 1) | A_BOLD);
		g_state.dircolor = 1;
	}

	int onscreen = MIN(ONSCREEN + curscroll, ndents);
	int len = scanselforpath(path, FALSE);

	ncols = adjust_cols(ncols);

	/* Print listing */
	for (i = curscroll; i < onscreen; ++i) {
		move(++j, 0);

		if (len)
			findmarkentry(len, &pdents[i]);

		printent(i, ncols, i == cur);
	}

	/* Must reset e.g. no files in dir */
	if (g_state.dircolor) {
		attroff(COLOR_PAIR(cfg.curctx + 1) | A_BOLD);
		g_state.dircolor = 0;
	}

	/* Go to last entry */
	if (onscreen < ndents) {
		move(xlines - 2, 0);
#ifdef ICONS_ENABLED
		addstr(ICON_ARROW_DOWN);
#else
		addch('v');
#endif
	}

	markhovered();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r15
movq 0xa9bf(%rip), %r14      # 0x18f90
movq (%r14), %rdi
testq %rdi, %rdi
je 0xe5e6
movl 0x4(%rdi), %eax
incl %eax
movzwl 0x6(%rdi), %ebx
incl %ebx
jmp 0xe5ee
movw $0xffff, %ax            # imm = 0xFFFF
movw $0xffff, %bx            # imm = 0xFFFF
movw %ax, 0xc593(%rip)       # 0x1ab88
cmpw $0x1000, %bx            # imm = 0x1000
movl $0x1000, %eax           # imm = 0x1000
cmovbl %ebx, %eax
movw %bx, 0x14c8f(%rip)      # 0x23298
movzwl %ax, %r12d
movl 0xaf11(%rip), %eax      # 0x19524
btl $0x9, %eax
jae 0xe67f
andl $0xfffffdff, %eax       # imm = 0xFFFFFDFF
movl %eax, 0xaf00(%rip)      # 0x19524
cmpl $0x0, 0xc561(%rip)      # 0x1ab8c
je 0xe67f
movl 0x15cb5(%rip), %eax     # 0x242e8
cmpl 0x14c6f(%rip), %eax     # 0x232a8
jne 0xe67f
movabsq $0x100000000000000, %r15 # imm = 0x100000000000000
movl %r12d, %edi
callq 0x10f51
movl %eax, %ebx
testb $0x4, 0xaecf(%rip)      # 0x19525
movl 0x15d04(%rip), %esi     # 0x24360
je 0xe677
movslq %esi, %rax
movq 0x14a08(%rip), %rcx     # 0x23070
imulq $0x30, %rax, %rax
testq %r15, 0x20(%rcx,%rax)
jne 0xea63
xorl %r14d, %r14d
jmp 0xea8b
callq 0x40e0
movl 0x149ee(%rip), %edi     # 0x23078
pushq $0x1
popq %rsi
callq 0xf3e7
cmpw $0x9, %bx
jae 0xe6b2
leaq 0x59cb(%rip), %rdi      # 0x1406a
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd5b9
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movl $0x100, %r12d           # imm = 0x100
leaq 0xe5f7(%rip), %r13      # 0x1ccc0
xorl %ebp, %ebp
pushq $0x20
popq %r15
cmpq $0x4, %rbp
je 0xe72a
testb $0x2, 0x1(%r13)
jne 0xe6e1
leal 0x31(%rbp), %esi
jmp 0xe704
movl 0xade1(%rip), %eax      # 0x194c8
shrl $0xd, %eax
andl $0x7, %eax
xorl %ecx, %ecx
cmpq %rax, %rbp
sete %cl
shll $0x11, %ecx
addl %r12d, %ecx
leal (%rcx,%rbp), %esi
addl $0x220031, %esi         # imm = 0x220031
movq (%r14), %rdi
callq 0x4850
movq (%r14), %rdi
movl %r15d, %esi
callq 0x4850
incq %rbp
addl $0x100, %r12d           # imm = 0x100
addq $0x2138, %r13           # imm = 0x2138
jmp 0xe6cf
movq (%r14), %rdi
movl 0xad95(%rip), %esi      # 0x194c8
shrl $0x5, %esi
andl $0x700, %esi            # imm = 0x700
addl $0x20100, %esi          # imm = 0x20100
xorl %r13d, %r13d
xorl %edx, %edx
callq 0x4120
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x10c4c
movl %eax, %r15d
movzbl 0xaee4(%rip), %r14d     # 0x19648
leaq (%rbx,%r14), %rbp
decq %rbp
testb %al, %al
movq %rbx, %r12
cmovneq %rbp, %r12
movq %r12, %rdi
callq 0x5d70
leal 0x8(%rax), %ecx
movq 0x8(%rsp), %rdx
cmpl %edx, %ecx
jle 0xe811
movslq %eax, %rdx
pushq $0x2f
popq %rsi
movq %r12, %rdi
callq 0x46f0
movq %rax, %r12
testb %r15b, %r15b
je 0xe7c3
addq 0x10(%rsp), %r14
movq 0xa7e2(%rip), %rax      # 0x18f90
movq (%rax), %rdi
movsbl (%rbp), %esi
callq 0x4850
movq %r14, %rbx
pushq $0x1
popq %rax
movl %eax, %r13d
testq %rbx, %rbx
je 0xe820
cmpq %rbx, %r12
je 0xe820
movq 0x8(%rsp), %rax
leal -0xa(%rax), %r14d
cmpq %r12, %rbx
jae 0xe820
cmpb $0x2f, (%rbx)
jne 0xe80c
cmpl %r14d, %r13d
jg 0xe844
addl $0x2, %r13d
movq 0xa7a0(%rip), %rbp      # 0x18f90
movq (%rbp), %rdi
pushq $0x2f
popq %rsi
callq 0x4850
movq (%rbp), %rdi
movsbl 0x1(%rbx), %esi
incq %rbx
callq 0x4850
incq %rbx
jmp 0xe7d6
movq 0xa778(%rip), %rax      # 0x18f90
movq (%rax), %rdi
addl $-0x8, %edx
jmp 0xe83c
testq %r12, %r12
je 0xe844
movq 0xa764(%rip), %rax      # 0x18f90
movq (%rax), %rdi
movq 0x8(%rsp), %rax
movl %eax, %edx
subl %r13d, %edx
addl $-0x8, %edx
movq %r12, %rsi
callq 0x41c0
testb %r15b, %r15b
movq 0x10(%rsp), %r14
je 0xe868
movq 0xadeb(%rip), %rax      # 0x19640
movzbl 0xadec(%rip), %ecx      # 0x19648
movb (%rax,%rcx), %dl
movb %dl, -0x1(%r14,%rcx)
movb $0x0, (%rax,%rcx)
movq 0xa721(%rip), %rbx      # 0x18f90
movq (%rbx), %rdi
movl 0xac50(%rip), %esi      # 0x194c8
shrl $0x5, %esi
andl $0x700, %esi            # imm = 0x700
addl $0x20100, %esi          # imm = 0x20100
xorl %edx, %edx
callq 0x4730
cmpl $0x0, 0x14a13(%rip)     # 0x232a8
movq 0x8(%rsp), %r15
jle 0xe8b4
movq (%rbx), %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x4070
movq (%rbx), %rdi
pushq $0x5e
popq %rsi
callq 0x4850
testb $0x4, 0xac6a(%rip)      # 0x19525
je 0xe8e3
movq (%rbx), %rdi
movl 0xac02(%rip), %esi      # 0x194c8
shrl $0x5, %esi
andl $0x700, %esi            # imm = 0x700
addl $0x200100, %esi         # imm = 0x200100
xorl %edx, %edx
callq 0x4120
orb $0x4, 0xac41(%rip)      # 0x19524
movabsq $0x2000000000000000, %r13 # imm = 0x2000000000000000
movzwl 0xc294(%rip), %eax      # 0x1ab88
movl 0x149ae(%rip), %ecx     # 0x232a8
addl %ecx, %eax
addl $-0x4, %eax
movl 0xc287(%rip), %ebp      # 0x1ab8c
cmpl %ebp, %eax
cmovll %eax, %ebp
movq %r14, %rdi
xorl %esi, %esi
callq 0x10147
movl %eax, %ebx
movl %r15d, %edi
callq 0x10f51
movl %eax, 0x10(%rsp)
movslq 0x1497f(%rip), %r14     # 0x232a8
movslq %ebx, %rax
leaq 0x1498d(%rip), %rcx     # 0x232c0
addq %rax, %rcx
movq %rcx, 0x20(%rsp)
movl %ebp, 0x1c(%rsp)
movslq %ebp, %rax
movq %rax, 0x8(%rsp)
imulq $0x30, %r14, %rbp
addq $0x20, %rbp
pushq $0x2
popq %r12
cmpq 0x8(%rsp), %r14
jge 0xe9f9
movq 0xa62b(%rip), %rax      # 0x18f90
movq (%rax), %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x4070
testl %ebx, %ebx
je 0xe9d2
movq 0x146f3(%rip), %r15     # 0x23070
movq (%r15,%rbp), %rax
testq %r13, %rax
jne 0xe9d2
movq 0x15933(%rip), %r13     # 0x242c0
movq -0x20(%r15,%rbp), %rsi
shrq $0x28, %rax
movzwl %ax, %edx
movq 0x20(%rsp), %rdi
callq 0x6016
leal (%rax,%rbx), %esi
movq %r13, %rdi
movabsq $0x2000000000000000, %r13 # imm = 0x2000000000000000
callq 0x11432
movq (%r15,%rbp), %rcx
movq %rcx, %rdx
btsq $0x3c, %rdx
testq %rax, %rax
cmoveq %rcx, %rdx
orq %r13, %rdx
movq %rdx, (%r15,%rbp)
xorl %edx, %edx
cmpl 0x1469d(%rip), %r14d    # 0x23078
sete %dl
movl %r14d, %edi
movl 0x10(%rsp), %esi
callq 0x10f79
incq %r14
addq $0x30, %rbp
incl %r12d
jmp 0xe953
testb $0x4, 0xab24(%rip)      # 0x19524
movq 0xa589(%rip), %rbx      # 0x18f90
je 0xea2f
movq (%rbx), %rdi
movl 0xaab6(%rip), %esi      # 0x194c8
shrl $0x5, %esi
andl $0x700, %esi            # imm = 0x700
addl $0x200100, %esi         # imm = 0x200100
xorl %edx, %edx
callq 0x4730
andb $-0x5, 0xaaf5(%rip)     # 0x19524
movl 0x1c(%rsp), %eax
cmpl 0xc153(%rip), %eax      # 0x1ab8c
jge 0xeb88
movq (%rbx), %rdi
movzwl 0xc13f(%rip), %esi      # 0x1ab88
addl $-0x2, %esi
xorl %edx, %edx
callq 0x4070
movq (%rbx), %rdi
pushq $0x76
popq %rsi
callq 0x4850
jmp 0xeb88
movq (%r14), %rdi
movl 0xaa5c(%rip), %esi      # 0x194c8
shrl $0x5, %esi
andl $0x700, %esi            # imm = 0x700
addl $0x200100, %esi         # imm = 0x200100
xorl %edx, %edx
callq 0x4120
movb $0x1, %r14b
movl 0x158d5(%rip), %esi     # 0x24360
movq 0xa4fe(%rip), %rax      # 0x18f90
movq (%rax), %rdi
subl 0x1480d(%rip), %esi     # 0x232a8
addl $0x2, %esi
xorl %edx, %edx
callq 0x4070
movl 0x158b5(%rip), %edi     # 0x24360
movl %ebx, %esi
xorl %edx, %edx
callq 0x10f79
testb $0x4, 0xaa6a(%rip)      # 0x19525
je 0xead6
movq 0x145ac(%rip), %rax     # 0x23070
movslq 0x145ad(%rip), %rcx     # 0x23078
imulq $0x30, %rcx, %rcx
testq %r15, 0x20(%rax,%rcx)
jne 0xeb06
testb %r14b, %r14b
je 0xeb34
movq 0xa4ae(%rip), %rax      # 0x18f90
movq (%rax), %rdi
movl 0xa9dd(%rip), %esi      # 0x194c8
shrl $0x5, %esi
andl $0x700, %esi            # imm = 0x700
addl $0x200100, %esi         # imm = 0x200100
xorl %r14d, %r14d
xorl %edx, %edx
callq 0x4730
jmp 0xeb34
testb %r14b, %r14b
jne 0xeb34
movq 0xa47e(%rip), %rax      # 0x18f90
movq (%rax), %rdi
movl 0xa9ad(%rip), %esi      # 0x194c8
shrl $0x5, %esi
andl $0x700, %esi            # imm = 0x700
addl $0x200100, %esi         # imm = 0x200100
xorl %edx, %edx
callq 0x4120
movb $0x1, %r14b
movq 0xa455(%rip), %r15      # 0x18f90
movq (%r15), %rdi
movl 0x14534(%rip), %esi     # 0x23078
subl 0x1475e(%rip), %esi     # 0x232a8
addl $0x2, %esi
xorl %edx, %edx
callq 0x4070
movl 0x1451e(%rip), %edi     # 0x23078
pushq $0x1
popq %rdx
movl %ebx, %esi
callq 0x10f79
testb %r14b, %r14b
je 0xeb88
movq (%r15), %rdi
movl 0xa956(%rip), %esi      # 0x194c8
shrl $0x5, %esi
andl $0x700, %esi            # imm = 0x700
addl $0x200100, %esi         # imm = 0x200100
xorl %edx, %edx
callq 0x4730
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x113f0