// File: /workspace/github_c_makefile_star2_O0/lh3[P]minigraph/algo.c
// Function: mg_intv_index
int32_t mg_intv_index(int32_t n, mg_intv_t *a)
{
	int32_t i, last_i, last, k;
	if (n <= 0) return -1;
	radix_sort_mg_intv(a, a + n);
	for (i = 0; i < n; i += 2) last_i = i, last = a[i].far = a[i].en;
	for (k = 1; 1LL<<k <= n; ++k) {
		int64_t x = 1LL<<(k-1), i0 = (x<<1) - 1, step = x<<2;
		for (i = i0; i < n; i += step) {
			int32_t el = a[i - x].far;
			int32_t er = i + x < n? a[i + x].far : last;
			int32_t e = a[i].en;
			e = e > el? e : el;
			e = e > er? e : er;
			a[i].far = e;
		}
		last_i = last_i>>k&1? last_i - x : last_i + x;
		if (last_i < n && a[last_i].far > last)
			last = a[last_i].far;
	}
	return k - 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
jg 0x4001
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4213
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movslq -0x8(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x3f80
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x4065
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl %eax, 0x8(%rcx)
movl %eax, -0x1c(%rbp)
movl -0x14(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x14(%rbp)
jmp 0x4020
movl $0x1, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movslq -0x8(%rbp), %rcx
cmpq %rcx, %rax
jg 0x420a
movl -0x20(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
shlq %rax
subq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x4195
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
subq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x3c(%rbp)
movslq -0x14(%rbp), %rax
addq -0x28(%rbp), %rax
movslq -0x8(%rbp), %rcx
cmpq %rcx, %rax
jge 0x410f
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
addq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x48(%rbp)
jmp 0x4115
movl -0x1c(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jle 0x4145
movl -0x44(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x414b
movl -0x3c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x40(%rbp), %eax
jle 0x4161
movl -0x44(%rbp), %eax
movl %eax, -0x50(%rbp)
jmp 0x4167
movl -0x40(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0x38(%rbp), %rcx
movslq -0x14(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x14(%rbp)
jmp 0x40be
movl -0x18(%rbp), %eax
movl -0x20(%rbp), %ecx
sarl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x41b3
movslq -0x18(%rbp), %rax
subq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x41bf
movslq -0x18(%rbp), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x41fa
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x1c(%rbp), %eax
jle 0x41fa
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0x41fc
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x406c
movl -0x20(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)