// File: /workspace/github_cpp_makefile_star2_O1/soybin[P]idyll/src/fractal.cpp
// Function: fractal::fractal(seed*)
fractal::fractal(seed* s) : s(s) {

	//
	// get number of fractal iterations
	//
	iterations = s->values["iterations"];

	//
	// determine shadow softness of the fractal
	//
	shadowSoftness = s->values["shadowSoftness"];

	//
	// get fractal color
	//
	color.x = s->values["xcolor"];
	color.y = s->values["ycolor"];
	color.z = s->values["zcolor"];

	//
	// get top sky gradient color
	// 
	gradientTop.x = s->values["xgradientTop"];
	gradientTop.y = s->values["ygradientTop"];
	gradientTop.z = s->values["zgradientTop"];

	//
	// get bottom sky gradient color
	//
	gradientBottom.x = s->values["xgradientBottom"];
	gradientBottom.y = s->values["ygradientBottom"];
	gradientBottom.z = s->values["zgradientBottom"];

	//
	// randomly change gradient color positions
	//
	if (s->i(0, 1)) {
		math::vec3 temp = gradientTop;
		gradientTop = gradientBottom;
		gradientBottom = temp;
	}

	//
	// determine fractal shift variation vector per iteration
	//
	xs = s->values["xshift"];
	zs = s->values["zshift"];
	
	//
	// determine fractal rotation per iteration
	//
	xr = s->values["xrotation"];
	zr = s->values["zrotation"];

	//
	// precompute sine and cosine of rotation angles
	//
	xrs = std::sin(xr);
	xrc = std::cos(xr);
	zrs = std::sin(zr);
	zrc = std::cos(zr);
	
	//
	// initialize point iterator
	//
	switch ((int)s->values["pointIterator"]) {
		case 0:
			mainPI = new PI0(xs, zs, xrs, xrc, zrs, zrc);
			break;
		case 1:
			mainPI = new PI1(xs, zs, xrs, xrc, zrs, zrc);
			break;
		case 2:
			mainPI = new PI2(xs, zs, xrs, xrc, zrs, zrc);
			break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x50(%rdi), %r13
movq %r13, %rdi
callq 0x61a4
movq %r14, 0x68(%rbx)
leaq 0x78(%rbx), %r15
movq %r15, %rdi
callq 0x61a4
leaq 0x90(%rbx), %rdi
movq %rdi, -0x58(%rbp)
callq 0x61a4
leaq -0x40(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x6285(%rip), %rsi      # 0xea10
leaq 0x6288(%rip), %rdx      # 0xea1a
leaq -0x50(%rbp), %rdi
callq 0x5342
movq %r14, -0x60(%rbp)
addq $0x2718, %r14           # imm = 0x2718
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
cvttsd2si (%rax), %eax
movl %eax, (%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x87cd
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x6240(%rip), %rsi      # 0xea1b
leaq 0x6247(%rip), %rdx      # 0xea29
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8811
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x620b(%rip), %rsi      # 0xea2a
leaq 0x620a(%rip), %rdx      # 0xea30
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movsd %xmm0, (%r13)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8856
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x61cd(%rip), %rsi      # 0xea31
leaq 0x61cc(%rip), %rdx      # 0xea37
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movsd %xmm0, 0x58(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x889a
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x6190(%rip), %rsi      # 0xea38
leaq 0x618f(%rip), %rdx      # 0xea3e
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x88de
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x6153(%rip), %rsi      # 0xea3f
leaq 0x6158(%rip), %rdx      # 0xea4b
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movsd %xmm0, (%r15)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8922
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x611c(%rip), %rsi      # 0xea4c
leaq 0x6121(%rip), %rdx      # 0xea58
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movsd %xmm0, 0x80(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8969
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x60e2(%rip), %rsi      # 0xea59
leaq 0x60e7(%rip), %rdx      # 0xea65
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movsd %xmm0, 0x88(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x89b0
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x60a8(%rip), %rsi      # 0xea66
leaq 0x60b0(%rip), %rdx      # 0xea75
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x89f7
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x6071(%rip), %rsi      # 0xea76
leaq 0x6079(%rip), %rdx      # 0xea85
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movsd %xmm0, 0x98(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8a3e
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x603a(%rip), %rsi      # 0xea86
leaq 0x6042(%rip), %rdx      # 0xea95
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movsd %xmm0, 0xa0(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8a85
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
movq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0xa5cc
testl %eax, %eax
je 0x8ac8
movq 0x10(%r15), %rax
leaq -0x50(%rbp), %r13
movq %rax, 0x10(%r13)
movups (%r15), %xmm0
movaps %xmm0, (%r13)
movq %r15, %rdi
movq -0x58(%rbp), %r15
movq %r15, %rsi
callq 0x6310
movq %r15, %rdi
movq %r13, %rsi
callq 0x6310
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x5fc0(%rip), %rsi      # 0xea96
leaq 0x5fbf(%rip), %rdx      # 0xea9c
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8b0c
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x5f83(%rip), %rsi      # 0xea9d
leaq 0x5f82(%rip), %rdx      # 0xeaa3
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8b50
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x5f46(%rip), %rsi      # 0xeaa4
leaq 0x5f48(%rip), %rdx      # 0xeaad
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8b94
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x5f0c(%rip), %rsi      # 0xeaae
leaq 0x5f0e(%rip), %rdx      # 0xeab7
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8bd8
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
movsd 0x18(%rbx), %xmm0
callq 0x3080
movsd %xmm0, 0x28(%rbx)
movsd 0x18(%rbx), %xmm0
callq 0x34e0
movsd %xmm0, 0x30(%rbx)
movsd 0x20(%rbx), %xmm0
callq 0x3080
movsd %xmm0, 0x38(%rbx)
movsd 0x20(%rbx), %xmm0
callq 0x34e0
movsd %xmm0, 0x40(%rbx)
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x5e96(%rip), %rsi      # 0xeab8
leaq 0x5e9c(%rip), %rdx      # 0xeac5
callq 0x5342
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x81c8
cvttsd2si (%rax), %r14d
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8c54
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
cmpl $0x3, %r14d
jae 0x8c91
movl %r14d, %eax
leaq 0xa0e4(%rip), %rcx      # 0x12d48
movq (%rcx,%rax,8), %r14
movl $0x38, %edi
callq 0x32c0
movups 0x8(%rbx), %xmm0
movups 0x28(%rbx), %xmm1
movups 0x38(%rbx), %xmm2
movups %xmm0, 0x8(%rax)
movups %xmm1, 0x18(%rax)
movups %xmm2, 0x28(%rax)
movq %r14, (%rax)
movq %rax, 0x70(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
jmp 0x8cdc
jmp 0x8cf6
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8cf9
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
jmp 0x8cf9
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3490
nop