// File: /workspace/github_c_makefile_star2_O0/ngkaho1234[P]ext4-extents-tree/extents.c
// Function: ext4_ext_lookup_extent
int
ext4_ext_lookup_extent(struct ext4_ext_cursor *cur, ext4_lblk_t lblock,
		       bool *notfound)
{
	int ret = 0;
	int depth;
	int rootdepth;
	struct super_block *sb;

	sb = cur->c_superblock;
	rootdepth = ext4_ext_cursor_depth(cur);

	if (notfound)
		*notfound = true;

	ext4_assert(cur->c_paths[rootdepth].p_hdr);

	for (depth = rootdepth; depth >= 0; depth--) {
		struct ext4_ext_path npath;
		struct ext4_extent_header *hdr;

		hdr = cur->c_paths[depth].p_hdr;
		if (depth)
			ext4_ext_binsearch_node(hdr, lblock,
						&cur->c_paths[depth].p_ptr);
		else
			ext4_ext_binsearch_leaf(hdr, lblock,
						&cur->c_paths[depth].p_ptr);
		if (depth) {
			struct ext4_extent_idx *idx;
			void *data;

			idx = EXT_FIRST_INDEX(hdr) + cur->c_paths[depth].p_ptr;
			npath.p_bcb = fs_bread(sb, ext4_idx_block(idx), &ret);
			if (ret)
				break;
			data = npath.p_bcb->b_data;
			npath.p_hdr = (struct ext4_extent_header *)data;
			ext4_ext_cursor_set_buf(cur, depth - 1, &npath);

			hdr = npath.p_hdr;
			if (hdr->eh_magic != EXT4_EXT_MAGIC) {
				ret = EIO;
				break;
			}
		} else {
			struct ext4_extent *ext =
			    EXT_FIRST_EXTENT(hdr) + cur->c_paths[0].p_ptr;
			uint16_t nritems = ext4_ext_header_entries(hdr);

			if (nritems && ext4_ext_in_range(lblock, ext)) {
				if (notfound)
					*notfound = false;
			}
		}
	}
	if (ret)
		ext4_ext_cursor_unpin(cur, -1, -1);
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6720
movl %eax, -0x24(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x64f3
movq -0x18(%rbp), %rax
movb $0x1, (%rax)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x650f
jmp 0x652e
leaq 0x4523(%rip), %rdi      # 0xaa39
leaq 0x44be(%rip), %rsi      # 0xa9db
movl $0x2dc, %edx            # imm = 0x2DC
leaq 0x452e(%rip), %rcx      # 0xaa57
callq 0x20c0
movl -0x24(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jl 0x66f8
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x6584
movq -0x50(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdx
movslq -0x20(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdx
addq $0x10, %rdx
callq 0x6740
jmp 0x65a7
movq -0x50(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdx
movslq -0x20(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdx
addq $0x10, %rdx
callq 0x6830
cmpl $0x0, -0x20(%rbp)
je 0x6656
movq -0x50(%rbp), %rax
addq $0xc, %rax
movq -0x8(%rbp), %rcx
movq 0x30(%rcx), %rcx
movslq -0x20(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
imulq $0xc, 0x10(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x58(%rbp), %rdi
callq 0x6970
movq -0x78(%rbp), %rdi
movq %rax, %rsi
leaq -0x1c(%rbp), %rdx
callq 0x2860
movq %rax, -0x48(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x6608
jmp 0x66f8
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
subl $0x1, %esi
leaq -0x48(%rbp), %rdx
callq 0x63e0
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movzwl (%rax), %eax
cmpl $0xf30a, %eax           # imm = 0xF30A
je 0x6651
movl $0x5, -0x1c(%rbp)
jmp 0x66f8
jmp 0x66e8
movq -0x50(%rbp), %rax
addq $0xc, %rax
movq -0x8(%rbp), %rcx
movq 0x30(%rcx), %rcx
imulq $0xc, 0x10(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rdi
callq 0x69a0
movw %ax, -0x6a(%rbp)
movzwl -0x6a(%rbp), %eax
cmpl $0x0, %eax
je 0x66e6
movl -0xc(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq -0x68(%rbp), %rdi
callq 0x69c0
movl %eax, %ecx
movl -0x7c(%rbp), %eax
cmpl %ecx, %eax
jb 0x66e6
movl -0xc(%rbp), %eax
movl %eax, -0x80(%rbp)
movq -0x68(%rbp), %rdi
callq 0x69c0
movl %eax, -0x84(%rbp)
movq -0x68(%rbp), %rdi
callq 0x69d0
movl -0x84(%rbp), %ecx
movw %ax, %dx
movl -0x80(%rbp), %eax
movzwl %dx, %edx
addl %edx, %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
ja 0x66e6
cmpq $0x0, -0x18(%rbp)
je 0x66e4
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
jmp 0x66e6
jmp 0x66e8
jmp 0x66ea
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x6534
cmpl $0x0, -0x1c(%rbp)
je 0x670e
movq -0x8(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %edx, %esi
callq 0x62d0
movl -0x1c(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)