// File: /workspace/github_cpp_makefile_star2_O2/ddunbar[P]PDSample/RangeList.cpp
// Function: RangeList::subtract(float, float)
void RangeList::subtract(float a, float b)
{
	static const float twoPi = (float) (M_PI*2);

	if (a>twoPi) {
		subtract(a-twoPi, b-twoPi);
	} else if (b<0) {
		subtract(a+twoPi, b+twoPi);
	} else if (a<0) {
		subtract(0, b);
		subtract(a+twoPi,twoPi);
	} else if (b>twoPi) {
		subtract(a, twoPi);
		subtract(0, b-twoPi);
	} else if (numRanges==0) {
		;
	} else {
		int pos;

		if (a<ranges[0].min) {
			pos = -1;
		} else {
			int lo=0, mid=0, hi=numRanges;

			while (lo<hi-1) {
				mid = (lo+hi)>>1;
				if (ranges[mid].min<a) {
					lo = mid;
				} else {
					hi = mid;
				}
			}

			pos = lo;
		}

		if (pos==-1) {
			pos = 0;
		} else if (a<ranges[pos].max) {
			float c = ranges[pos].min;
			float d = ranges[pos].max;
			if (a-c<kSmallestRange) {
				if (b<d) {
					ranges[pos].min = b;
				} else {
					deleteRange(pos);
				}
			} else {
				ranges[pos].max = a;
				if (b<d) {
					insertRange(pos+1, b, d);
				}
				pos++;
			}
		} else {
			if (pos<numRanges-1 && b>ranges[pos+1].min) {
				pos++;
			} else {
				return;
			}
		}

		while (pos<numRanges && b>ranges[pos].min) {
			if (ranges[pos].max-b<kSmallestRange) {
				deleteRange(pos);
			} else {
				ranges[pos].min = b;
			}
		}
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movaps %xmm1, %xmm4
movq %rdi, %rbx
movss 0x2a2e(%rip), %xmm1     # 0x9484
movss 0x4afe(%rip), %xmm2     # 0xb55c
xorps %xmm3, %xmm3
ucomiss %xmm1, %xmm0
jbe 0x6a70
addss %xmm2, %xmm0
addss %xmm2, %xmm4
jmp 0x6a61
ucomiss %xmm4, %xmm3
movaps %xmm0, %xmm5
addss %xmm1, %xmm5
jbe 0x6a85
addss %xmm1, %xmm4
movaps %xmm5, %xmm0
jmp 0x6a61
ucomiss %xmm0, %xmm3
jbe 0x6abc
xorps %xmm0, %xmm0
movq %rbx, %rdi
movaps %xmm4, %xmm1
movss %xmm5, 0x4(%rsp)
callq 0x6a44
xorps %xmm3, %xmm3
movss 0x4ab3(%rip), %xmm2     # 0xb55c
movss 0x29d3(%rip), %xmm1     # 0x9484
movss 0x4(%rsp), %xmm0
movaps %xmm1, %xmm4
jmp 0x6a61
ucomiss %xmm1, %xmm4
movss %xmm4, 0x4(%rsp)
jbe 0x6afc
movq %rbx, %rdi
movss 0x29b2(%rip), %xmm1     # 0x9484
callq 0x6a44
xorps %xmm3, %xmm3
movss 0x4a7a(%rip), %xmm2     # 0xb55c
movss 0x299a(%rip), %xmm1     # 0x9484
movss 0x4(%rsp), %xmm4
addss %xmm2, %xmm4
xorps %xmm0, %xmm0
jmp 0x6a61
movl 0x8(%rbx), %ecx
testl %ecx, %ecx
je 0x6bd5
movq (%rbx), %rax
movss (%rax), %xmm1
ucomiss %xmm0, %xmm1
ja 0x6b71
xorl %r14d, %r14d
movl %ecx, %edx
leal -0x1(%rdx), %esi
cmpl %esi, %r14d
jge 0x6b38
leal (%r14,%rdx), %esi
sarl %esi
movslq %esi, %rdi
ucomiss (%rax,%rdi,8), %xmm0
ja 0x6b33
movl %esi, %edx
jmp 0x6b18
movl %esi, %r14d
jmp 0x6b18
cmpl $-0x1, %r14d
je 0x6b71
movslq %r14d, %rdx
movss 0x4(%rax,%rdx,8), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x6bc2
movaps %xmm0, %xmm2
subss (%rax,%rdx,8), %xmm2
movss 0x49fc(%rip), %xmm3     # 0xb558
ucomiss %xmm2, %xmm3
jbe 0x6bdd
ucomiss %xmm4, %xmm1
jbe 0x6bfb
movss %xmm4, (%rax,%rdx,8)
jmp 0x6b74
xorl %r14d, %r14d
movslq %r14d, %r14
movss 0x49d9(%rip), %xmm1     # 0xb558
cmpl 0x8(%rbx), %r14d
jge 0x6bd5
movq (%rbx), %rax
ucomiss (%rax,%r14,8), %xmm4
jbe 0x6bd5
movss 0x4(%rax,%r14,8), %xmm0
subss %xmm4, %xmm0
ucomiss %xmm0, %xmm1
jbe 0x6bba
movq %rbx, %rdi
movl %r14d, %esi
callq 0x6946
movss 0x49a6(%rip), %xmm1     # 0xb558
movss 0x4(%rsp), %xmm4
jmp 0x6b7f
movss %xmm4, (%rax,%r14,8)
jmp 0x6b7f
decl %ecx
cmpl %ecx, %r14d
jge 0x6bd5
ucomiss 0x8(%rax,%rdx,8), %xmm4
jbe 0x6bd5
incl %r14d
jmp 0x6b74
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movss %xmm0, 0x4(%rax,%rdx,8)
incl %r14d
ucomiss %xmm4, %xmm1
jbe 0x6b74
movq %rbx, %rdi
movl %r14d, %esi
movaps %xmm4, %xmm0
callq 0x6984
jmp 0x6c06
movq %rbx, %rdi
movl %r14d, %esi
callq 0x6946
movss 0x4(%rsp), %xmm4
jmp 0x6b74
nop