// File: iannisdezwart[P]forcefield-visualiser/./motion.hpp
// Function: motion::four_body()
void four_body()
	{
		// The center of the image

		Vector<2> image_centre({ WIDTH / 2, HEIGHT / 2 });

		// Set the planets and their rotation vectors

		// Planet 1

		Mass planet_1(200, 0, 4);
		masses.push_back(planet_1);

		double rotation_1 = 0.000625 * 2 * M_PI;

		Matrix<2, 2> rotation_matrix_1({
			{ cos(rotation_1), -sin(rotation_1) },
			{ sin(rotation_1), cos(rotation_1) },
		});

		// Planet 2

		Mass planet_2(0, 300, 3);
		masses.push_back(planet_2);

		double rotation_2 = 0.00125 * 2 * M_PI;

		Matrix<2, 2> rotation_matrix_2({
			{ cos(rotation_2), -sin(rotation_2) },
			{ sin(rotation_2), cos(rotation_2) },
		});

		// Planet 3

		Mass planet_3(-400, 0, 2);
		masses.push_back(planet_3);

		double rotation_3 = 0.001875 * 2 * M_PI;

		Matrix<2, 2> rotation_matrix_3({
			{ cos(rotation_3), -sin(rotation_3) },
			{ sin(rotation_3), cos(rotation_3) },
		});

		// Planet 4

		Mass planet_4(0, -500, 1);
		masses.push_back(planet_4);

		double rotation_4 = 0.0025 * 2 * M_PI;

		Matrix<2, 2> rotation_matrix_4({
			{ cos(rotation_4), -sin(rotation_4) },
			{ sin(rotation_4), cos(rotation_4) },
		});

		// Render 1600 frames

		for (int i = 0; i < 1600; i++) {
			string frame_number = to_string(i);

			if (frame_number.length() != 4) {
				frame_number = string(4 - frame_number.length(), '0') + frame_number;
			}

			// Move the planets

			// Planet 1

			planet_1.position = rotation_matrix_1 * planet_1.position;
			masses[0].position = planet_1.position + image_centre;

			// Planet 2

			planet_2.position = rotation_matrix_2 * planet_2.position;
			masses[1].position = planet_2.position + image_centre;

			// Planet 3

			planet_3.position = rotation_matrix_3 * planet_3.position;
			masses[2].position = planet_3.position + image_centre;

			// Planet 4

			planet_4.position = rotation_matrix_4 * planet_4.position;
			masses[3].position = planet_4.position + image_centre;

			// Render the frame

			render_image("output/" + frame_number + ".png", MULTI_THREADED);

			cout << "Rendered frame " << i << "/" << "1600\n";
		}
	}

// Assembly:
subq $0x4e8, %rsp            # imm = 0x4E8
movsd 0xa109(%rip), %xmm0     # 0xf068
movsd %xmm0, 0x4b8(%rsp)
movsd 0xa0f0(%rip), %xmm0     # 0xf060
movsd %xmm0, 0x4c0(%rsp)
leaq 0x4b8(%rsp), %rax
movq %rax, 0x4c8(%rsp)
movq $0x2, 0x4d0(%rsp)
movq 0x4c8(%rsp), %rsi
movq 0x4d0(%rsp), %rdx
leaq 0x4d8(%rsp), %rdi
callq 0x5e40
leaq 0x4a0(%rsp), %rdi
movl $0xc8, %esi
xorl %edx, %edx
movl $0x4, %ecx
callq 0x5d10
leaq 0x1038e(%rip), %rdi     # 0x15360
leaq 0x4a0(%rsp), %rsi
callq 0x5db0
movsd 0xa0a1(%rip), %xmm0     # 0xf088
movsd %xmm0, 0x498(%rsp)
movsd 0x498(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x438(%rsp)
movsd 0x498(%rsp), %xmm0
callq 0x3090
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x440(%rsp)
leaq 0x438(%rsp), %rax
movq %rax, 0x448(%rsp)
movq $0x2, 0x450(%rsp)
movsd 0x498(%rsp), %xmm0
callq 0x3090
movsd %xmm0, 0x428(%rsp)
movsd 0x498(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x430(%rsp)
leaq 0x428(%rsp), %rax
movq %rax, 0x458(%rsp)
movq $0x2, 0x460(%rsp)
leaq 0x448(%rsp), %rax
movq %rax, 0x468(%rsp)
movq $0x2, 0x470(%rsp)
movq 0x468(%rsp), %rsi
movq 0x470(%rsp), %rdx
leaq 0x478(%rsp), %rdi
callq 0x6440
leaq 0x410(%rsp), %rdi
xorl %esi, %esi
movl $0x12c, %edx            # imm = 0x12C
movl $0x3, %ecx
callq 0x5d10
leaq 0x1026c(%rip), %rdi     # 0x15360
leaq 0x410(%rsp), %rsi
callq 0x5db0
movsd 0x9f77(%rip), %xmm0     # 0xf080
movsd %xmm0, 0x408(%rsp)
movsd 0x408(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x3a8(%rsp)
movsd 0x408(%rsp), %xmm0
callq 0x3090
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x3b0(%rsp)
leaq 0x3a8(%rsp), %rax
movq %rax, 0x3b8(%rsp)
movq $0x2, 0x3c0(%rsp)
movsd 0x408(%rsp), %xmm0
callq 0x3090
movsd %xmm0, 0x398(%rsp)
movsd 0x408(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x3a0(%rsp)
leaq 0x398(%rsp), %rax
movq %rax, 0x3c8(%rsp)
movq $0x2, 0x3d0(%rsp)
leaq 0x3b8(%rsp), %rax
movq %rax, 0x3d8(%rsp)
movq $0x2, 0x3e0(%rsp)
movq 0x3d8(%rsp), %rsi
movq 0x3e0(%rsp), %rdx
leaq 0x3e8(%rsp), %rdi
callq 0x6440
leaq 0x380(%rsp), %rdi
movl $0xfffffe70, %esi       # imm = 0xFFFFFE70
xorl %edx, %edx
movl $0x2, %ecx
callq 0x5d10
leaq 0x1014a(%rip), %rdi     # 0x15360
leaq 0x380(%rsp), %rsi
callq 0x5db0
movsd 0x9e4d(%rip), %xmm0     # 0xf078
movsd %xmm0, 0x378(%rsp)
movsd 0x378(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x318(%rsp)
movsd 0x378(%rsp), %xmm0
callq 0x3090
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x320(%rsp)
leaq 0x318(%rsp), %rax
movq %rax, 0x328(%rsp)
movq $0x2, 0x330(%rsp)
movsd 0x378(%rsp), %xmm0
callq 0x3090
movsd %xmm0, 0x308(%rsp)
movsd 0x378(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x310(%rsp)
leaq 0x308(%rsp), %rax
movq %rax, 0x338(%rsp)
movq $0x2, 0x340(%rsp)
leaq 0x328(%rsp), %rax
movq %rax, 0x348(%rsp)
movq $0x2, 0x350(%rsp)
movq 0x348(%rsp), %rsi
movq 0x350(%rsp), %rdx
leaq 0x358(%rsp), %rdi
callq 0x6440
leaq 0x2f0(%rsp), %rdi
xorl %esi, %esi
movl $0xfffffe0c, %edx       # imm = 0xFFFFFE0C
movl $0x1, %ecx
callq 0x5d10
leaq 0x10028(%rip), %rdi     # 0x15360
leaq 0x2f0(%rsp), %rsi
callq 0x5db0
movsd 0x9d23(%rip), %xmm0     # 0xf070
movsd %xmm0, 0x2e8(%rsp)
movsd 0x2e8(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x288(%rsp)
movsd 0x2e8(%rsp), %xmm0
callq 0x3090
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x290(%rsp)
leaq 0x288(%rsp), %rax
movq %rax, 0x298(%rsp)
movq $0x2, 0x2a0(%rsp)
movsd 0x2e8(%rsp), %xmm0
callq 0x3090
movsd %xmm0, 0x278(%rsp)
movsd 0x2e8(%rsp), %xmm0
callq 0x35f0
movsd %xmm0, 0x280(%rsp)
leaq 0x278(%rsp), %rax
movq %rax, 0x2a8(%rsp)
movq $0x2, 0x2b0(%rsp)
leaq 0x298(%rsp), %rax
movq %rax, 0x2b8(%rsp)
movq $0x2, 0x2c0(%rsp)
movq 0x2b8(%rsp), %rsi
movq 0x2c0(%rsp), %rdx
leaq 0x2c8(%rsp), %rdi
callq 0x6440
movl $0x0, 0x274(%rsp)
cmpl $0x640, 0x274(%rsp) # imm = 0x640
jge 0x5a72
movl 0x274(%rsp), %esi
leaq 0x250(%rsp), %rdi
callq 0x65f0
leaq 0x250(%rsp), %rdi
callq 0x3480
cmpq $0x4, %rax
je 0x5580
leaq 0x250(%rsp), %rdi
callq 0x3480
movq %rax, %rcx
movl $0x4, %eax
subq %rcx, %rax
movq %rax, 0xa0(%rsp)
leaq 0x20f(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x35b0
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rcx
leaq 0x210(%rsp), %rdi
movl $0x30, %edx
callq 0x6780
jmp 0x54da
leaq 0x230(%rsp), %rdi
leaq 0x210(%rsp), %rsi
leaq 0x250(%rsp), %rdx
callq 0x6730
jmp 0x54f9
leaq 0x250(%rsp), %rdi
leaq 0x230(%rsp), %rsi
callq 0x33d0
leaq 0x230(%rsp), %rdi
callq 0x3200
leaq 0x210(%rsp), %rdi
callq 0x3200
leaq 0x20f(%rsp), %rdi
callq 0x3360
jmp 0x5580
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x556e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x210(%rsp), %rdi
callq 0x3200
leaq 0x20f(%rsp), %rdi
callq 0x3360
jmp 0x5a63
movups 0x4a0(%rsp), %xmm0
movaps %xmm0, 0x1d0(%rsp)
movsd 0x1d0(%rsp), %xmm0
movsd 0x1d8(%rsp), %xmm1
leaq 0x478(%rsp), %rdi
callq 0x6800
movsd %xmm1, 0x90(%rsp)
movsd %xmm0, 0x98(%rsp)
jmp 0x55c3
movsd 0x90(%rsp), %xmm0
movsd 0x98(%rsp), %xmm1
movsd %xmm1, 0x1e8(%rsp)
movsd %xmm0, 0x1f0(%rsp)
movups 0x1e8(%rsp), %xmm0
movaps %xmm0, 0x4a0(%rsp)
movups 0x4d8(%rsp), %xmm0
movaps %xmm0, 0x1b0(%rsp)
movsd 0x1b0(%rsp), %xmm0
movsd 0x1b8(%rsp), %xmm1
leaq 0x4a0(%rsp), %rdi
callq 0x68f0
movsd %xmm1, 0x80(%rsp)
movsd %xmm0, 0x88(%rsp)
jmp 0x563a
movsd 0x80(%rsp), %xmm0
movsd 0x88(%rsp), %xmm1
movsd %xmm1, 0x1c0(%rsp)
movsd %xmm0, 0x1c8(%rsp)
leaq 0xfcfb(%rip), %rdi      # 0x15360
xorl %eax, %eax
movl %eax, %esi
callq 0x5f30
movups 0x1c0(%rsp), %xmm0
movups %xmm0, (%rax)
movups 0x410(%rsp), %xmm0
movaps %xmm0, 0x190(%rsp)
movsd 0x190(%rsp), %xmm0
movsd 0x198(%rsp), %xmm1
leaq 0x3e8(%rsp), %rdi
callq 0x6800
movsd %xmm1, 0x70(%rsp)
movsd %xmm0, 0x78(%rsp)
jmp 0x56b6
movsd 0x70(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
movsd %xmm1, 0x1a0(%rsp)
movsd %xmm0, 0x1a8(%rsp)
movups 0x1a0(%rsp), %xmm0
movaps %xmm0, 0x410(%rsp)
movups 0x4d8(%rsp), %xmm0
movaps %xmm0, 0x170(%rsp)
movsd 0x170(%rsp), %xmm0
movsd 0x178(%rsp), %xmm1
leaq 0x410(%rsp), %rdi
callq 0x68f0
movsd %xmm1, 0x60(%rsp)
movsd %xmm0, 0x68(%rsp)
jmp 0x5721
movsd 0x60(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
movsd %xmm1, 0x180(%rsp)
movsd %xmm0, 0x188(%rsp)
leaq 0xfc1a(%rip), %rdi      # 0x15360
movl $0x1, %esi
callq 0x5f30
movups 0x180(%rsp), %xmm0
movups %xmm0, (%rax)
movups 0x380(%rsp), %xmm0
movaps %xmm0, 0x150(%rsp)
movsd 0x150(%rsp), %xmm0
movsd 0x158(%rsp), %xmm1
leaq 0x358(%rsp), %rdi
callq 0x6800
movsd %xmm1, 0x50(%rsp)
movsd %xmm0, 0x58(%rsp)
jmp 0x5798
movsd 0x50(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd %xmm1, 0x160(%rsp)
movsd %xmm0, 0x168(%rsp)
movups 0x160(%rsp), %xmm0
movaps %xmm0, 0x380(%rsp)
movups 0x4d8(%rsp), %xmm0
movaps %xmm0, 0x130(%rsp)
movsd 0x130(%rsp), %xmm0
movsd 0x138(%rsp), %xmm1
leaq 0x380(%rsp), %rdi
callq 0x68f0
movsd %xmm1, 0x40(%rsp)
movsd %xmm0, 0x48(%rsp)
jmp 0x5803
movsd 0x40(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd %xmm1, 0x140(%rsp)
movsd %xmm0, 0x148(%rsp)
leaq 0xfb38(%rip), %rdi      # 0x15360
movl $0x2, %esi
callq 0x5f30
movups 0x140(%rsp), %xmm0
movups %xmm0, (%rax)
movups 0x2f0(%rsp), %xmm0
movaps %xmm0, 0x110(%rsp)
movsd 0x110(%rsp), %xmm0
movsd 0x118(%rsp), %xmm1
leaq 0x2c8(%rsp), %rdi
callq 0x6800
movsd %xmm1, 0x30(%rsp)
movsd %xmm0, 0x38(%rsp)
jmp 0x587a
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd %xmm1, 0x120(%rsp)
movsd %xmm0, 0x128(%rsp)
movups 0x120(%rsp), %xmm0
movaps %xmm0, 0x2f0(%rsp)
movups 0x4d8(%rsp), %xmm0
movaps %xmm0, 0xf0(%rsp)
movsd 0xf0(%rsp), %xmm0
movsd 0xf8(%rsp), %xmm1
leaq 0x2f0(%rsp), %rdi
callq 0x68f0
movsd %xmm1, 0x20(%rsp)
movsd %xmm0, 0x28(%rsp)
jmp 0x58e5
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd %xmm1, 0x100(%rsp)
movsd %xmm0, 0x108(%rsp)
leaq 0xfa56(%rip), %rdi      # 0x15360
movl $0x3, %esi
callq 0x5f30
movups 0x100(%rsp), %xmm0
movups %xmm0, (%rax)
leaq 0x9782(%rip), %rsi      # 0xf0a8
leaq 0xb0(%rsp), %rdi
leaq 0x250(%rsp), %rdx
callq 0x69d0
jmp 0x593d
leaq 0x9794(%rip), %rdx      # 0xf0d8
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x6980
jmp 0x595b
leaq 0xd0(%rsp), %rdi
movl $0x1, %esi
callq 0x3f40
jmp 0x596f
leaq 0xd0(%rsp), %rdi
callq 0x3200
leaq 0xb0(%rsp), %rdi
callq 0x3200
movq 0xf640(%rip), %rdi      # 0x14fd0
leaq 0x9719(%rip), %rsi      # 0xf0b0
callq 0x3310
movq %rax, 0x18(%rsp)
jmp 0x59a3
movq 0x18(%rsp), %rdi
movl 0x274(%rsp), %esi
callq 0x3560
movq %rax, 0x10(%rsp)
jmp 0x59bb
movq 0x10(%rsp), %rdi
leaq 0x96e7(%rip), %rsi      # 0xf0ae
callq 0x3310
movq %rax, 0x8(%rsp)
jmp 0x59d3
movq 0x8(%rsp), %rdi
leaq 0x96eb(%rip), %rsi      # 0xf0ca
callq 0x3310
jmp 0x59e6
leaq 0x250(%rsp), %rdi
callq 0x3200
movl 0x274(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x274(%rsp)
jmp 0x5445
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x5a63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x5a56
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x3200
leaq 0xb0(%rsp), %rdi
callq 0x3200
leaq 0x250(%rsp), %rdi
callq 0x3200
jmp 0x5a7a
addq $0x4e8, %rsp            # imm = 0x4E8
retq
movq 0x200(%rsp), %rdi
callq 0x3590
nopw (%rax,%rax)