// File: /workspace/github_c_makefile_star2_O0/ngkaho1234[P]ext4-extents-tree/extents.c
// Function: ext4_ext_insert_item
static void
ext4_ext_insert_item(struct ext4_ext_cursor *cur, int depth,
		     union ext4_extent_item *nitems, bool updptr)
{
	struct ext4_extent_header *hdr;
	uint16_t nritems;
	ssize_t ptr;
	union ext4_extent_item *item;

	hdr = cur->c_paths[depth].p_hdr;
	nritems = ext4_ext_header_entries(hdr);
	ptr = (nritems) ? cur->c_paths[depth].p_ptr : 0;
	item = EXT_FIRST_ITEM(hdr) + ptr;

	ext4_assert(EXT_HAS_FREE_INDEX(hdr));

	if (nritems) {
		ssize_t shiftnritems;

		if (depth) {
			if (ext4_idx_lblock(&item->i) <
			    ext4_idx_lblock(&nitems->i)) {
				ptr++;
				item++;
			}
		} else {
			if (ext4_ext_lblock(&item->e) + ext4_ext_len(&item->e) -
				1 <
			    ext4_ext_lblock(&nitems->e)) {
				ptr++;
				item++;
			}
		}
		shiftnritems = EXT_LAST_ITEM(hdr) - item + 1;
		if (shiftnritems)
			memmove(item + 1, item,
				shiftnritems * EXT4_EXT_ITEM_SIZE);
		memcpy(item, nitems, EXT4_EXT_ITEM_SIZE);
	} else {
		memcpy(item, nitems, EXT4_EXT_ITEM_SIZE);
	}
	if (updptr)
		cur->c_paths[depth].p_ptr = ptr;
	ext4_ext_header_set_entries(hdr, ext4_ext_header_entries(hdr) + 1);
	if (depth == ext4_ext_cursor_depth(cur))
		cur->c_cursor_op.c_root_dirty_func(cur);
	else
		fs_mark_buffer_dirty(cur->c_paths[depth].p_bcb);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%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, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x69a0
movw %ax, -0x2a(%rbp)
movzwl -0x2a(%rbp), %eax
cmpl $0x0, %eax
je 0x6e68
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, -0x50(%rbp)
jmp 0x6e70
xorl %eax, %eax
movq %rax, -0x50(%rbp)
jmp 0x6e70
movq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
addq $0xc, %rax
imulq $0xc, -0x38(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movzwl 0x2(%rax), %eax
movq -0x28(%rbp), %rcx
movzwl 0x4(%rcx), %ecx
cmpl %ecx, %eax
jge 0x6ea2
jmp 0x6ec1
leaq 0x3d5d(%rip), %rdi      # 0xac06
leaq 0x3b2b(%rip), %rsi      # 0xa9db
movl $0x407, %edx            # imm = 0x407
leaq 0x3d62(%rip), %rcx      # 0xac1e
callq 0x20c0
cmpw $0x0, -0x2a(%rbp)
je 0x6fc6
cmpl $0x0, -0xc(%rbp)
je 0x6f0a
movq -0x40(%rbp), %rdi
callq 0x89b0
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rdi
callq 0x89b0
movl %eax, %ecx
movl -0x54(%rbp), %eax
cmpl %ecx, %eax
jae 0x6f08
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x40(%rbp)
jmp 0x6f5c
movq -0x40(%rbp), %rdi
callq 0x69c0
movl %eax, -0x5c(%rbp)
movq -0x40(%rbp), %rdi
callq 0x69d0
movw %ax, %cx
movl -0x5c(%rbp), %eax
movzwl %cx, %ecx
addl %ecx, %eax
subl $0x1, %eax
movl %eax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x69c0
movl %eax, %ecx
movl -0x58(%rbp), %eax
cmpl %ecx, %eax
jae 0x6f5a
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x40(%rbp)
jmp 0x6f5c
movq -0x28(%rbp), %rax
addq $0xc, %rax
movq -0x28(%rbp), %rcx
movzwl 0x2(%rcx), %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addq $-0xc, %rax
movq -0x40(%rbp), %rcx
subq %rcx, %rax
movl $0xc, %ecx
cqto
idivq %rcx
addq $0x1, %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x6fb0
movq -0x40(%rbp), %rdi
addq $0xc, %rdi
movq -0x40(%rbp), %rsi
imulq $0xc, -0x48(%rbp), %rdx
callq 0x2210
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movl 0x8(%rcx), %ecx
movl %ecx, 0x8(%rax)
jmp 0x6fda
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movl 0x8(%rcx), %ecx
movl %ecx, 0x8(%rax)
testb $0x1, -0x19(%rbp)
je 0x6ffb
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0xc(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rdi
callq 0x69a0
movq -0x68(%rbp), %rdi
movzwl %ax, %eax
addl $0x1, %eax
movzwl %ax, %esi
callq 0x87e0
movl -0xc(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6720
movl %eax, %ecx
movl -0x60(%rbp), %eax
cmpl %ecx, %eax
jne 0x7046
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rdi
callq *%rax
jmp 0x7061
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x29b0
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)