// File: /workspace/github_c_makefile_star2_O1/cglindkamp[P]dfm/src/xdg.c
// Function: xdg_get_config_dirs
struct list *xdg_get_config_dirs(bool include_config_home)
{
	struct path *path;
	int ret;

	struct list *list = list_new(0);
	if(list == NULL)
		return NULL;

	const char *config_dirs = getenv("XDG_CONFIG_DIRS");
	if(config_dirs) {
		char *curpath, *saveptr;
		char config_dirs_copy[strlen(config_dirs) + 1];

		strcpy(config_dirs_copy, config_dirs);

		if((curpath = strtok_r(config_dirs_copy, ":", &saveptr))) {
			do {
				ret = path_new_from_string(&path, curpath);
				if(ret == EINVAL)
					continue;
				if(path != NULL) {
					if(!list_append(list, path))
						goto err_delete_list_and_path;
				} else
					goto err_delete_list;
			} while((curpath = strtok_r(NULL, ":", &saveptr)));

		}
	}

	if(list_length(list) == 0) {
		ret = path_new_from_string(&path, "/etc/xdg");
		if(path != NULL) {
			if(!list_append(list, path))
				goto err_delete_list_and_path;
		} else
			goto err_delete_list;
	}

	if(include_config_home) {
		ret = xdg_get_config_home(&path);
		if(path != NULL) {
			if(!list_insert(list, 0, path))
				goto err_delete_list_and_path;
		} else if(ret == ENOMEM)
			goto err_delete_list;
	}

	return list;

err_delete_list_and_path:
	path_delete(path);
err_delete_list:
	list_delete(list, (list_item_deallocator)path_delete);
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edi, %r14d
xorl %r15d, %r15d
xorl %edi, %edi
callq 0x7840
testq %rax, %rax
je 0x88b3
movq %rax, %rbx
leaq 0xd9f(%rip), %rdi       # 0x9500
callq 0x3070
testq %rax, %rax
je 0x882f
movq %rax, %r15
movl %r14d, -0x34(%rbp)
movq %rax, %rdi
callq 0x3230
movq %rsp, -0x40(%rbp)
movq %rsp, %r12
addq $0x10, %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movq %r12, %rdi
movq %r15, %rsi
callq 0x3110
leaq 0xd6b(%rip), %rsi       # 0x9510
leaq -0x48(%rbp), %rdx
movq %r12, %rdi
callq 0x33b0
testq %rax, %rax
je 0x8801
leaq -0x30(%rbp), %r15
leaq 0xd4f(%rip), %r12       # 0x9510
leaq -0x48(%rbp), %r13
movq %r15, %rdi
movq %rax, %rsi
callq 0x83f9
cmpl $0x16, %eax
je 0x87ea
movq -0x30(%rbp), %rsi
testq %rsi, %rsi
je 0x8806
movq %rbx, %rdi
callq 0x78e2
testb %al, %al
je 0x880e
xorl %r14d, %r14d
xorl %edi, %edi
movq %r12, %rsi
movq %r13, %rdx
callq 0x33b0
testq %rax, %rax
jne 0x87c5
jmp 0x8814
xorl %r14d, %r14d
jmp 0x8814
movl $0x5, %r14d
jmp 0x8814
movl $0x4, %r14d
movq -0x40(%rbp), %rsp
movl %r14d, %eax
leaq 0xcae(%rip), %rcx       # 0x94d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movl -0x34(%rbp), %r14d
jmpq *%rax
movq %rbx, %rdi
callq 0x78de
testq %rax, %rax
je 0x8865
testb %r14b, %r14b
je 0x88b0
leaq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x868c
movq (%r14), %rdx
testq %rdx, %rdx
je 0x88ab
movq %rbx, %rdi
xorl %esi, %esi
callq 0x794a
testb %al, %al
je 0x888c
jmp 0x88b0
leaq 0xca6(%rip), %rsi       # 0x9512
leaq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0x83f9
movq (%r15), %rsi
testq %rsi, %rsi
je 0x8895
movq %rbx, %rdi
callq 0x78e2
testb %al, %al
jne 0x883c
movq -0x30(%rbp), %rdi
callq 0x8489
leaq -0x413(%rip), %rsi      # 0x8489
movq %rbx, %rdi
callq 0x7896
xorl %r15d, %r15d
jmp 0x88b3
jmp 0x88b3
cmpl $0xc, %eax
je 0x8895
movq %rbx, %r15
movq %r15, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)