// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movaps %xmm1, %xmm3
movaps %xmm0, %xmm4
movq %rdi, %rbx
movss 0x31d9(%rip), %xmm0     # 0xa484
movss 0x52a9(%rip), %xmm1     # 0xc55c
xorps %xmm2, %xmm2
ucomiss %xmm0, %xmm4
jbe 0x72c5
addss %xmm1, %xmm4
addss %xmm1, %xmm3
jmp 0x72b6
ucomiss %xmm3, %xmm2
jbe 0x72d4
addss %xmm0, %xmm4
addss %xmm0, %xmm3
jmp 0x72b6
ucomiss %xmm4, %xmm2
jbe 0x730f
xorps %xmm0, %xmm0
movq %rbx, %rdi
movaps %xmm3, %xmm1
movss %xmm4, 0x4(%rsp)
callq 0x7292
xorps %xmm2, %xmm2
movss 0x5264(%rip), %xmm1     # 0xc55c
movss 0x3184(%rip), %xmm0     # 0xa484
movss 0x4(%rsp), %xmm4
addss %xmm0, %xmm4
movaps %xmm0, %xmm3
jmp 0x72b6
ucomiss %xmm0, %xmm3
movss %xmm3, 0x4(%rsp)
jbe 0x7352
movq %rbx, %rdi
movaps %xmm4, %xmm0
movss 0x315c(%rip), %xmm1     # 0xa484
callq 0x7292
xorps %xmm2, %xmm2
movss 0x5224(%rip), %xmm1     # 0xc55c
movss 0x3144(%rip), %xmm0     # 0xa484
movss 0x4(%rsp), %xmm3
addss %xmm1, %xmm3
xorps %xmm4, %xmm4
jmp 0x72b6
movl 0x8(%rbx), %eax
testl %eax, %eax
je 0x746e
movq (%rbx), %rcx
movss (%rcx), %xmm0
ucomiss %xmm4, %xmm0
jbe 0x73ee
xorl %r14d, %r14d
cmpl %eax, %r14d
jge 0x746e
movslq %r14d, %r15
leal 0x1(%r14), %ecx
movslq %ecx, %r12
movss 0x51cd(%rip), %xmm1     # 0xc558
movq (%rbx), %rcx
ucomiss (%rcx,%r15,8), %xmm3
jbe 0x746e
leaq (%rcx,%r15,8), %rdi
movss 0x4(%rdi), %xmm0
subss %xmm3, %xmm0
ucomiss %xmm0, %xmm1
jbe 0x73e0
leal -0x1(%rax), %edx
cmpl %r14d, %edx
jle 0x73d9
leaq (%rcx,%r12,8), %rsi
subl %r12d, %eax
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x22d0
movss 0x518a(%rip), %xmm1     # 0xc558
movss 0x4(%rsp), %xmm3
movl 0x8(%rbx), %edx
decl %edx
movl %edx, 0x8(%rbx)
movl %edx, %eax
jmp 0x73e4
movss %xmm3, (%rdi)
cmpl %eax, %r14d
jl 0x738b
jmp 0x746e
xorl %r14d, %r14d
cmpl $0x2, %eax
jl 0x7423
xorl %r14d, %r14d
movl %eax, %edx
leal (%r14,%rdx), %esi
sarl %esi
movslq %esi, %rdi
ucomiss (%rcx,%rdi,8), %xmm4
ja 0x740e
movl %esi, %edx
jmp 0x7411
movl %esi, %r14d
leal -0x1(%rdx), %esi
cmpl %esi, %r14d
jl 0x73fb
cmpl $-0x1, %r14d
je 0x736d
movslq %r14d, %rdx
movss 0x4(%rcx,%rdx,8), %xmm1
ucomiss %xmm4, %xmm1
jbe 0x7457
leaq (%rcx,%rdx,8), %rdi
movaps %xmm4, %xmm0
subss (%rdi), %xmm0
movss 0x5114(%rip), %xmm2     # 0xc558
ucomiss %xmm0, %xmm2
jbe 0x747a
ucomiss %xmm3, %xmm1
jbe 0x74a7
movss %xmm3, (%rdi)
jmp 0x7370
leal -0x1(%rax), %esi
cmpl %esi, %r14d
jge 0x746e
ucomiss 0x8(%rcx,%rdx,8), %xmm3
jbe 0x746e
incl %r14d
jmp 0x7370
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movss %xmm4, 0x4(%rdi)
incl %r14d
ucomiss %xmm3, %xmm1
jbe 0x7370
movq %rbx, %rdi
movl %r14d, %esi
movaps %xmm3, %xmm0
callq 0x71ce
movss 0x4(%rsp), %xmm3
movl 0x8(%rbx), %eax
jmp 0x7370
leal -0x1(%rax), %esi
cmpl %r14d, %esi
jle 0x74d5
leaq (%rcx,%rdx,8), %rsi
addq $0x8, %rsi
movl %r14d, %ecx
notl %ecx
addl %eax, %ecx
movslq %ecx, %rdx
shlq $0x3, %rdx
callq 0x22d0
movss 0x4(%rsp), %xmm3
movl 0x8(%rbx), %esi
decl %esi
movl %esi, 0x8(%rbx)
movl %esi, %eax
jmp 0x7370
nop