// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
movsd 0x10(%rsi), %xmm0
movsd 0x18(%rsi), %xmm1
movsd %xmm1, (%rsp)
movsd 0x20(%rsi), %xmm1
movsd %xmm1, 0x38(%rsp)
movups 0x28(%rsi), %xmm1
movaps %xmm1, 0x90(%rsp)
movsd 0x38(%rsi), %xmm1
movsd %xmm1, 0x30(%rsp)
movups (%rsi), %xmm1
leaq 0x40(%rsp), %rsi
movaps %xmm1, (%rsi)
movsd %xmm0, 0x10(%rsi)
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x5304
movq 0x10(%r14), %rax
leaq 0x60(%rsp), %r15
movq %rax, 0x10(%r15)
movups (%r14), %xmm0
movaps %xmm0, (%r15)
leaq 0xc(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x127ec
movslq (%r14), %rsi
movq %r15, %rdi
callq 0xa8e8
movsd (%rax), %xmm0
ucomisd 0x688c(%rip), %xmm0     # 0x18a30
movl (%r14), %eax
jne 0x121b9
jp 0x121b9
incl %eax
pushq $0x3
popq %rcx
cltd
idivl %ecx
movl %edx, %eax
movl %edx, 0xc(%rsp)
movslq %eax, %rsi
leaq 0x60(%rsp), %r15
movq %r15, %rdi
callq 0xa8e8
movabsq $0x3ff0000000000000, %rbp # imm = 0x3FF0000000000000
movq %rbp, (%rax)
leaq 0x68(%rsp), %r14
movsd -0x8(%r14), %xmm0
movsd 0x10(%rsp), %xmm1
movupd 0x18(%rsp), %xmm2
movupd (%r14), %xmm3
movapd %xmm2, %xmm4
shufpd $0x1, %xmm1, %xmm4      # xmm4 = xmm4[1],xmm1[0]
mulpd %xmm3, %xmm4
mulsd %xmm3, %xmm1
shufpd $0x1, %xmm0, %xmm3      # xmm3 = xmm3[1],xmm0[0]
mulpd %xmm2, %xmm3
subpd %xmm4, %xmm3
mulsd %xmm2, %xmm0
subsd %xmm0, %xmm1
leaq 0xa0(%rsp), %r12
movapd %xmm3, (%r12)
movsd %xmm1, 0x10(%r12)
leaq 0x40(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x5304
movq %r15, %rdi
movq %r13, %rsi
callq 0x5806
movsd -0x8(%r14), %xmm0
movsd 0x10(%rsp), %xmm1
movupd 0x18(%rsp), %xmm2
movupd (%r14), %xmm3
movapd %xmm2, %xmm4
shufpd $0x1, %xmm1, %xmm4      # xmm4 = xmm4[1],xmm1[0]
mulpd %xmm3, %xmm4
mulsd %xmm3, %xmm1
shufpd $0x1, %xmm0, %xmm3      # xmm3 = xmm3[1],xmm0[0]
mulpd %xmm2, %xmm3
subpd %xmm4, %xmm3
mulsd %xmm2, %xmm0
subsd %xmm0, %xmm1
movapd %xmm3, (%r12)
movsd %xmm1, 0x10(%r12)
leaq 0x40(%rsp), %r15
leaq 0xa0(%rsp), %rsi
movq %r15, %rdi
callq 0x5304
leaq 0x78(%rsp), %rdi
movq %r15, %rsi
callq 0x5806
leaq 0x50(%rbx), %rax
movq %rax, (%r15)
andq $0x0, 0x8(%r15)
pushq $0x1
popq %rax
movq %rax, 0x10(%r15)
movq %rax, 0x18(%r15)
movsd -0x8(%r14), %xmm0
movsd %xmm0, 0x50(%rbx)
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
callq 0x12814
leaq 0x70(%rsp), %rsi
movq %rax, %rdi
callq 0x12814
leaq 0xa0(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x12814
leaq 0x78(%rsp), %rsi
movq %rax, %rdi
callq 0x12814
leaq 0x80(%rsp), %rsi
movq %rax, %rdi
callq 0x12814
leaq 0x88(%rsp), %rsi
movq %rax, %rdi
callq 0x12814
leaq 0xe0(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x12814
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x12814
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x12814
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x12814
leaq 0xd8(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x12814
leaq 0xd0(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x12814
leaq 0xc8(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x12814
leaq 0xc0(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x12814
leaq 0xb8(%rsp), %rsi
movq %rbp, (%rsi)
movq %rax, %rdi
callq 0x12814
leaq 0x40(%rsp), %rdi
callq 0x128bc
movsd (%rsp), %xmm0
mulsd 0x8dca(%rip), %xmm0     # 0x1b1b0
divsd 0x8dca(%rip), %xmm0     # 0x1b1b8
movsd %xmm0, (%rsp)
callq 0x34c0
movsd %xmm0, 0x28(%rsp)
movsd (%rsp), %xmm0
callq 0x3090
movsd 0x28(%rsp), %xmm1
movsd %xmm1, 0xd0(%rbx)
movsd %xmm1, 0xf8(%rbx)
movaps 0x661b(%rip), %xmm1     # 0x18a40
xorps %xmm0, %xmm1
movlps %xmm1, 0xf0(%rbx)
movsd %xmm0, 0xd8(%rbx)
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x150(%rbx)
movsd %xmm0, 0x178(%rbx)
movsd %xmm0, 0x1a0(%rbx)
movaps 0x90(%rsp), %xmm0
movaps %xmm0, 0x230(%rbx)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x240(%rbx)
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x12492
jmp 0x12492
jmp 0x12492
jmp 0x12492
jmp 0x12492
jmp 0x12492
jmp 0x12492
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x128bc
movq %rbx, %rdi
callq 0x3490
nop