// File: /workspace/github_c_makefile_star2_O1/jarun[P]nnn/src/nnn.c
// Function: savecurctx
static void savecurctx(char *path, char *curname, int nextctx)
{
	settings tmpcfg = cfg;
	context *ctxr = &g_ctx[nextctx];

	/* Save current context */
	if (curname)
		xstrsncpy(g_ctx[tmpcfg.curctx].c_name, curname, NAME_MAX + 1);
	else
		g_ctx[tmpcfg.curctx].c_name[0] = '\0';

	g_ctx[tmpcfg.curctx].c_cfg = tmpcfg;

	if (ctxr->c_cfg.ctxactive) { /* Switch to saved context */
		tmpcfg = ctxr->c_cfg;
		/* Skip ordering an open context */
		if (order) {
			cfgsort[CTX_MAX] = cfgsort[nextctx];
			cfgsort[nextctx] = '0';
		}
	} else { /* Set up a new context from current context */
		ctxr->c_cfg.ctxactive = 1;
		xstrsncpy(ctxr->c_path, path, PATH_MAX);
		ctxr->c_last[0] = ctxr->c_name[0] = ctxr->c_fltr[0] = ctxr->c_fltr[1] = '\0';
		ctxr->c_cfg = tmpcfg;
		/* If already in an ordered dir, clear ordering for the new context and let it order */
		if (cfgsort[cfg.curctx] == 'z')
			cfgsort[nextctx] = 'z';
	}

	tmpcfg.curctx = nextctx;
	setcfg(tmpcfg);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rdi, %rdx
movl 0x9746(%rip), %ebp      # 0x1a4c8
movslq %ebx, %r15
imulq $0x2138, %r15, %r14     # imm = 0x2138
leaq 0xadfd(%rip), %rcx      # 0x1bb90
addq %rcx, %r14
movl %ebp, %eax
shrl $0xd, %eax
andl $0x7, %eax
imulq $0x2138, %rax, %rax     # imm = 0x2138
leaq (%rax,%rcx), %r12
addq $0x2000, %r12           # imm = 0x2000
testq %rsi, %rsi
je 0x10de1
movl $0x100, %ecx            # imm = 0x100
movq %r12, %rdi
movq %rdx, %r13
xorl %edx, %edx
callq 0x4860
leaq 0xadc2(%rip), %rcx      # 0x1bb90
movq %r13, %rdx
testq %rax, %rax
jne 0x10de6
movb $0x0, 0xff(%r12)
jmp 0x10de6
movb $0x0, (%r12)
movl %ebp, %r12d
shrl $0xd, %r12d
andl $0x7, %r12d
imulq $0x2138, %r12, %rax     # imm = 0x2138
movl %ebp, 0x2130(%rax,%rcx)
movl 0x2130(%r14), %eax
btl $0x9, %eax
jb 0x10e6f
orl $0x200, %eax            # imm = 0x200
movl %eax, 0x2130(%r14)
movl $0x1000, %ecx           # imm = 0x1000
movq %r14, %rdi
movq %rdx, %rsi
xorl %edx, %edx
callq 0x4860
testq %rax, %rax
jne 0x10e37
movb $0x0, 0xfff(%r14)
movw $0x0, 0x2100(%r14)
xorl %eax, %eax
movb %al, 0x2000(%r14)
movb %al, 0x1000(%r14)
movl %ebp, 0x2130(%r14)
leaq 0x13266(%rip), %rax     # 0x240c5
cmpb $0x7a, (%r12,%rax)
jne 0x10e6b
movb $0x7a, (%r15,%rax)
movl %ebp, %eax
jmp 0x10e8f
cmpq $0x0, 0x9811(%rip)      # 0x1a688
je 0x10e8f
leaq 0x13245(%rip), %rcx     # 0x240c5
movb (%r15,%rcx), %dl
movb %dl, 0x1323f(%rip)      # 0x240c9
movb $0x30, (%r15,%rcx)
shll $0xd, %ebx
movzwl %bx, %ecx
movl %eax, %edx
andl $0xffff1fff, %edx       # imm = 0xFFFF1FFF
orl %ecx, %edx
movl %edx, 0x9623(%rip)      # 0x1a4c8
btl $0xa, %eax
leaq -0x1e45(%rip), %rcx     # 0xf06b
leaq -0x1e76(%rip), %rdx     # 0xf041
cmovaeq %rcx, %rdx
btl $0xb, %eax
leaq -0x1bcd(%rip), %rcx     # 0xf2f9
leaq -0x1d12(%rip), %rsi     # 0xf1bb
cmovaeq %rcx, %rsi
movq %rdx, 0x9608(%rip)      # 0x1a4e0
movq %rsi, 0x9609(%rip)      # 0x1a4e8
btl $0x19, %eax
leaq -0x2098(%rip), %rax     # 0xee52
leaq -0xaf64(%rip), %rcx     # 0x5f8d
cmovaeq %rax, %rcx
movq %rcx, 0x959c(%rip)      # 0x1a498
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq