// File: /workspace/github_c_makefile_star2_O0/ngkaho1234[P]ext4-extents-tree/extents.c
// Function: ext4_ext_split_node
static int
ext4_ext_split_node(struct ext4_ext_cursor *cur, int depth, ext4_fsblk_t nblocknr,
		    struct ext4_ext_path *pathp)
{
	int ret;
	ssize_t ptr;
	ssize_t nptr = -1;
	struct buffer_head *nbcb;
	uint16_t nritems;
	uint16_t nnritems;
	struct super_block *sb;
	struct ext4_extent_header *hdr;
	struct ext4_extent_header *nhdr;
	union ext4_extent_item *items;
	union ext4_extent_item *nitems;

	ext4_assert(depth != ext4_ext_cursor_depth(cur));

	ptr = cur->c_paths[depth].p_ptr;
	sb = cur->c_superblock;

	nbcb = fs_bwrite(sb, nblocknr, &ret);
	if (ret)
		return ret;

	hdr = cur->c_paths[depth].p_hdr;
	nhdr = (struct ext4_extent_header *)nbcb->b_data;

	items = EXT_FIRST_ITEM(hdr);
	nitems = EXT_FIRST_ITEM(nhdr);
	nritems = ext4_ext_header_entries(hdr) / 2;
	nnritems = ext4_ext_header_entries(hdr) - nritems;

	ext4_ext_header_set_magic(nhdr);
	ext4_ext_header_set_depth(nhdr, depth);
	ext4_ext_header_set_max_entries(nhdr,
					ext4_ext_node_maxitems(cur->c_blocksz));
	ext4_ext_header_set_generation(nhdr, 0);

	ext4_ext_header_set_entries(hdr, nritems);
	ext4_ext_header_set_entries(nhdr, nnritems);

	memcpy(nitems, items + nritems, nnritems * EXT4_EXT_ITEM_SIZE);
	memset(items + nritems, 0, nnritems * EXT4_EXT_ITEM_SIZE);

	fs_mark_buffer_dirty(cur->c_paths[depth].p_bcb);
	fs_mark_buffer_dirty(nbcb);

	if (ptr >= nritems)
		nptr = ptr - nritems;

	pathp->p_bcb = nbcb;
	pathp->p_hdr = nhdr;
	pathp->p_ptr = nptr;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq $-0x1, -0x40(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6720
movl %eax, %ecx
movl -0x7c(%rbp), %eax
cmpl %ecx, %eax
je 0x8a6c
jmp 0x8a8b
leaq 0x2112(%rip), %rdi      # 0xab85
leaq 0x1f61(%rip), %rsi      # 0xa9db
movl $0x34d, %edx            # imm = 0x34D
leaq 0x2123(%rip), %rcx      # 0xaba9
callq 0x20c0
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x2920
movq %rax, -0x48(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x8ad8
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x8c52
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x78(%rbp)
movq -0x60(%rbp), %rdi
callq 0x69a0
movzwl %ax, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movw %ax, -0x4a(%rbp)
movq -0x60(%rbp), %rdi
callq 0x69a0
movzwl %ax, %eax
movzwl -0x4a(%rbp), %ecx
subl %ecx, %eax
movw %ax, -0x4c(%rbp)
movq -0x68(%rbp), %rdi
callq 0x87a0
movq -0x68(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x80a0
movq -0x68(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x6100
movq -0x88(%rbp), %rdi
movzwl %ax, %esi
callq 0x87c0
movq -0x68(%rbp), %rdi
xorl %esi, %esi
callq 0x8800
movq -0x60(%rbp), %rdi
movzwl -0x4a(%rbp), %esi
callq 0x87e0
movq -0x68(%rbp), %rdi
movzwl -0x4c(%rbp), %esi
callq 0x87e0
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rsi
movzwl -0x4a(%rbp), %eax
cltq
imulq $0xc, %rax, %rax
addq %rax, %rsi
movzwl -0x4c(%rbp), %eax
imulq $0xc, %rax, %rdx
callq 0x2180
movq -0x70(%rbp), %rdi
movzwl -0x4a(%rbp), %eax
cltq
imulq $0xc, %rax, %rax
addq %rax, %rdi
movzwl -0x4c(%rbp), %eax
imulq $0xc, %rax, %rdx
xorl %esi, %esi
callq 0x20d0
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x29b0
movq -0x48(%rbp), %rdi
callq 0x29b0
movq -0x38(%rbp), %rax
movzwl -0x4a(%rbp), %ecx
cmpq %rcx, %rax
jl 0x8c28
movq -0x38(%rbp), %rax
movzwl -0x4a(%rbp), %ecx
subq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x68(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nop