// File: /workspace/github_c_makefile_star2_O1/ngkaho1234[P]ext4-extents-tree/extents.c
// Function: ext4_ext_reload_paths
int
ext4_ext_reload_paths(struct ext4_ext_cursor *cur, int depth, bool right)
{
	int ret = 0;
	int i;
	struct ext4_extent_header *hdr;
	struct super_block *sb;

	sb = cur->c_superblock;
	hdr = cur->c_paths[depth].p_hdr;

	if (cur->c_paths[depth].p_ptr > ext4_ext_header_entries(hdr) - 1)
		cur->c_paths[depth].p_ptr = ext4_ext_header_entries(hdr) - 1;

	for (i = depth - 1; i >= 0; i--) {
		int udepth = i + 1;
		uint16_t nritems;
		struct ext4_ext_path npath;
		struct ext4_extent_idx *idx;
		void *data;

		hdr = cur->c_paths[udepth].p_hdr;
		idx = EXT_FIRST_INDEX(hdr) + cur->c_paths[udepth].p_ptr;

		if (cur->c_paths[i].p_hdr &&
		    ext4_buf_blocknr(cur->c_paths[i].p_bcb) ==
			ext4_idx_block(idx)) {
			nritems = ext4_ext_header_entries(cur->c_paths[i].p_hdr);
			ext4_assert(nritems);
			if (cur->c_paths[i].p_ptr == -1 ||
			    cur->c_paths[i].p_ptr >= nritems) {
				if (right)
					cur->c_paths[i].p_ptr = nritems - 1;
				else
					cur->c_paths[i].p_ptr = 0;
			}
			continue;
		}

		ext4_ext_cursor_unpin(cur, i, 1);
		npath.p_bcb = fs_bread(sb, ext4_idx_block(idx), &ret);
		if (ret)
			goto out;
		data = npath.p_bcb->b_data;
		npath.p_hdr = (struct ext4_extent_header *)data;
		npath.p_ptr = -1;
		ext4_ext_cursor_set_buf(cur, i, &npath);

		hdr = npath.p_hdr;
		if (hdr->eh_magic != EXT4_EXT_MAGIC) {
			ret = EIO;
			goto out;
		}

		nritems = ext4_ext_header_entries(hdr);
		if (right)
			cur->c_paths[i].p_ptr = nritems - 1;
		else
			cur->c_paths[i].p_ptr = 0;
	}
out:
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, -0x30(%rbp)
movq %rdi, %r14
movl $0x0, -0x2c(%rbp)
movq 0x10(%rdi), %rax
movq %rax, -0x50(%rbp)
movq 0x30(%rdi), %rax
movslq %esi, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rax,%rcx,8), %rdx
movzwl 0x2(%rdx), %edx
cmpq %rdx, 0x10(%rax,%rcx,8)
jl 0x5036
decq %rdx
movq %rdx, 0x10(%rax,%rcx,8)
testl %esi, %esi
jle 0x51e7
movl %esi, %r13d
leaq (,%r13,2), %rax
addq %r13, %rax
leaq 0x10(,%rax,8), %rbx
xorl %eax, %eax
movl %eax, %eax
movq %rax, -0x40(%rbp)
leaq 0x296d(%rip), %r12      # 0x79d0
movl $0x5, %eax
movl %eax, %eax
movq %rax, -0x48(%rbp)
movl $0x4, %eax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq 0x30(%r14), %rax
movq -0x8(%rax,%rbx), %rcx
movq (%rax,%rbx), %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,4), %r15
addq $0xc, %r15
cmpq $0x0, -0x20(%rax,%rbx)
je 0x50fa
movq -0x28(%rax,%rbx), %rcx
movl 0x4(%r15), %edx
movzwl 0x8(%r15), %esi
shlq $0x20, %rsi
orq %rdx, %rsi
cmpq %rsi, 0x8(%rcx)
jne 0x50fa
movq -0x20(%rax,%rbx), %rcx
movzwl 0x2(%rcx), %ecx
testq %rcx, %rcx
je 0x51fb
movq -0x18(%rax,%rbx), %rsi
cmpq $-0x1, %rsi
je 0x50dc
movl $0x4, %edx
cmpq %rcx, %rsi
jl 0x5133
cmpb $0x0, -0x30(%rbp)
je 0x51bd
decl %ecx
movq %rcx, -0x18(%rax,%rbx)
movq -0x38(%rbp), %rax
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
leal -0x1(%r13), %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0x445b
movl 0x4(%r15), %eax
movzwl 0x8(%r15), %esi
shlq $0x20, %rsi
orq %rax, %rsi
movq -0x50(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x27c8
movl $0x5, %edx
cmpl $0x0, -0x2c(%rbp)
je 0x5158
movl %edx, %eax
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
decq %r13
leaq 0x1(%r13), %rax
addq $-0x18, %rbx
cmpq $0x1, %rax
jg 0x5079
jmp 0x51e7
movq 0x30(%r14), %rdx
cmpq $0x0, -0x20(%rdx,%rbx)
jne 0x521a
movq 0x18(%rax), %rcx
movq %rax, -0x28(%rdx,%rbx)
movq %rcx, -0x20(%rdx,%rbx)
movq $-0x1, -0x18(%rdx,%rbx)
cmpw $0xf30a, (%rcx)         # imm = 0xF30A
jne 0x51a9
cmpb $0x0, -0x30(%rbp)
je 0x51d3
movzwl 0x2(%rcx), %eax
decq %rax
movq 0x30(%r14), %rcx
movq %rax, -0x18(%rcx,%rbx)
movq -0x40(%rbp), %rax
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movl $0x5, -0x2c(%rbp)
movq -0x48(%rbp), %rax
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq $0x0, -0x18(%rax,%rbx)
movq -0x38(%rbp), %rax
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq 0x30(%r14), %rax
movq $0x0, -0x18(%rax,%rbx)
xorl %edx, %edx
jmp 0x5133
movl -0x2c(%rbp), %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x51ea
leaq 0x2c82(%rip), %rdi      # 0x7e84
leaq 0x27fa(%rip), %rsi      # 0x7a03
leaq 0x28ba(%rip), %rcx      # 0x7aca
movl $0x595, %edx            # imm = 0x595
callq 0x20c0
leaq 0x27c7(%rip), %rdi      # 0x79e8
leaq 0x27db(%rip), %rsi      # 0x7a03
leaq 0x27de(%rip), %rcx      # 0x7a0d
movl $0x23f, %edx            # imm = 0x23F
callq 0x20c0