// File: /workspace/github_c_makefile_star2_O0/dlbeer[P]dhara/dhara/map.c
// Function: trace_path
static int trace_path(struct dhara_map *m, dhara_sector_t target,
		      dhara_page_t *loc, uint8_t *new_meta,
		      dhara_error_t *err)
{
	uint8_t meta[DHARA_META_SIZE];
	int depth = 0;
	dhara_page_t p = dhara_journal_root(&m->journal);

	if (new_meta)
		meta_set_id(new_meta, target);

	if (p == DHARA_PAGE_NONE)
		goto not_found;

	if (dhara_journal_read_meta(&m->journal, p, meta, err) < 0)
		return -1;

	while (depth < DHARA_RADIX_DEPTH) {
		const dhara_sector_t id = meta_get_id(meta);

		if (id == DHARA_SECTOR_NONE)
			goto not_found;

		if ((target ^ id) & d_bit(depth)) {
			if (new_meta)
				meta_set_alt(new_meta, depth, p);

			p = meta_get_alt(meta, depth);
			if (p == DHARA_PAGE_NONE) {
				depth++;
				goto not_found;
			}

			if (dhara_journal_read_meta(&m->journal, p,
						    meta, err) < 0)
				return -1;
		} else {
			if (new_meta)
				meta_set_alt(new_meta, depth,
					meta_get_alt(meta, depth));
		}

		depth++;
	}

	if (loc)
		*loc = p;

	return 0;

not_found:
	if (new_meta) {
		while (depth < DHARA_RADIX_DEPTH)
			meta_set_alt(new_meta, depth++, DHARA_SECTOR_NONE);
	}

	dhara_set_error(err, DHARA_E_NOT_FOUND);
	return -1;
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xc8(%rsp)
movl %esi, 0xc4(%rsp)
movq %rdx, 0xb8(%rsp)
movq %rcx, 0xb0(%rsp)
movq %r8, 0xa8(%rsp)
movl $0x0, 0x1c(%rsp)
movq 0xc8(%rsp), %rdi
callq 0x22d0
movl %eax, 0x18(%rsp)
cmpq $0x0, 0xb0(%rsp)
je 0x1406
movq 0xb0(%rsp), %rdi
movl 0xc4(%rsp), %esi
callq 0x22e0
cmpl $-0x1, 0x18(%rsp)
jne 0x1412
jmp 0x1587
movq 0xc8(%rsp), %rdi
movl 0x18(%rsp), %esi
leaq 0x20(%rsp), %rdx
movq 0xa8(%rsp), %rcx
callq 0x2fe0
cmpl $0x0, %eax
jge 0x1445
movl $0xffffffff, 0xd4(%rsp) # imm = 0xFFFFFFFF
jmp 0x15df
jmp 0x1447
movslq 0x1c(%rsp), %rax
cmpq $0x20, %rax
jae 0x1561
leaq 0x20(%rsp), %rdi
callq 0x2300
movl %eax, 0x14(%rsp)
cmpl $-0x1, 0x14(%rsp)
jne 0x1470
jmp 0x1587
movl 0xc4(%rsp), %eax
xorl 0x14(%rsp), %eax
movl %eax, 0x10(%rsp)
movl 0x1c(%rsp), %edi
callq 0x2310
movl %eax, %ecx
movl 0x10(%rsp), %eax
andl %ecx, %eax
cmpl $0x0, %eax
je 0x1513
cmpq $0x0, 0xb0(%rsp)
je 0x14b5
movq 0xb0(%rsp), %rdi
movl 0x1c(%rsp), %esi
movl 0x18(%rsp), %edx
callq 0x2330
leaq 0x20(%rsp), %rdi
movl 0x1c(%rsp), %esi
callq 0x2370
movl %eax, 0x18(%rsp)
cmpl $-0x1, 0x18(%rsp)
jne 0x14de
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x1587
movq 0xc8(%rsp), %rdi
movl 0x18(%rsp), %esi
leaq 0x20(%rsp), %rdx
movq 0xa8(%rsp), %rcx
callq 0x2fe0
cmpl $0x0, %eax
jge 0x1511
movl $0xffffffff, 0xd4(%rsp) # imm = 0xFFFFFFFF
jmp 0x15df
jmp 0x1551
cmpq $0x0, 0xb0(%rsp)
je 0x154f
movq 0xb0(%rsp), %rax
movq %rax, (%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0xc(%rsp)
leaq 0x20(%rsp), %rdi
movl 0x1c(%rsp), %esi
callq 0x2370
movq (%rsp), %rdi
movl 0xc(%rsp), %esi
movl %eax, %edx
callq 0x2330
jmp 0x1551
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x1447
cmpq $0x0, 0xb8(%rsp)
je 0x157a
movl 0x18(%rsp), %ecx
movq 0xb8(%rsp), %rax
movl %ecx, (%rax)
movl $0x0, 0xd4(%rsp)
jmp 0x15df
cmpq $0x0, 0xb0(%rsp)
je 0x15c2
jmp 0x1594
movslq 0x1c(%rsp), %rax
cmpq $0x20, %rax
jae 0x15c0
movq 0xb0(%rsp), %rdi
movl 0x1c(%rsp), %esi
movl %esi, %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2330
jmp 0x1594
jmp 0x15c2
movq 0xa8(%rsp), %rdi
movl $0x6, %esi
callq 0x16c0
movl $0xffffffff, 0xd4(%rsp) # imm = 0xFFFFFFFF
movl 0xd4(%rsp), %eax
addq $0xd8, %rsp
retq
nop