// File: /workspace/github_c_makefile_star2_O0/jarun[P]nnn/src/nnn.c
// Function: setup_config
static bool setup_config(void)
{
	size_t r, len;
	char *xdgcfg = getenv("XDG_CONFIG_HOME");
	bool xdg = FALSE;

	/* Set up configuration file paths */
	if (xdgcfg && xdgcfg[0]) {
		DPRINTF_S(xdgcfg);
		if (tilde_is_home(xdgcfg)) {
			r = xstrsncpy(g_buf, home, PATH_MAX);
			xstrsncpy(g_buf + r - 1, xdgcfg + 1, PATH_MAX);
			xdgcfg = g_buf;
			DPRINTF_S(xdgcfg);
		}

		if (!xdiraccess(xdgcfg)) {
			xerror();
			return FALSE;
		}

		len = xstrlen(xdgcfg) + xstrlen("/nnn/bookmarks") + 1;
		xdg = TRUE;
	}

	if (!xdg)
		len = xstrlen(home) + xstrlen("/.config/nnn/bookmarks") + 1;

	cfgpath = malloc(len);
	plgpath = malloc(len);
	if (!cfgpath || !plgpath) {
		xerror();
		return FALSE;
	}

	if (xdg) {
		xstrsncpy(cfgpath, xdgcfg, len);
		r = len - xstrlen("/nnn/bookmarks");
	} else {
		r = xstrsncpy(cfgpath, home, len);

		/* Create ~/.config */
		xstrsncpy(cfgpath + r - 1, "/.config", len - r);
		DPRINTF_S(cfgpath);
		r += 8; /* length of "/.config" */
	}

	/* Create ~/.config/nnn */
	xstrsncpy(cfgpath + r - 1, "/nnn", len - r);
	DPRINTF_S(cfgpath);

	/* Create bookmarks, sessions, mounts and plugins directories */
	for (r = 0; r < ELEMENTS(toks); ++r) {
		mkpath(cfgpath, toks[r], plgpath);
		/* The dirs are created on first run, check if they already exist */
		if (access(plgpath, F_OK) && !xmktree(plgpath, TRUE)) {
			DPRINTF_S(toks[r]);
			xerror();
			return FALSE;
		}
	}

	/* Set selection file path */
	if (!g_state.picker) {
		char *env_sel = xgetenv(env_cfg[NNN_SEL], NULL);

		selpath = env_sel ? xstrdup(env_sel)
				  : malloc(len + 3); /* Length of "/.config/nnn/.selection" */

		if (!selpath) {
			xerror();
			return FALSE;
		}

		if (!env_sel) {
			r = xstrsncpy(selpath, cfgpath, len + 3);
			xstrsncpy(selpath + r - 1, "/.selection", 12);
			DPRINTF_S(selpath);
		}
	}

	return TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
leaq 0x15689(%rip), %rdi     # 0x1c178
callq 0x4050
movq %rax, -0x20(%rbp)
movb $0x0, -0x21(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x6bc5
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x6bc5
movq -0x20(%rbp), %rdi
callq 0xd130
testb $0x1, %al
jne 0x6b26
jmp 0x6b6e
movq 0x19e13(%rip), %rsi     # 0x20940
leaq 0x19f1c(%rip), %rdi     # 0x20a50
movl $0x1000, %edx           # imm = 0x1000
callq 0x6250
movq %rax, -0x10(%rbp)
leaq 0x19f07(%rip), %rdi     # 0x20a50
addq -0x10(%rbp), %rdi
addq $-0x1, %rdi
movq -0x20(%rbp), %rsi
addq $0x1, %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x6250
leaq 0x19ee6(%rip), %rax     # 0x20a50
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x7300
testb $0x1, %al
jne 0x6b96
movl $0x217e, %edi           # imm = 0x217E
callq 0x5df0
movq %rax, %rdi
callq 0x4750
movb $0x0, -0x1(%rbp)
jmp 0x6e40
movq -0x20(%rbp), %rdi
callq 0x5cc0
movq %rax, -0x38(%rbp)
leaq 0x155e6(%rip), %rdi     # 0x1c190
callq 0x5cc0
movq %rax, %rcx
movq -0x38(%rbp), %rax
addq %rcx, %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movb $0x1, -0x21(%rbp)
testb $0x1, -0x21(%rbp)
jne 0x6bf9
movq 0x19d6e(%rip), %rdi     # 0x20940
callq 0x5cc0
movq %rax, -0x40(%rbp)
leaq 0x155a6(%rip), %rdi     # 0x1c188
callq 0x5cc0
movq %rax, %rcx
movq -0x40(%rbp), %rax
addq %rcx, %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x45e0
movq %rax, 0x1b05f(%rip)     # 0x21c68
movq -0x18(%rbp), %rdi
callq 0x45e0
movq %rax, 0x1b187(%rip)     # 0x21da0
cmpq $0x0, 0x1b047(%rip)     # 0x21c68
je 0x6c2d
cmpq $0x0, 0x1b175(%rip)     # 0x21da0
jne 0x6c48
movl $0x218c, %edi           # imm = 0x218C
callq 0x5df0
movq %rax, %rdi
callq 0x4750
movb $0x0, -0x1(%rbp)
jmp 0x6e40
testb $0x1, -0x21(%rbp)
je 0x6c86
movq 0x1b013(%rip), %rdi     # 0x21c68
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x6250
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq 0x1551f(%rip), %rdi     # 0x1c190
callq 0x5cc0
movq %rax, %rcx
movq -0x48(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x6cd0
movq 0x1afdb(%rip), %rdi     # 0x21c68
movq 0x19cac(%rip), %rsi     # 0x20940
movq -0x18(%rbp), %rdx
callq 0x6250
movq %rax, -0x10(%rbp)
movq 0x1afc0(%rip), %rdi     # 0x21c68
addq -0x10(%rbp), %rdi
addq $-0x1, %rdi
movq -0x18(%rbp), %rdx
subq -0x10(%rbp), %rdx
leaq 0x154e0(%rip), %rsi     # 0x1c19f
callq 0x6250
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movq 0x1af91(%rip), %rdi     # 0x21c68
addq -0x10(%rbp), %rdi
addq $-0x1, %rdi
movq -0x18(%rbp), %rdx
subq -0x10(%rbp), %rdx
leaq 0x15462(%rip), %rsi     # 0x1c150
callq 0x6250
movq $0x0, -0x10(%rbp)
cmpq $0x4, -0x10(%rbp)
jae 0x6d77
movq 0x1af5f(%rip), %rdi     # 0x21c68
movq -0x10(%rbp), %rcx
leaq 0x18f9c(%rip), %rax     # 0x1fcb0
movq (%rax,%rcx,8), %rsi
movq 0x1b081(%rip), %rdx     # 0x21da0
callq 0x74c0
movq 0x1b075(%rip), %rdi     # 0x21da0
xorl %esi, %esi
callq 0x4720
cmpl $0x0, %eax
je 0x6d67
movq 0x1b062(%rip), %rdi     # 0x21da0
movl $0x1, %esi
callq 0x7360
testb $0x1, %al
jne 0x6d67
movl $0x21a6, %edi           # imm = 0x21A6
callq 0x5df0
movq %rax, %rdi
callq 0x4750
movb $0x0, -0x1(%rbp)
jmp 0x6e40
jmp 0x6d69
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x6cfb
movl 0x19aa7(%rip), %eax     # 0x20824
shrl $0xc, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x6e3c
movq 0x18bf5(%rip), %rdi     # 0x1f988
xorl %eax, %eax
movl %eax, %esi
callq 0x5c70
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x6db6
movq -0x30(%rbp), %rdi
callq 0x7190
movq %rax, -0x50(%rbp)
jmp 0x6dc7
movq -0x18(%rbp), %rdi
addq $0x3, %rdi
callq 0x45e0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, 0x19a56(%rip)     # 0x20828
cmpq $0x0, 0x19a4e(%rip)     # 0x20828
jne 0x6df4
movl $0x21b3, %edi           # imm = 0x21B3
callq 0x5df0
movq %rax, %rdi
callq 0x4750
movb $0x0, -0x1(%rbp)
jmp 0x6e40
cmpq $0x0, -0x30(%rbp)
jne 0x6e3a
movq 0x19a26(%rip), %rdi     # 0x20828
movq 0x1ae5f(%rip), %rsi     # 0x21c68
movq -0x18(%rbp), %rdx
addq $0x3, %rdx
callq 0x6250
movq %rax, -0x10(%rbp)
movq 0x19a07(%rip), %rdi     # 0x20828
addq -0x10(%rbp), %rdi
addq $-0x1, %rdi
leaq 0x15378(%rip), %rsi     # 0x1c1a8
movl $0xc, %edx
callq 0x6250
jmp 0x6e3c
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)