// File: /workspace/github_c_makefile_star2_O2/ngkaho1234[P]ext4-extents-tree/extrm.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;

	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]);
	for (; (int32_t)(to - from) * dir >= 0; from += 1 * dir) {
		bool notfound;
		struct ext4_ext_cursor *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);
			ext4_ext_cursor_free(cur);
			break;
		}

		if (!notfound) {
			fprintf(stderr, "Removing extent containing block: %" PRIu32 "\n", from);
			err = ext4_ext_delete(cur);
			if (err) {
				fprintf(stderr, "err: %s, block: %" PRIu32 "\n",
						strerror(err), from);
				ext4_ext_cursor_free(cur);
				break;
			}
		}
		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 $0x28, %rsp
cmpl $0x4, %edi
jge 0x23e6
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rbx
movq 0x10(%rsi), %rdi
xorl %r13d, %r13d
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
cmpl %r12d, %r15d
adcl $-0x1, %r13d
callq 0x2090
movq %rax, -0x48(%rbp)
movq 0x8(%rbx), %rdi
callq 0x2792
pushq $0xc
popq %rsi
movl %eax, %edi
callq 0x27bd
movq %rax, -0x38(%rbp)
movq 0x10(%rax), %r14
pushq $0x1
popq %rdi
movl $0x80, %esi
callq 0x2140
movq %r14, (%rax)
movq %rax, %r14
leaq 0x21f(%rip), %rax       # 0x2670
movq %rax, 0x78(%r14)
leaq 0x8(%r14), %rsi
movaps 0x3bb0(%rip), %xmm0     # 0x6010
movups %xmm0, 0x8(%r14)
leaq 0x20(%r14), %rbx
movl $0x2d, 0x20(%r14)
pushq $-0x1
popq %rdi
pushq $0x10
popq %rdx
callq 0x3a7c
movl %eax, 0x28(%r14)
pushq $0x4
popq %rdx
movl %eax, %edi
movq %rbx, %rsi
movq %rdx, %rbx
callq 0x3a7c
movl %eax, 0x28(%r14)
leaq 0x24(%r14), %rsi
movl %eax, %edi
movq %rbx, %rdx
callq 0x3a7c
movl %eax, 0x28(%r14)
movq -0x38(%rbp), %rdi
callq 0x3253
testq %rax, %rax
je 0x2668
orl $0x1, %r13d
movq %r13, -0x40(%rbp)
movq (%r14), %rdi
callq 0x3f90
movq %rax, %r13
movq %r14, %rbx
addq $0x38, %rbx
movq 0x10(%rax), %rax
movups 0x14(%rax), %xmm0
movups 0x24(%rax), %xmm1
movups 0x34(%rax), %xmm2
movups 0x40(%rax), %xmm3
movups %xmm0, 0x38(%r14)
movups %xmm1, 0x48(%r14)
movups %xmm2, 0x58(%r14)
movups %xmm3, 0x64(%r14)
cmpw $0xf30a, 0x38(%r14)     # imm = 0xF30A
je 0x2510
movq %rbx, %rdi
callq 0x5a1a
orb $0x1, 0x74(%r14)
movq %r14, -0x38(%rbp)
movq %r13, 0x18(%r14)
subl %r15d, %r12d
movq -0x40(%rbp), %rax
imull %eax, %r12d
movl %eax, %r14d
imull %eax, %r14d
testl %r12d, %r12d
js 0x25d5
movq -0x38(%rbp), %rdx
movq (%rdx), %rdi
movq (%rdi), %rcx
movq %rbx, %rsi
callq 0x40f2
movq %rax, %r13
movq %rax, %rdi
movl %r15d, %esi
leaq -0x29(%rbp), %rdx
callq 0x42d9
testl %eax, %eax
jne 0x2599
cmpb $0x0, -0x29(%rbp)
je 0x2572
movq %r13, %rdi
callq 0x42af
addl -0x40(%rbp), %r15d
subl %r14d, %r12d
jmp 0x252a
movq 0x7a7f(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x3ab1(%rip), %rsi      # 0x6034
movl %r15d, %edx
xorl %eax, %eax
callq 0x2160
movq %r13, %rdi
callq 0x532f
testl %eax, %eax
je 0x2561
movq 0x7a58(%rip), %r14      # 0x9ff8
movq (%r14), %rbx
movl %eax, %r12d
movl %eax, %edi
callq 0x2280
leaq 0x3a6c(%rip), %rsi      # 0x6020
movq %rbx, %rdi
movq %rax, %rdx
movl %r15d, %ecx
movq %r14, %r15
xorl %eax, %eax
callq 0x2160
movq %r13, %rdi
callq 0x42af
movq -0x38(%rbp), %r14
jmp 0x25e3
movq -0x38(%rbp), %r14
movq 0x7a18(%rip), %r15      # 0x9ff8
xorl %r12d, %r12d
callq 0x2090
movq %rax, %rbx
movq (%r15), %r15
negl %r12d
movl %r12d, %edi
callq 0x2280
movq %rax, %rcx
subq -0x48(%rbp), %rbx
movl $0xf4240, %esi          # imm = 0xF4240
movq %rbx, %rax
cqto
idivq %rsi
leaq 0x3a46(%rip), %rsi      # 0x605a
xorl %ebx, %ebx
movq %r15, %rdi
movq %rcx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2160
movq (%r14), %rax
movq 0x18(%r14), %r12
movq 0x10(%rax), %r15
testb $0x1, 0x74(%r14)
je 0x2646
movq 0x78(%r14), %rax
testq %rax, %rax
je 0x2646
movq %r14, %rdi
callq *%rax
movq %r14, %rdi
callq 0x2030
movq %r12, %rdi
callq 0x401d
movq %r15, %rdi
callq 0x293f
callq 0x2766
jmp 0x23d5
pushq $0x1
popq %rdi
callq 0x2250