// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movl %esi, %r14d
movl $0x0, -0x2c(%rbp)
movq (%rdi), %rax
movq 0x10(%rdi), %rcx
movq %rcx, -0x48(%rbp)
movzwl 0x6(%rax), %r12d
testq %rdx, %rdx
je 0x44f4
movb $0x1, (%rdx)
movq %rdx, -0x38(%rbp)
movq 0x30(%rdi), %rax
leaq (%r12,%r12,2), %rcx
cmpq $0x0, 0x8(%rax,%rcx,8)
je 0x46ff
movq %rdi, -0x40(%rbp)
movq 0x30(%rdi), %rdx
leaq (%r12,%r12,2), %r13
movq 0x8(%rdx,%r13,8), %rcx
movzwl 0x2(%rcx), %esi
testq %r12, %r12
je 0x4573
testq %rsi, %rsi
je 0x45e2
leaq -0x1(%rsi), %r9
leaq 0xc(%rcx), %r8
xorl %r10d, %r10d
leaq (%r9,%r10), %rdi
movq %rdi, %rax
shrq $0x3f, %rax
addq %rdi, %rax
sarq %rax
leaq (%rax,%rax,2), %rdi
movl (%r8,%rdi,4), %edi
cmpl %r14d, %edi
je 0x45e4
seta %dil
ja 0x4568
leaq 0x1(%rax), %r10
jmp 0x456c
leaq -0x1(%rax), %r9
cmpq %r9, %r10
jle 0x453a
jmp 0x45e6
testq %rsi, %rsi
je 0x45e2
leaq 0xc(%rcx), %r8
leaq -0x1(%rsi), %r9
xorl %r10d, %r10d
leaq (%r9,%r10), %rdi
movq %rdi, %rax
shrq $0x3f, %rax
addq %rdi, %rax
sarq %rax
leaq (%rax,%rax,2), %rbx
movl (%r8,%rbx,4), %r11d
cmpl %r14d, %r11d
seta %dil
ja 0x45cc
leaq (%r8,%rbx,4), %rbx
movzwl 0x4(%rbx), %ebx
movl %ebx, %r15d
andl $0x7fff, %r15d          # imm = 0x7FFF
cmpl $0x8001, %ebx           # imm = 0x8001
cmovbl %ebx, %r15d
leal (%r11,%r15), %ebx
decl %ebx
cmpl %r14d, %ebx
jae 0x45e4
cmpl %r14d, %r11d
ja 0x45d7
leaq 0x1(%rax), %r10
jmp 0x45db
leaq -0x1(%rax), %r9
cmpq %r9, %r10
jle 0x4583
jmp 0x45e6
xorl %eax, %eax
xorl %edi, %edi
leaq (%rdx,%r13,8), %r8
testq %rax, %rax
setne %r9b
andb %dil, %r9b
movzbl %r9b, %edi
subq %rdi, %rax
addq $0xc, %rcx
movq %r12, %rbx
movq %rax, 0x10(%r8)
subq $0x1, %rbx
jb 0x4672
leaq (%rax,%rax,2), %rax
movl 0x4(%rcx,%rax,4), %edx
movzwl 0x8(%rcx,%rax,4), %esi
shlq $0x20, %rsi
orq %rdx, %rsi
movq -0x48(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x2728
cmpl $0x0, -0x2c(%rbp)
movq -0x40(%rbp), %rdi
jne 0x46bf
movq 0x30(%rdi), %rcx
cmpq $0x0, -0x10(%rcx,%r13,8)
jne 0x46e0
leaq (%rcx,%r13,8), %rcx
movq 0x18(%rax), %rdx
movq %rax, -0x18(%rcx)
movq %rdx, -0x10(%rcx)
cmpw $0xf30a, (%rdx)         # imm = 0xF30A
jne 0x46b8
testq %r12, %r12
movq %rbx, %r12
jg 0x4510
xorl %eax, %eax
jmp 0x46d1
xorl %eax, %eax
testq %rsi, %rsi
je 0x46d1
movq 0x10(%rdx), %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,4), %rdx
movl (%rdx), %ecx
cmpl %r14d, %ecx
ja 0x46d1
movzwl 0x4(%rdx), %esi
movl %esi, %edx
andl $0x7fff, %edx           # imm = 0x7FFF
cmpl $0x8001, %esi           # imm = 0x8001
cmovbl %esi, %edx
movq -0x38(%rbp), %rsi
testq %rsi, %rsi
je 0x46d1
addl %edx, %ecx
decl %ecx
cmpl %r14d, %ecx
jb 0x46d1
movb $0x0, (%rsi)
jmp 0x46d1
movl $0x5, -0x2c(%rbp)
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x435b
movl -0x2c(%rbp), %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22e9(%rip), %rdi      # 0x69d0
leaq 0x22fd(%rip), %rsi      # 0x69eb
leaq 0x2300(%rip), %rcx      # 0x69f5
movl $0x23f, %edx            # imm = 0x23F
callq 0x20c0
leaq 0x2343(%rip), %rdi      # 0x6a49
leaq 0x22de(%rip), %rsi      # 0x69eb
leaq 0x2353(%rip), %rcx      # 0x6a67
movl $0x2dc, %edx            # imm = 0x2DC
callq 0x20c0