// File: /workspace/github_cpp_makefile_star2_O2/ddunbar[P]PDSample/ScallopedSector.cpp
// Function: ScallopedRegion::subtractDisk(Vec2, float)
void ScallopedRegion::subtractDisk(Vec2 C, float r)
{
	std::vector<ScallopedSector> *newRegions = new std::vector<ScallopedSector>;

	area = 0;
	for (unsigned int i=0; i<regions->size(); i++) {
		ScallopedSector &ss = (*regions)[i];
		std::vector<ScallopedSector> *tmp = new std::vector<ScallopedSector>;

		ss.subtractDisk(C, r, tmp);

		for (unsigned int j=0; j<tmp->size(); j++) {
			ScallopedSector &nss = (*tmp)[j];

			if (nss.area>minArea) {
				area += nss.area;

				if (newRegions->size()) {
					ScallopedSector &last = (*newRegions)[newRegions->size()-1];
					if (last.a2==nss.a1 && (last.arcs[0].P==nss.arcs[0].P && last.arcs[0].r==nss.arcs[0].r && last.arcs[0].sign==nss.arcs[0].sign) &&
						(last.arcs[1].P==nss.arcs[1].P && last.arcs[1].r==nss.arcs[1].r && last.arcs[1].sign==nss.arcs[1].sign)) {
						last.a2 = nss.a2;
						last.area = last.calcAreaToAngle(last.a2);
						continue;
					}
				}

				newRegions->push_back(nss);
			}
		}

		delete tmp;
	}

	delete regions;
	regions = newRegions;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movss %xmm1, 0x4(%rsp)
movq %rdi, %rbx
leaq 0x10(%rsp), %rax
movlps %xmm0, (%rax)
pushq $0x18
popq %rdi
callq 0x2190
movq %rax, %r14
xorps %xmm0, %xmm0
andq $0x0, 0x10(%rax)
movups %xmm0, (%rax)
andl $0x0, 0xc(%rbx)
xorl %ecx, %ecx
pushq $0x5c
popq %r12
movl %ecx, %ecx
movq (%rbx), %r13
movq (%r13), %rbp
movq 0x8(%r13), %rax
subq %rbp, %rax
cqto
idivq %r12
cmpq %rcx, %rax
jbe 0x7b53
movq %rcx, 0x8(%rsp)
imulq $0x5c, %rcx, %rax
addq %rax, %rbp
pushq $0x18
popq %rdi
callq 0x2190
movq %rax, %r13
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq %rbp, %rdi
leaq 0x10(%rsp), %rsi
movss 0x4(%rsp), %xmm0
movq %rax, %rdx
callq 0x72f2
xorl %ebp, %ebp
movl %ebp, %ebp
movq (%r13), %rsi
movq 0x8(%r13), %rax
subq %rsi, %rax
cqto
idivq %r12
cmpq %rbp, %rax
jbe 0x7b34
imulq $0x5c, %rbp, %rax
movss 0x10(%rsi,%rax), %xmm0
ucomiss 0x8(%rbx), %xmm0
jbe 0x7b2d
addq %rax, %rsi
addss 0xc(%rbx), %xmm0
movss %xmm0, 0xc(%rbx)
movq 0x8(%r14), %r15
cmpq (%r14), %r15
je 0x7b25
movss -0x50(%r15), %xmm0
ucomiss 0x8(%rsi), %xmm0
jne 0x7b25
jp 0x7b25
movss -0x48(%r15), %xmm0
ucomiss 0x14(%rsi), %xmm0
jne 0x7b25
jp 0x7b25
movss -0x44(%r15), %xmm0
ucomiss 0x18(%rsi), %xmm0
jne 0x7b25
jp 0x7b25
movss -0x40(%r15), %xmm0
ucomiss 0x1c(%rsi), %xmm0
jne 0x7b25
jp 0x7b25
movss -0x3c(%r15), %xmm0
ucomiss 0x20(%rsi), %xmm0
jne 0x7b25
jp 0x7b25
movss -0x24(%r15), %xmm0
ucomiss 0x38(%rsi), %xmm0
jne 0x7b25
jp 0x7b25
movss -0x20(%r15), %xmm0
ucomiss 0x3c(%rsi), %xmm0
jne 0x7b25
jp 0x7b25
movss -0x1c(%r15), %xmm0
ucomiss 0x40(%rsi), %xmm0
jne 0x7b25
jp 0x7b25
movss -0x18(%r15), %xmm0
ucomiss 0x44(%rsi), %xmm0
jne 0x7b25
jp 0x7b25
movq %r15, %rdi
addq $-0x5c, %rdi
movss 0xc(%rsi), %xmm0
movss %xmm0, -0x50(%r15)
callq 0x6ece
movss %xmm0, -0x4c(%r15)
jmp 0x7b2d
movq %r14, %rdi
callq 0x7cb8
incl %ebp
jmp 0x7a2f
movq %r13, %rdi
callq 0x84bc
movq %r13, %rdi
pushq $0x18
popq %rsi
callq 0x21a0
movq 0x8(%rsp), %rcx
incl %ecx
jmp 0x79d7
movq %r13, %rdi
callq 0x84bc
pushq $0x18
popq %rsi
movq %r13, %rdi
callq 0x21a0
movq %r14, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq