// File: /workspace/github_c_makefile_star2_O0/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
subq $0x70, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
andb $0x1, %al
movb %al, -0xd(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rdi
callq 0x69a0
movw %ax, %cx
movq -0x60(%rbp), %rax
movzwl %cx, %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jle 0x7326
movq -0x20(%rbp), %rdi
callq 0x69a0
movzwl %ax, %eax
subl $0x1, %eax
movslq %eax, %rcx
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0xc(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jl 0x7593
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
addq $0xc, %rax
movq -0x8(%rbp), %rcx
movq 0x30(%rcx), %rcx
movslq -0x2c(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
imulq $0xc, 0x10(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x74a6
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rdi
callq 0x6970
movq %rax, %rcx
movq -0x68(%rbp), %rax
cmpq %rcx, %rax
jne 0x74a6
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x69a0
movw %ax, -0x2e(%rbp)
cmpw $0x0, -0x2e(%rbp)
je 0x7402
jmp 0x7421
leaq 0x3ab0(%rip), %rdi      # 0xaeb9
leaq 0x35cb(%rip), %rsi      # 0xa9db
movl $0x595, %edx            # imm = 0x595
leaq 0x3686(%rip), %rcx      # 0xaaa2
callq 0x20c0
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $-0x1, 0x10(%rax)
je 0x745b
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movzwl -0x2e(%rbp), %ecx
cmpq %rcx, %rax
jl 0x74a1
testb $0x1, -0xd(%rbp)
je 0x7484
movzwl -0x2e(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x18(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
jmp 0x749f
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x10(%rax)
jmp 0x74a1
jmp 0x7585
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movl $0x1, %edx
callq 0x62d0
movq -0x28(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x50(%rbp), %rdi
callq 0x6970
movq -0x70(%rbp), %rdi
movq %rax, %rsi
leaq -0x14(%rbp), %rdx
callq 0x2860
movq %rax, -0x48(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x74e7
jmp 0x7595
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x40(%rbp)
movq $-0x1, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
leaq -0x48(%rbp), %rdx
callq 0x63e0
movq -0x40(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movzwl (%rax), %eax
cmpl $0xf30a, %eax           # imm = 0xF30A
je 0x7532
movl $0x5, -0x14(%rbp)
jmp 0x7595
movq -0x20(%rbp), %rdi
callq 0x69a0
movw %ax, -0x2e(%rbp)
testb $0x1, -0xd(%rbp)
je 0x7568
movzwl -0x2e(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x18(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
jmp 0x7583
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x10(%rax)
jmp 0x7585
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x732f
jmp 0x7595
movl -0x14(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nop