// File: /workspace/github_c_makefile_star2_O0/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
subq $0x70, %rsp
movb %dil, %al
andb $0x1, %al
movb %al, -0x9(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x9f60
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xbcb1
movq $0x0, -0x8(%rbp)
jmp 0xbe67
leaq 0x17e2(%rip), %rdi      # 0xd49a
callq 0x3070
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xbdbc
movq -0x30(%rbp), %rdi
callq 0x3230
movq %rax, %rcx
movq %rcx, %rax
incq %rax
movq %rsp, %rdx
movq %rdx, -0x48(%rbp)
addq $0x10, %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
subq %rcx, %rdi
movq %rdi, -0x60(%rbp)
movq %rdi, %rsp
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rsi
callq 0x3110
movq -0x60(%rbp), %rdi
leaq 0x1798(%rip), %rsi      # 0xd4aa
leaq -0x40(%rbp), %rdx
callq 0x33b0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0xbd8d
jmp 0xbd27
movq -0x38(%rbp), %rsi
leaq -0x18(%rbp), %rdi
callq 0xb700
movl %eax, -0x1c(%rbp)
cmpl $0x16, -0x1c(%rbp)
jne 0xbd3f
jmp 0xbd6d
cmpq $0x0, -0x18(%rbp)
je 0xbd62
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xa0b0
testb $0x1, %al
jne 0xbd60
movl $0x4, -0x54(%rbp)
jmp 0xbd94
jmp 0xbd6b
movl $0x5, -0x54(%rbp)
jmp 0xbd94
jmp 0xbd6d
xorl %eax, %eax
movl %eax, %edi
leaq 0x1732(%rip), %rsi      # 0xd4aa
leaq -0x40(%rbp), %rdx
callq 0x33b0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0xbd27
jmp 0xbd8d
movl $0x0, -0x54(%rbp)
movq -0x48(%rbp), %rax
movq %rax, %rsp
movl -0x54(%rbp), %eax
movl %eax, -0x64(%rbp)
testl %eax, %eax
je 0xbdba
jmp 0xbda7
movl -0x64(%rbp), %eax
subl $0x4, %eax
je 0xbe46
jmp 0xbdb5
jmp 0xbe4f
jmp 0xbdbc
movq -0x28(%rbp), %rdi
callq 0xa090
cmpq $0x0, %rax
jne 0xbdfe
leaq -0x18(%rbp), %rdi
leaq 0x16d6(%rip), %rsi      # 0xd4ac
callq 0xb700
movl %eax, -0x1c(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xbdfa
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xa0b0
testb $0x1, %al
jne 0xbdf8
jmp 0xbe46
jmp 0xbdfc
jmp 0xbe4f
jmp 0xbdfe
testb $0x1, -0x9(%rbp)
je 0xbe3c
leaq -0x18(%rbp), %rdi
callq 0xbb70
movl %eax, -0x1c(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xbe30
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0xa190
testb $0x1, %al
jne 0xbe2e
jmp 0xbe46
jmp 0xbe3a
cmpl $0xc, -0x1c(%rbp)
jne 0xbe38
jmp 0xbe4f
jmp 0xbe3a
jmp 0xbe3c
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xbe67
movq -0x18(%rbp), %rdi
callq 0xb7f0
movq -0x28(%rbp), %rdi
leaq -0x66a(%rip), %rsi      # 0xb7f0
callq 0xa010
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rbp, %rsp
popq %rbp
retq