// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
movq %rdi, %r8
movl 0x996c(%rip), %ebx      # 0x1a4c8
movl %edx, 0xc(%rsp)
movslq %edx, %rax
movq %rax, 0x10(%rsp)
imulq $0x2138, %rax, %r14     # imm = 0x2138
leaq 0xb01a(%rip), %rax      # 0x1bb90
addq %rax, %r14
movl %ebx, %r15d
shrl $0xd, %r15d
andl $0x7, %r15d
imulq $0x2138, %r15, %r13     # imm = 0x2138
leaq (%rax,%r13), %r12
addq $0x2000, %r12           # imm = 0x2000
testq %rsi, %rsi
je 0x10bc7
movl $0x100, %ecx            # imm = 0x100
movq %r12, %rdi
movq %r8, %rbp
xorl %edx, %edx
callq 0x4860
movq %rbp, %r8
testq %rax, %rax
leaq 0xafd6(%rip), %rax      # 0x1bb90
jne 0x10bcc
movb $0x0, 0xff(%r12)
jmp 0x10bcc
movb $0x0, (%r12)
movl %ebx, 0x2130(%r13,%rax)
movl 0x2130(%r14), %eax
btl $0x9, %eax
jb 0x10c48
orl $0x200, %eax            # imm = 0x200
movl %eax, 0x2130(%r14)
movl $0x1000, %ecx           # imm = 0x1000
movq %r14, %rdi
movq %r8, %rsi
xorl %edx, %edx
callq 0x4860
testq %rax, %rax
jne 0x10c0c
movb $0x0, 0xfff(%r14)
movw $0x0, 0x2100(%r14)
xorl %eax, %eax
movb %al, 0x2000(%r14)
movb %al, 0x1000(%r14)
movl %ebx, 0x2130(%r14)
leaq 0x13491(%rip), %rax     # 0x240c5
cmpb $0x7a, (%r15,%rax)
jne 0x10c44
movq 0x10(%rsp), %rcx
movb $0x7a, (%rcx,%rax)
movl %ebx, %eax
jmp 0x10c6b
cmpq $0x0, 0x9a38(%rip)      # 0x1a688
je 0x10c6b
leaq 0x1346c(%rip), %rcx     # 0x240c5
movq 0x10(%rsp), %rsi
movb (%rsi,%rcx), %dl
movb %dl, 0x13462(%rip)      # 0x240c9
movb $0x30, (%rsi,%rcx)
movl 0xc(%rsp), %ecx
shll $0xd, %ecx
movzwl %cx, %ecx
movl %eax, %edx
andl $0xffff1fff, %edx       # imm = 0xFFFF1FFF
orl %ecx, %edx
movl %edx, 0x9843(%rip)      # 0x1a4c8
btl $0xa, %eax
leaq -0x1e33(%rip), %rcx     # 0xee5d
leaq -0x1e64(%rip), %rdx     # 0xee33
cmovaeq %rcx, %rdx
btl $0xb, %eax
leaq -0x1bb7(%rip), %rcx     # 0xf0ef
leaq -0x1cfc(%rip), %rsi     # 0xefb1
cmovaeq %rcx, %rsi
movq %rdx, 0x9828(%rip)      # 0x1a4e0
movq %rsi, 0x9829(%rip)      # 0x1a4e8
btl $0x19, %eax
leaq -0x2087(%rip), %rax     # 0xec43
leaq -0xad79(%rip), %rcx     # 0x5f58
cmovaeq %rax, %rcx
movq %rcx, 0x97bc(%rip)      # 0x1a498
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq