// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movl %edx, %ebx
movq %rdi, %r14
movl $0x0, -0x2c(%rbp)
movq 0x10(%rdi), %rax
movq %rax, -0x38(%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 0x4e96
decq %rdx
movq %rdx, 0x10(%rax,%rcx,8)
testl %esi, %esi
jle 0x4fae
movl %esi, %r13d
leaq (,%r13,2), %rcx
addq %r13, %rcx
leaq 0x10(,%rcx,8), %r12
movq -0x20(%rax,%r12), %rcx
movq -0x8(%rax,%r12), %rdx
movq (%rax,%r12), %rsi
leaq (%rsi,%rsi,2), %rsi
leaq (%rdx,%rsi,4), %r15
addq $0xc, %r15
testq %rcx, %rcx
je 0x4f17
movq -0x28(%rax,%r12), %rdx
movl 0x4(%r15), %esi
movzwl 0x8(%r15), %edi
shlq $0x20, %rdi
orq %rsi, %rdi
cmpq %rdi, 0x8(%rdx)
jne 0x4f17
movzwl 0x2(%rcx), %ecx
testq %rcx, %rcx
je 0x4fe7
movq -0x18(%rax,%r12), %rdx
cmpq $-0x1, %rdx
je 0x4f0f
cmpq %rcx, %rdx
jl 0x4f99
testb %bl, %bl
je 0x4f90
decl %ecx
jmp 0x4f85
leal -0x1(%r13), %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0x435b
movl 0x4(%r15), %eax
movzwl 0x8(%r15), %esi
shlq $0x20, %rsi
orq %rax, %rsi
movq -0x38(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x2728
movl -0x2c(%rbp), %ecx
testl %ecx, %ecx
jne 0x4fb7
movq 0x30(%r14), %rdx
cmpq $0x0, -0x20(%rdx,%r12)
jne 0x4fc8
movq 0x18(%rax), %rcx
movq %rax, -0x28(%rdx,%r12)
movq %rcx, -0x20(%rdx,%r12)
movq $-0x1, -0x18(%rdx,%r12)
cmpw $0xf30a, (%rcx)         # imm = 0xF30A
jne 0x4fb2
testb %bl, %bl
je 0x4f8c
movzwl 0x2(%rcx), %ecx
decq %rcx
movq 0x30(%r14), %rax
movq %rcx, -0x18(%rax,%r12)
jmp 0x4f99
movq 0x30(%r14), %rax
movq $0x0, -0x18(%rax,%r12)
decq %r13
leaq 0x1(%r13), %rcx
addq $-0x18, %r12
cmpq $0x1, %rcx
ja 0x4eb4
xorl %ecx, %ecx
jmp 0x4fb7
movl $0x5, %ecx
movl %ecx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a01(%rip), %rdi      # 0x69d0
leaq 0x1a15(%rip), %rsi      # 0x69eb
leaq 0x1a18(%rip), %rcx      # 0x69f5
movl $0x23f, %edx            # imm = 0x23F
callq 0x20c0
leaq 0x1e7d(%rip), %rdi      # 0x6e6b
leaq 0x19f6(%rip), %rsi      # 0x69eb
leaq 0x1ab6(%rip), %rcx      # 0x6ab2
movl $0x595, %edx            # imm = 0x595
callq 0x20c0