// File: /workspace/github_c_makefile_star2_O2/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
andl $0x0, -0x2c(%rbp)
movq 0x10(%rdi), %rax
movq %rax, -0x38(%rbp)
movq 0x30(%rdi), %rax
movslq %esi, %rcx
imulq $0x18, %rcx, %rcx
movq 0x8(%rax,%rcx), %rdx
movzwl 0x2(%rdx), %edx
cmpq %rdx, 0x10(%rax,%rcx)
jl 0x4b72
decq %rdx
movq %rdx, 0x10(%rax,%rcx)
movl %esi, %r12d
imulq $0x18, %r12, %r13
addq $0x10, %r13
testl %r12d, %r12d
jle 0x4c8c
decq %r12
movq -0x8(%rax,%r13), %rcx
imulq $0xc, (%rax,%r13), %rdx
leaq (%rcx,%rdx), %rbx
addq $0xc, %rbx
movl %r12d, %ecx
imulq $0x18, %rcx, %r15
movq 0x8(%rax,%r15), %rcx
testq %rcx, %rcx
je 0x4c01
leaq (%rax,%r15), %rdx
movq (%rdx), %rdx
movl 0x4(%rbx), %esi
movzwl 0x8(%rbx), %edi
shlq $0x20, %rdi
orq %rsi, %rdi
cmpq %rdi, 0x8(%rdx)
jne 0x4c01
movzwl 0x2(%rcx), %ecx
testq %rcx, %rcx
je 0x4ca3
movq 0x10(%rax,%r15), %rdx
cmpq $-0x1, %rdx
je 0x4be8
cmpq %rcx, %rdx
jl 0x4c7d
leaq (%rax,%r15), %rdx
addq $0x10, %rdx
cmpb $0x0, -0x30(%rbp)
je 0x4c86
decl %ecx
movq %rcx, (%rdx)
jmp 0x4c7d
movq %r14, %rdi
movl %r12d, %esi
pushq $0x1
popq %rdx
callq 0x417f
movl 0x4(%rbx), %eax
movzwl 0x8(%rbx), %esi
shlq $0x20, %rsi
orq %rax, %rsi
movq -0x38(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x267c
movq %rax, %rcx
movq %rax, -0x50(%rbp)
movl -0x2c(%rbp), %eax
testl %eax, %eax
jne 0x4c94
movq 0x18(%rcx), %rbx
movq %rbx, -0x48(%rbp)
orq $-0x1, -0x40(%rbp)
movq %r14, %rdi
movl %r12d, %esi
leaq -0x50(%rbp), %rdx
callq 0x4227
cmpw $0xf30a, (%rbx)         # imm = 0xF30A
jne 0x4c91
cmpb $0x0, -0x30(%rbp)
je 0x4c73
movzwl 0x2(%rbx), %ecx
decq %rcx
movq 0x30(%r14), %rax
movq %rcx, 0x10(%rax,%r15)
jmp 0x4c7d
movq 0x30(%r14), %rax
andq $0x0, 0x10(%rax,%r15)
addq $-0x18, %r13
jmp 0x4b7d
andq $0x0, (%rdx)
jmp 0x4c7d
movl -0x2c(%rbp), %eax
jmp 0x4c94
pushq $0x5
popq %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21b1(%rip), %rdi      # 0x6e5b
leaq 0x1d2a(%rip), %rsi      # 0x69db
leaq 0x1dea(%rip), %rcx      # 0x6aa2
movl $0x595, %edx            # imm = 0x595
callq 0x20c0