// File: /workspace/github_cpp_makefile_star2_O3/IsaacLaw12[P]RayTracer/./src/Transformation.cpp
// Function: Transformation::create_transform_matrix(double*)
void Transformation::create_transform_matrix(double transform_string[]){
    double rot_trans_x = transform_string[0];
    double rot_trans_y = transform_string[1];
    double rot_trans_z = transform_string[2];
    double deg_angle   = transform_string[3];
    double scale       = transform_string[4];
    double translate_x = transform_string[5];
    double translate_y = transform_string[6];
    double translate_z = transform_string[7];

    // Populate rotation matrices
    Eigen::Vector3d Wv = Eigen::Vector3d(rot_trans_x, rot_trans_y, rot_trans_z).normalized();
    Eigen::Vector3d Uv = Eigen::Vector3d(Wv);
    Eigen::Vector3d Vv;

    // Make sure Uv is not parallel to Wv
    int minindex;
    Uv.minCoeff(&minindex);
    if (Uv(minindex) == -1)
        // (-1 0 0) is a special case because it would change to (1 0 0)
        //     which is parallel
        minindex = (minindex + 1) % 3;
    Uv(minindex) = 1.0;

    Uv = Wv.cross(Uv).normalized();
    Vv = Wv.cross(Uv).normalized();

    normalize_z_rotate << Uv[0], Uv[1], Uv[2], 0,
                          Vv[0], Vv[1], Vv[2], 0,
                          Wv[0], Wv[1], Wv[2], 0,
                          0,     0,     0,     1;

    double rad_angle = (deg_angle * M_PI) / 180;
    double cos_angle = cos(rad_angle);
    double sin_angle = sin(rad_angle);
    rotate_matrix(0,0) = cos_angle;
    rotate_matrix(1,1) = cos_angle;
    rotate_matrix(0,1) = -sin_angle;
    rotate_matrix(1,0) = sin_angle;

    // Populate scale matrix
    scale_matrix(0,0) = scale;
    scale_matrix(1,1) = scale;
    scale_matrix(2,2) = scale;

    // Populate translate matrix
    translate_matrix(0,3) = translate_x;
    translate_matrix(1,3) = translate_y;
    translate_matrix(2,3) = translate_z;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
movsd (%rsi), %xmm1
movupd 0x8(%rsi), %xmm0
movapd %xmm1, %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
movapd %xmm2, %xmm3
mulpd %xmm2, %xmm3
movapd %xmm3, %xmm5
unpckhpd %xmm3, %xmm5            # xmm5 = xmm5[1],xmm3[1]
addsd %xmm3, %xmm5
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
movapd %xmm3, %xmm4
mulsd %xmm3, %xmm4
addsd %xmm5, %xmm4
xorpd %xmm5, %xmm5
ucomisd %xmm5, %xmm4
jbe 0x1113d
movq %xmm4, %xmm0            # xmm0 = xmm4[0],zero
sqrtpd %xmm0, %xmm0
divsd %xmm0, %xmm3
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm2
movapd %xmm2, 0x30(%rsp)
movapd %xmm2, %xmm0
shufpd $0x1, %xmm3, %xmm0      # xmm0 = xmm0[1],xmm3[0]
movapd %xmm2, %xmm1
jmp 0x11143
movapd %xmm2, 0x30(%rsp)
movsd 0x18(%rsi), %xmm2
movsd %xmm2, 0x8(%rsp)
movsd 0x20(%rsi), %xmm10
movups 0x28(%rsi), %xmm11
movsd 0x38(%rsi), %xmm12
movhpd %xmm0, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x20(%rsp)
movaps 0x30(%rsp), %xmm2
movaps %xmm2, 0x10(%rsp)
movsd 0x10(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
xorl %eax, %eax
ucomisd %xmm3, %xmm2
seta %al
minsd %xmm2, %xmm3
ucomisd 0x20(%rsp), %xmm3
movl $0x2, %ecx
cmovbel %eax, %ecx
leal 0x1(%rcx), %edx
leal -0x2(%rcx), %eax
cmpl $0x3, %edx
cmovbl %edx, %eax
movl %ecx, %edx
movsd 0x10(%rsp,%rdx,8), %xmm2
ucomisd 0x5cfc(%rip), %xmm2     # 0x16eb8
cmovnel %ecx, %eax
cmovpl %ecx, %eax
cmpl $0x3, %eax
jae 0x11519
movapd %xmm0, %xmm4
unpckhpd %xmm0, %xmm4            # xmm4 = xmm4[1],xmm0[1]
movl %eax, %eax
movabsq $0x3ff0000000000000, %r14 # imm = 0x3FF0000000000000
movq %r14, 0x10(%rsp,%rax,8)
movapd %xmm0, %xmm5
shufpd $0x1, %xmm1, %xmm5      # xmm5 = xmm5[1],xmm1[0]
movapd 0x5d1b(%rip), %xmm3     # 0x16f10
movsd 0x10(%rsp), %xmm7
movupd 0x18(%rsp), %xmm2
movapd %xmm2, %xmm8
mulpd %xmm5, %xmm8
xorpd %xmm3, %xmm5
movapd %xmm1, %xmm6
mulsd %xmm2, %xmm6
shufpd $0x1, %xmm7, %xmm2      # xmm2 = xmm2[1],xmm7[0]
mulpd %xmm0, %xmm2
subpd %xmm8, %xmm2
xorpd %xmm0, %xmm3
mulsd %xmm0, %xmm7
subsd %xmm7, %xmm6
movapd %xmm2, %xmm7
mulpd %xmm2, %xmm7
movapd %xmm7, %xmm9
unpckhpd %xmm7, %xmm9            # xmm9 = xmm9[1],xmm7[1]
addsd %xmm7, %xmm9
movapd %xmm6, %xmm8
mulsd %xmm6, %xmm8
addsd %xmm9, %xmm8
xorpd %xmm7, %xmm7
ucomisd %xmm7, %xmm8
jbe 0x1127b
movq %xmm8, %xmm8            # xmm8 = xmm8[0],zero
sqrtpd %xmm8, %xmm8
divsd %xmm8, %xmm6
unpcklpd %xmm8, %xmm8            # xmm8 = xmm8[0,0]
divpd %xmm8, %xmm2
leaq 0x18(%rsp), %rsi
movapd %xmm2, -0x8(%rsi)
movsd %xmm6, 0x8(%rsi)
movapd %xmm2, %xmm8
unpckhpd %xmm2, %xmm8            # xmm8 = xmm8[1],xmm2[1]
mulsd %xmm8, %xmm1
mulsd %xmm5, %xmm8
mulsd %xmm6, %xmm0
addsd %xmm8, %xmm0
unpckhpd %xmm5, %xmm5            # xmm5 = xmm5[1,1]
mulsd %xmm6, %xmm5
mulsd %xmm2, %xmm4
addsd %xmm5, %xmm4
unpcklpd %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0]
mulsd %xmm2, %xmm3
addsd %xmm1, %xmm3
movapd %xmm0, %xmm1
mulpd %xmm0, %xmm1
movapd %xmm1, %xmm4
unpckhpd %xmm1, %xmm4            # xmm4 = xmm4[1],xmm1[1]
addsd %xmm1, %xmm4
movapd %xmm3, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm4, %xmm1
ucomisd %xmm7, %xmm1
movsd %xmm10, 0x58(%rsp)
movaps %xmm11, 0xa0(%rsp)
movsd %xmm12, 0x50(%rsp)
jbe 0x11314
movq %xmm1, %xmm1            # xmm1 = xmm1[0],zero
sqrtpd %xmm1, %xmm1
divsd %xmm1, %xmm3
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
divpd %xmm1, %xmm0
movapd %xmm0, 0x80(%rsp)
movsd %xmm3, 0x90(%rsp)
leaq 0x50(%rbx), %rax
leaq 0x60(%rsp), %rdi
movq %rax, (%rdi)
movq $0x0, 0x8(%rdi)
movl $0x1, %eax
movq %rax, 0x10(%rdi)
movq %rax, 0x18(%rdi)
movsd %xmm2, 0x50(%rbx)
callq 0x11c16
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x11c16
leaq 0xe0(%rsp), %rsi
movq $0x0, (%rsi)
movq %rax, %rdi
callq 0x11c16
leaq 0x80(%rsp), %rsi
movq %rax, %rdi
callq 0x11c16
leaq 0x88(%rsp), %rsi
movq %rax, %rdi
callq 0x11c16
leaq 0x90(%rsp), %rsi
movq %rax, %rdi
callq 0x11c16
leaq 0xd8(%rsp), %rsi
movq $0x0, (%rsi)
movq %rax, %rdi
callq 0x11c16
leaq 0x30(%rsp), %rsi
movq %rax, %rdi
callq 0x11c16
leaq 0x38(%rsp), %rsi
movq %rax, %rdi
callq 0x11c16
leaq 0x40(%rsp), %rsi
movq %rax, %rdi
callq 0x11c16
leaq 0xd0(%rsp), %rsi
movq $0x0, (%rsi)
movq %rax, %rdi
callq 0x11c16
leaq 0xc8(%rsp), %rsi
movq $0x0, (%rsi)
movq %rax, %rdi
callq 0x11c16
leaq 0xc0(%rsp), %rsi
movq $0x0, (%rsi)
movq %rax, %rdi
callq 0x11c16
leaq 0xb8(%rsp), %rsi
movq $0x0, (%rsi)
movq %rax, %rdi
callq 0x11c16
leaq 0xb0(%rsp), %rsi
movq %r14, (%rsi)
movq %rax, %rdi
callq 0x11c16
movq 0x78(%rsp), %rax
addq 0x68(%rsp), %rax
cmpq $0x4, %rax
jne 0x11566
cmpq $0x4, 0x70(%rsp)
jne 0x11566
movsd 0x8(%rsp), %xmm0
mulsd 0x6a68(%rip), %xmm0     # 0x17ee8
divsd 0x6a68(%rip), %xmm0     # 0x17ef0
movsd %xmm0, 0x8(%rsp)
callq 0x34f0
movsd %xmm0, 0x48(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x3090
movsd 0x48(%rsp), %xmm1
movsd %xmm1, 0xd0(%rbx)
movsd %xmm1, 0xf8(%rbx)
movaps 0x5a4f(%rip), %xmm1     # 0x16f10
xorps %xmm0, %xmm1
movlps %xmm1, 0xf0(%rbx)
movsd %xmm0, 0xd8(%rbx)
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x150(%rbx)
movsd %xmm0, 0x178(%rbx)
movsd %xmm0, 0x1a0(%rbx)
movaps 0xa0(%rsp), %xmm0
movaps %xmm0, 0x230(%rbx)
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x240(%rbx)
addq $0xe8, %rsp
popq %rbx
popq %r14
retq
leaq 0x6a7f(%rip), %rdi      # 0x17f9f
leaq 0x4fa1(%rip), %rsi      # 0x164c8
leaq 0x6a8e(%rip), %rcx      # 0x17fbc
movl $0x1a9, %edx            # imm = 0x1A9
callq 0x31a0
jmp 0x11546
jmp 0x11546
jmp 0x11546
jmp 0x11546
jmp 0x11546
jmp 0x11546
jmp 0x11546
movq 0x78(%rsp), %rcx
addq 0x68(%rsp), %rcx
cmpq $0x4, %rcx
jne 0x11566
cmpq $0x4, 0x70(%rsp)
jne 0x11566
movq %rax, %rdi
callq 0x34b0
leaq 0x53db(%rip), %rdi      # 0x16948
leaq 0x5472(%rip), %rsi      # 0x169e6
leaq 0x6ac6(%rip), %rcx      # 0x18041
movl $0x78, %edx
callq 0x31a0
nop