// File: /workspace/github_c_makefile_star2_O0/ngkaho1234[P]ext4-extents-tree/extents.c
// Function: ext4_ext_ensure_unfull
static int
ext4_ext_ensure_unfull(struct ext4_ext_cursor *cur)
{
	int ret = 0;
	ext4_fsblk_t *nblocknrs = NULL;
	int rootdepth;
	int nrlevel;
	int nrallocs = 0;

	rootdepth = ext4_ext_cursor_depth(cur);
	nrlevel = ext4_ext_nrlevel_need_split(cur);

	if (nrlevel) {
		uint16_t i;
		ssize_t pptr;
		ext4_lblk_t prlblock;
		union ext4_extent_item nitems;

		nblocknrs =
		    (ext4_fsblk_t *)ext4_malloc(nrlevel * sizeof(ext4_fsblk_t));
		if (!nblocknrs) {
			ret = ENOMEM;
			goto out;
		}
		for (i = 0; i < nrlevel; i++, nrallocs++) {
			ret = cur->c_cursor_op.c_alloc_block_func(cur,
								  nblocknrs + i);
			if (ret)
				goto out;
		}
		for (i = 0; i < nrlevel; i++) {
			ssize_t ptr;
			ext4_lblk_t rlblock;
			struct ext4_ext_path path;

			if (i < rootdepth) {
				ret = ext4_ext_split_node(cur, i, nblocknrs[i],
							  &path);
				if (ret)
					goto out;
			} else {
				ret = ext4_ext_tree_grow(cur, i, nblocknrs[i],
							 &path);
				if (ret)
					goto out;
				rootdepth++;
				ret = ext4_ext_cursor_reset_rootpath(cur);
				if (ret)
					goto out;
				cur->c_paths[rootdepth].p_ptr = 0;
			}
			ptr = path.p_ptr;
			rlblock = ext4_ext_node_lblock(path.p_hdr);
			if (path.p_ptr != -1) {
				ext4_ext_cursor_unpin(cur, i, 1);
				ext4_ext_cursor_set_buf(cur, i, &path);
			} else {
				ext4_ext_path_unpin(&path);
			}
			if (i) {
				memset(&nitems, 0, EXT4_EXT_ITEM_SIZE);
				ext4_idx_store_lblock(&nitems.i, prlblock);
				ext4_idx_store_block(&nitems.i, nblocknrs[i - 1]);
				ext4_ext_insert_item(cur, i, &nitems,
						     pptr != -1);
			}
			pptr = ptr;
			prlblock = rlblock;
		}
		memset(&nitems, 0, EXT4_EXT_ITEM_SIZE);
		ext4_idx_store_lblock(&nitems.i, prlblock);
		ext4_idx_store_block(&nitems.i, nblocknrs[i - 1]);
		ext4_ext_insert_item(cur, i, &nitems, pptr != -1);
	}

out:
	if (nblocknrs) {
		if (ret) {
			uint16_t i = nrallocs;

			while (i--)
				cur->c_cursor_op.c_free_block_func(cur,
								   nblocknrs[i]);
		}
		ext4_free(nblocknrs);
	}

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq $0x0, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6720
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x89c0
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x6d98
movslq -0x20(%rbp), %rdi
shlq $0x3, %rdi
callq 0x21c0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x6b78
movl $0xc, -0xc(%rbp)
jmp 0x6d9a
movw $0x0, -0x26(%rbp)
movzwl -0x26(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x6bce
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movzwl -0x26(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rsi
callq *%rax
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x6bb5
jmp 0x6d9a
jmp 0x6bb7
movw -0x26(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x26(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x6b7e
movw $0x0, -0x26(%rbp)
movzwl -0x26(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x6d42
movzwl -0x26(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x6c17
movq -0x8(%rbp), %rdi
movzwl -0x26(%rbp), %esi
movq -0x18(%rbp), %rax
movzwl -0x26(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
leaq -0x68(%rbp), %rcx
callq 0x8a30
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x6c15
jmp 0x6d9a
jmp 0x6c7d
movq -0x8(%rbp), %rdi
movzwl -0x26(%rbp), %esi
movq -0x18(%rbp), %rax
movzwl -0x26(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
leaq -0x68(%rbp), %rcx
callq 0x8c60
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x6c42
jmp 0x6d9a
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x80c0
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x6c62
jmp 0x6d9a
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x10(%rax)
movq -0x58(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x60(%rbp), %rdi
callq 0x8df0
movl %eax, -0x4c(%rbp)
cmpq $-0x1, -0x58(%rbp)
je 0x6cbd
movq -0x8(%rbp), %rdi
movzwl -0x26(%rbp), %esi
movl $0x1, %edx
callq 0x62d0
movq -0x8(%rbp), %rdi
movzwl -0x26(%rbp), %esi
leaq -0x68(%rbp), %rdx
callq 0x63e0
jmp 0x6cc6
leaq -0x68(%rbp), %rdi
callq 0x6380
cmpw $0x0, -0x26(%rbp)
je 0x6d23
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x20d0
movl -0x34(%rbp), %esi
leaq -0x40(%rbp), %rdi
callq 0x8e40
movq -0x18(%rbp), %rax
movzwl -0x26(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x40(%rbp), %rdi
callq 0x8e60
movq -0x8(%rbp), %rdi
movzwl -0x26(%rbp), %esi
cmpq $-0x1, -0x30(%rbp)
setne %al
movzbl %al, %ecx
andl $0x1, %ecx
leaq -0x40(%rbp), %rdx
callq 0x6e00
movq -0x48(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x34(%rbp)
movw -0x26(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x26(%rbp)
jmp 0x6bd4
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x20d0
movl -0x34(%rbp), %esi
leaq -0x40(%rbp), %rdi
callq 0x8e40
movq -0x18(%rbp), %rax
movzwl -0x26(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x40(%rbp), %rdi
callq 0x8e60
movq -0x8(%rbp), %rdi
movzwl -0x26(%rbp), %esi
cmpq $-0x1, -0x30(%rbp)
setne %al
movzbl %al, %ecx
andl $0x1, %ecx
leaq -0x40(%rbp), %rdx
callq 0x6e00
jmp 0x6d9a
cmpq $0x0, -0x18(%rbp)
je 0x6dea
cmpl $0x0, -0xc(%rbp)
je 0x6de1
movl -0x24(%rbp), %eax
movw %ax, -0x6a(%rbp)
movw -0x6a(%rbp), %ax
movw %ax, %cx
addw $-0x1, %cx
movw %cx, -0x6a(%rbp)
cmpw $0x0, %ax
je 0x6ddf
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rcx
movzwl -0x6a(%rbp), %edx
movq (%rcx,%rdx,8), %rsi
callq *%rax
jmp 0x6dae
jmp 0x6de1
movq -0x18(%rbp), %rdi
callq 0x2030
movl -0xc(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)