// File: /workspace/github_cpp_makefile_star2_O1/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 0x30a7(%rip), %xmm0     # 0xa498
movss 0x5173(%rip), %xmm1     # 0xc56c
xorps %xmm2, %xmm2
ucomiss %xmm0, %xmm4
jbe 0x740b
addss %xmm1, %xmm4
addss %xmm1, %xmm3
jmp 0x73fc
ucomiss %xmm3, %xmm2
jbe 0x741a
addss %xmm0, %xmm4
addss %xmm0, %xmm3
jmp 0x73fc
ucomiss %xmm4, %xmm2
jbe 0x7455
xorps %xmm0, %xmm0
movq %rbx, %rdi
movaps %xmm3, %xmm1
movss %xmm4, 0x4(%rsp)
callq 0x73d8
xorps %xmm2, %xmm2
movss 0x512e(%rip), %xmm1     # 0xc56c
movss 0x3052(%rip), %xmm0     # 0xa498
movss 0x4(%rsp), %xmm4
addss %xmm0, %xmm4
movaps %xmm0, %xmm3
jmp 0x73fc
ucomiss %xmm0, %xmm3
movss %xmm3, 0x4(%rsp)
jbe 0x7498
movq %rbx, %rdi
movaps %xmm4, %xmm0
movss 0x302a(%rip), %xmm1     # 0xa498
callq 0x73d8
xorps %xmm2, %xmm2
movss 0x50ee(%rip), %xmm1     # 0xc56c
movss 0x3012(%rip), %xmm0     # 0xa498
movss 0x4(%rsp), %xmm3
addss %xmm1, %xmm3
xorps %xmm4, %xmm4
jmp 0x73fc
movl 0x8(%rbx), %eax
testl %eax, %eax
je 0x75f3
movq (%rbx), %rcx
movss (%rcx), %xmm0
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
ucomiss %xmm4, %xmm0
ja 0x74e0
xorl %r14d, %r14d
cmpl $0x2, %eax
jl 0x74e0
xorl %r14d, %r14d
movl %eax, %edx
leal (%r14,%rdx), %esi
sarl %esi
movslq %esi, %rdi
ucomiss (%rcx,%rdi,8), %xmm4
ja 0x74d5
movl %esi, %edx
jmp 0x74d8
movl %esi, %r14d
leal -0x1(%rdx), %esi
cmpl %esi, %r14d
jl 0x74c2
cmpl $-0x1, %r14d
je 0x7517
movslq %r14d, %rdx
movss 0x4(%rcx,%rdx,8), %xmm1
ucomiss %xmm4, %xmm1
jbe 0x751c
leaq (%rcx,%rdx,8), %rdi
movaps %xmm4, %xmm0
subss (%rdi), %xmm0
movss 0x5061(%rip), %xmm2     # 0xc568
ucomiss %xmm0, %xmm2
jbe 0x7533
ucomiss %xmm3, %xmm1
jbe 0x7557
movss %xmm3, (%rdi)
jmp 0x7583
xorl %r14d, %r14d
jmp 0x7583
decl %eax
cmpl %eax, %r14d
jge 0x75f3
ucomiss 0x8(%rcx,%rdx,8), %xmm3
ja 0x7552
jmp 0x75f3
movss %xmm4, 0x4(%rdi)
ucomiss %xmm3, %xmm1
jbe 0x7552
leal 0x1(%r14), %esi
movq %rbx, %rdi
movaps %xmm3, %xmm0
callq 0x731c
movss 0x4(%rsp), %xmm3
incl %r14d
jmp 0x7583
leal -0x1(%rax), %esi
cmpl %r14d, %esi
jle 0x7580
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
decl 0x8(%rbx)
movl 0x8(%rbx), %eax
cmpl %eax, %r14d
jge 0x75f3
movslq %r14d, %r15
leal 0x1(%r14), %ecx
movslq %ecx, %r12
movss 0x4fcb(%rip), %xmm1     # 0xc568
movq (%rbx), %rcx
ucomiss (%rcx,%r15,8), %xmm3
jbe 0x75f3
leaq (%rcx,%r15,8), %rdi
movss 0x4(%rdi), %xmm0
subss %xmm3, %xmm0
ucomiss %xmm0, %xmm1
jbe 0x75e7
leal -0x1(%rax), %edx
cmpl %r14d, %edx
jle 0x75e2
leaq (%rcx,%r12,8), %rsi
subl %r12d, %eax
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x22d0
movss 0x4f8c(%rip), %xmm1     # 0xc568
movss 0x4(%rsp), %xmm3
decl 0x8(%rbx)
jmp 0x75eb
movss %xmm3, (%rdi)
movl 0x8(%rbx), %eax
cmpl %eax, %r14d
jl 0x759d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop