// File: /workspace/github_cpp_makefile_star2_O3/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 0x61cc
movq %r14, 0x68(%rbx)
leaq 0x78(%rbx), %r15
movq %r15, %rdi
callq 0x61cc
leaq 0x90(%rbx), %rdi
movq %rdi, -0x58(%rbp)
callq 0x61cc
leaq -0x40(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x6425(%rip), %rsi      # 0xea08
leaq 0x6428(%rip), %rdx      # 0xea12
leaq -0x50(%rbp), %rdi
callq 0x5366
movq %r14, -0x60(%rbp)
addq $0x2718, %r14           # imm = 0x2718
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
cvttsd2si (%rax), %eax
movl %eax, (%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8625
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x63e0(%rip), %rsi      # 0xea13
leaq 0x63e7(%rip), %rdx      # 0xea21
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8669
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x63ab(%rip), %rsi      # 0xea22
leaq 0x63aa(%rip), %rdx      # 0xea28
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movsd %xmm0, (%r13)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x86ae
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x636d(%rip), %rsi      # 0xea29
leaq 0x636c(%rip), %rdx      # 0xea2f
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movsd %xmm0, 0x58(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x86f2
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x6330(%rip), %rsi      # 0xea30
leaq 0x632f(%rip), %rdx      # 0xea36
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8736
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x62f3(%rip), %rsi      # 0xea37
leaq 0x62f8(%rip), %rdx      # 0xea43
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movsd %xmm0, (%r15)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x877a
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x62bc(%rip), %rsi      # 0xea44
leaq 0x62c1(%rip), %rdx      # 0xea50
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movsd %xmm0, 0x80(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x87c1
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x6282(%rip), %rsi      # 0xea51
leaq 0x6287(%rip), %rdx      # 0xea5d
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movsd %xmm0, 0x88(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8808
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x6248(%rip), %rsi      # 0xea5e
leaq 0x6250(%rip), %rdx      # 0xea6d
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x884f
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x6211(%rip), %rsi      # 0xea6e
leaq 0x6219(%rip), %rdx      # 0xea7d
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movsd %xmm0, 0x98(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8896
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x61da(%rip), %rsi      # 0xea7e
leaq 0x61e2(%rip), %rdx      # 0xea8d
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movsd %xmm0, 0xa0(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x88dd
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
movq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0xa400
testl %eax, %eax
je 0x8920
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 0x6338
movq %r15, %rdi
movq %r13, %rsi
callq 0x6338
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x6160(%rip), %rsi      # 0xea8e
leaq 0x615f(%rip), %rdx      # 0xea94
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8964
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x6123(%rip), %rsi      # 0xea95
leaq 0x6122(%rip), %rdx      # 0xea9b
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x89a8
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x60e6(%rip), %rsi      # 0xea9c
leaq 0x60e8(%rip), %rdx      # 0xeaa5
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x89ec
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
leaq -0x50(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x60ac(%rip), %rsi      # 0xeaa6
leaq 0x60ae(%rip), %rdx      # 0xeaaf
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rbx)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8a30
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 0x6036(%rip), %rsi      # 0xeab0
leaq 0x603c(%rip), %rdx      # 0xeabd
callq 0x5366
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x8024
cvttsd2si (%rax), %r14d
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8aac
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
cmpl $0x3, %r14d
jae 0x8ae9
movl %r14d, %eax
leaq 0xa284(%rip), %rcx      # 0x12d40
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 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
jmp 0x8b34
jmp 0x8b4e
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8b51
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32d0
jmp 0x8b51
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3490
nop