// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %r15d
movq %rdi, %rbx
movl $0x0, -0x2c(%rbp)
movq (%rdi), %rax
movq 0x10(%rdi), %rcx
movq %rcx, -0x40(%rbp)
movzwl 0x6(%rax), %r12d
testq %rdx, %rdx
je 0x45f7
movb $0x1, (%rdx)
movq %rdx, -0x38(%rbp)
movq 0x30(%rbx), %rax
leaq (%r12,%r12,2), %rcx
cmpq $0x0, 0x8(%rax,%rcx,8)
je 0x4811
movq 0x30(%rbx), %rax
leaq (%r12,%r12,2), %r14
movq 0x8(%rax,%r14,8), %rcx
movzwl 0x2(%rcx), %esi
testq %r12, %r12
je 0x4671
testq %rsi, %rsi
je 0x46e2
decq %rsi
leaq 0xc(%rcx), %r8
xorl %r9d, %r9d
leaq (%rsi,%r9), %rdi
movq %rdi, %rdx
shrq $0x3f, %rdx
addq %rdi, %rdx
sarq %rdx
leaq (%rdx,%rdx,2), %rdi
movl (%r8,%rdi,4), %edi
cmpl %r15d, %edi
je 0x46e4
seta %dil
ja 0x4666
leaq 0x1(%rdx), %r9
jmp 0x466a
leaq -0x1(%rdx), %rsi
cmpq %rsi, %r9
jle 0x4638
jmp 0x46e6
testq %rsi, %rsi
je 0x46e2
leaq 0xc(%rcx), %r8
decq %rsi
xorl %r9d, %r9d
leaq (%rsi,%r9), %rdi
movq %rdi, %rdx
shrq $0x3f, %rdx
addq %rdi, %rdx
sarq %rdx
leaq (%rdx,%rdx,2), %r11
movl (%r8,%r11,4), %r10d
cmpl %r15d, %r10d
seta %dil
ja 0x46cc
leaq (%r8,%r11,4), %r11
movzwl 0x4(%r11), %r11d
movl %r11d, %r13d
andl $0x7fff, %r13d          # imm = 0x7FFF
cmpl $0x8001, %r11d          # imm = 0x8001
cmovbl %r11d, %r13d
leal (%r10,%r13), %r11d
decl %r11d
cmpl %r15d, %r11d
jae 0x46e4
cmpl %r15d, %r10d
ja 0x46d7
leaq 0x1(%rdx), %r9
jmp 0x46db
leaq -0x1(%rdx), %rsi
cmpq %rsi, %r9
jle 0x4680
jmp 0x46e6
xorl %edx, %edx
xorl %edi, %edi
leaq (%rax,%r14,8), %r8
testq %rdx, %rdx
setne %sil
andb %dil, %sil
movzbl %sil, %esi
subq %rsi, %rdx
leaq 0xc(%rcx), %rsi
movq %r12, %r13
movq %rdx, 0x10(%r8)
subq $0x1, %r13
jae 0x475e
movb $0x1, %dl
cmpw $0x0, 0x2(%rcx)
je 0x47b8
movq 0x10(%rax), %rax
leaq (%rax,%rax,2), %rax
leaq (%rsi,%rax,4), %rcx
movl (%rcx), %eax
cmpl %r15d, %eax
ja 0x47b8
movzwl 0x4(%rcx), %esi
movl %esi, %ecx
andl $0x7fff, %ecx           # imm = 0x7FFF
cmpl $0x8001, %esi           # imm = 0x8001
cmovbl %esi, %ecx
cmpq $0x0, -0x38(%rbp)
je 0x47b8
addl %ecx, %eax
decl %eax
cmpl %r15d, %eax
jb 0x47b8
movq -0x38(%rbp), %rax
movb $0x0, (%rax)
jmp 0x47b8
movq 0x10(%rax,%r14,8), %rax
leaq (%rax,%rax,2), %rax
movl 0x4(%rsi,%rax,4), %ecx
movzwl 0x8(%rsi,%rax,4), %esi
shlq $0x20, %rsi
orq %rcx, %rsi
movq -0x40(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x27c8
cmpl $0x0, -0x2c(%rbp)
jne 0x47b6
movq 0x30(%rbx), %rcx
cmpq $0x0, -0x10(%rcx,%r14,8)
jne 0x47f2
leaq (%rcx,%r14,8), %rcx
movq 0x18(%rax), %rsi
movq %rax, -0x18(%rcx)
movq %rsi, -0x10(%rcx)
movb $0x1, %dl
cmpw $0xf30a, (%rsi)         # imm = 0xF30A
je 0x47b8
movl $0x5, -0x2c(%rbp)
xorl %edx, %edx
testb %dl, %dl
je 0x47c8
testq %r12, %r12
movq %r13, %r12
jg 0x460f
cmpl $0x0, -0x2c(%rbp)
je 0x47e0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x445b
movl -0x2c(%rbp), %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x31ef(%rip), %rdi      # 0x79e8
leaq 0x3203(%rip), %rsi      # 0x7a03
leaq 0x3206(%rip), %rcx      # 0x7a0d
movl $0x23f, %edx            # imm = 0x23F
callq 0x20c0
leaq 0x3249(%rip), %rdi      # 0x7a61
leaq 0x31e4(%rip), %rsi      # 0x7a03
leaq 0x3259(%rip), %rcx      # 0x7a7f
movl $0x2dc, %edx            # imm = 0x2DC
callq 0x20c0