// File: /workspace/github_cpp_makefile_star2_O2/dmarto[P]crrs-xlib/main.cpp
// Function: Reflection(std::vector<Sphere*, std::allocator<Sphere*>> const&, Vec3 const&, Vec3 const&, Vec3&)
void Reflection(const std::vector<Sphere *> &objects, const Vec3 &pointOfIntersection, const Vec3 &normal, Vec3 &pixclr)
{
	Colors color;
	double reflectionIntensity = 2.5;

	for (auto &sphereB : objects)
	{
		const Ray ray2(pointOfIntersection, normal * 40);
		double t2;
		if (sphereB->Intersects(ray2, t2))
		{
			const Vec3 pointOfIntersection2 = ray2.origin + ray2.destination * t2;
			const Vec3 len2 = pointOfIntersection - pointOfIntersection2;
			const Vec3 normal2 = sphereB->GetNormal(pointOfIntersection2);
			const double dotP2 = dot(len2.Normalize(), normal2.Normalize());

			Vec3 pixclrBounce = sphereB->clr * dotP2 * reflectionIntensity;
			if (sphereB->name == "world")
				pixclrBounce = pixclrBounce - color.white / 1.5;

			ColorBoundary(pixclrBounce);
			pixclr = pixclrBounce + pixclr;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq (%rdi), %r13
movq 0x8(%rdi), %rbp
cmpq %rbp, %r13
je 0x155b
movsd 0x10(%r14), %xmm0
mulsd 0x1c63(%rip), %xmm0     # 0x3010
movupd (%r14), %xmm1
mulpd 0x1cd6(%rip), %xmm1     # 0x3090
movq 0x10(%r15), %rax
movq %rax, 0x30(%rsp)
movupd (%r15), %xmm2
movapd %xmm2, 0x20(%rsp)
movupd %xmm1, 0x38(%rsp)
movsd %xmm0, 0x48(%rsp)
movq (%r13), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x20a0
testb %al, %al
je 0x1552
movsd 0x18(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
mulsd %xmm0, %xmm1
addsd 0x30(%rsp), %xmm1
movupd 0x38(%rsp), %xmm2
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm2, %xmm0
addpd 0x20(%rsp), %xmm0
movapd %xmm0, 0x90(%rsp)
movsd %xmm1, 0xa0(%rsp)
movsd 0x10(%r15), %xmm2
subsd %xmm1, %xmm2
movupd (%r15), %xmm1
subpd %xmm0, %xmm1
movapd %xmm1, 0x70(%rsp)
movsd %xmm2, 0x80(%rsp)
movq (%r13), %rsi
leaq 0xc0(%rsp), %r12
movq %r12, %rdi
leaq 0x90(%rsp), %rdx
callq 0x215e
movq %rsp, %rdi
leaq 0x70(%rsp), %rsi
callq 0x219a
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
callq 0x219a
movsd 0xa8(%rsp), %xmm0
mulsd (%rsp), %xmm0
movupd 0x8(%rsp), %xmm1
movupd 0xb0(%rsp), %xmm2
mulpd %xmm1, %xmm2
addsd %xmm2, %xmm0
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm0, %xmm2
movq (%r13), %rdi
mulsd 0x1b53(%rip), %xmm2     # 0x3018
movupd 0x20(%rdi), %xmm0
movapd %xmm2, %xmm1
unpcklpd %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
mulsd 0x30(%rdi), %xmm2
mulpd %xmm0, %xmm1
movapd %xmm1, 0x50(%rsp)
movapd %xmm1, (%rsp)
movapd %xmm2, 0x60(%rsp)
movsd %xmm2, 0x10(%rsp)
addq $0x38, %rdi
leaq 0x1d33(%rip), %rsi      # 0x3230
callq 0x21ec
testb %al, %al
je 0x152d
movapd 0x50(%rsp), %xmm1
addpd 0x1b8c(%rip), %xmm1     # 0x30a0
movapd 0x60(%rsp), %xmm0
addsd 0x1afe(%rip), %xmm0     # 0x3020
movapd %xmm1, (%rsp)
movsd %xmm0, 0x10(%rsp)
movq %rsp, %rdi
callq 0x130c
movsd 0x10(%rbx), %xmm0
addsd 0x10(%rsp), %xmm0
movupd (%rbx), %xmm1
addpd (%rsp), %xmm1
movupd %xmm1, (%rbx)
movsd %xmm0, 0x10(%rbx)
addq $0x8, %r13
jmp 0x1396
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq