// File: /workspace/github_c_makefile_star2_O3/ngkaho1234[P]ext4-extents-tree/extrm-ranged.c
// Function: main
int main(int argc, char **argv)
{
	int dir;
	int err = 0;
	struct inode *inode;
	time_t a, b;
	ext4_lblk_t from, to;
	bool notfound;
	struct ext4_ext_cursor *cur;

	if (argc < 4)
		return -1;

	from = strtoul(argv[2], NULL, 0);
	to = strtoul(argv[3], NULL, 0);
	dir = (to > from)?1:-1;
	a = clock();
	inode = open_ext4_db(argv[1]);

	if (dir == -1) {
		ext4_lblk_t tmp = to;
		to = from;
		from = tmp;
	}

	cur = ext4_ext_cursor_alloc(inode->i_sb, inode->i_data, inode, inode->i_sb->s_blocksize);

	err = ext4_ext_lookup_extent(cur, from, &notfound);
	if (err) {
		fprintf(stderr, "err: %s, block: %" PRIu32 "\n",
				strerror(err), from);
		goto out;
	}

	if (!notfound) {
		fprintf(stderr, "Removing extent containing block: %" PRIu32 " - %" PRIu32 "\n",
			from, to);
		err = ext4_ext_delete_range(cur, from, to);
		if (err) {
			fprintf(stderr, "err: %s, block: %" PRIu32 "\n",
					strerror(err), from);
		}
	}

out:
	ext4_ext_cursor_free(cur);

	b = clock();
	fprintf(stderr, "err: %s, clock: %ld\n", strerror(-err), (b - a)/CLOCKS_PER_SEC);
	free_ext4_db(inode);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpl $0x4, %edi
jge 0x247a
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rbx
movq 0x10(%rsi), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2230
movq %rax, %r15
movq 0x18(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2230
movq %rax, %r12
callq 0x2090
movq %rax, -0x38(%rbp)
movq 0x8(%rbx), %rdi
callq 0x27fa
movl %eax, %edi
movl $0xc, %esi
callq 0x2827
movq %rax, %r14
movq 0x10(%rax), %r13
movl $0x1, %edi
movl $0x80, %esi
callq 0x2140
movq %rax, %rbx
movq %r13, (%rax)
leaq 0x1fd(%rip), %rax       # 0x26db
movq %rax, 0x78(%rbx)
leaq 0x8(%rbx), %rsi
movaps 0x3b23(%rip), %xmm0     # 0x6010
movups %xmm0, 0x8(%rbx)
leaq 0x20(%rbx), %r13
movl $0x2d, 0x20(%rbx)
movl $0x10, %edx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3b18
movl %eax, 0x28(%rbx)
movl $0x4, %edx
movl %eax, %edi
movq %r13, %rsi
callq 0x3b18
movl %eax, 0x28(%rbx)
leaq 0x24(%rbx), %rsi
movl $0x4, %edx
movl %eax, %edi
callq 0x3b18
movl %eax, 0x28(%rbx)
movq %r14, %rdi
callq 0x32c5
testq %rax, %rax
je 0x26d1
movq (%rbx), %rdi
callq 0x410c
movq %rax, %r13
movq %rbx, %r14
addq $0x38, %r14
movq 0x10(%rax), %rax
movups 0x14(%rax), %xmm0
movups 0x24(%rax), %xmm1
movups 0x34(%rax), %xmm2
movups 0x40(%rax), %xmm3
movups %xmm0, 0x38(%rbx)
movups %xmm1, 0x48(%rbx)
movups %xmm2, 0x58(%rbx)
movups %xmm3, 0x64(%rbx)
cmpw $0xf30a, 0x38(%rbx)     # imm = 0xF30A
je 0x258e
movq %r14, %rdi
callq 0x5d68
orb $0x1, 0x74(%rbx)
movq %r13, 0x18(%rbx)
cmpl %r15d, %r12d
movl %r15d, %r13d
cmoval %r12d, %r15d
cmovbl %r12d, %r13d
movq (%rbx), %rdi
movq (%rdi), %rcx
movq %r14, %rsi
movq %rbx, %rdx
callq 0x427b
movq %rax, %r12
leaq -0x29(%rbp), %rdx
movq %rax, %rdi
movl %r13d, %esi
callq 0x44bd
testl %eax, %eax
jne 0x2603
xorl %r14d, %r14d
cmpb $0x0, -0x29(%rbp)
jne 0x262f
movq 0x7a21(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x3a53(%rip), %rsi      # 0x6034
xorl %r14d, %r14d
movl %r13d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2160
movq %r12, %rdi
movl %r13d, %esi
movl %r15d, %edx
callq 0x50dc
testl %eax, %eax
je 0x262f
movl %eax, %r14d
movq 0x79eb(%rip), %rax      # 0x9ff8
movq (%rax), %r15
movl %r14d, %edi
callq 0x2280
leaq 0x3a01(%rip), %rsi      # 0x6020
movq %r15, %rdi
movq %rax, %rdx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2160
movq %r12, %rdi
callq 0x448e
callq 0x2090
movq %rax, %r15
movq 0x79b2(%rip), %rax      # 0x9ff8
movq (%rax), %r12
negl %r14d
movl %r14d, %edi
callq 0x2280
movq %rax, %r8
subq -0x38(%rbp), %r15
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
movq %r15, %rax
imulq %rcx
movq %rdx, %rcx
shrq $0x3f, %rcx
sarq $0x12, %rdx
addq %rdx, %rcx
leaq 0x39df(%rip), %rsi      # 0x605f
xorl %r14d, %r14d
movq %r12, %rdi
movq %r8, %rdx
xorl %eax, %eax
callq 0x2160
movq (%rbx), %rax
movq 0x18(%rbx), %r12
movq 0x10(%rax), %r15
testb $0x1, 0x74(%rbx)
je 0x26af
movq 0x78(%rbx), %rax
testq %rax, %rax
je 0x26af
movq %rbx, %rdi
callq *%rax
movq %rbx, %rdi
callq 0x2030
movq %r12, %rdi
callq 0x41a0
movq %r15, %rdi
callq 0x29b7
callq 0x27d0
jmp 0x2468
movl $0x1, %edi
callq 0x2250