// File: /workspace/github_cpp_makefile_star2_O1/alan0201tw[P]RayTracer/src/transform.cpp
// Function: rotate_y::rotate_y(std::shared_ptr<hitable>, float)
rotate_y::rotate_y(std::shared_ptr<hitable> _target, float _angle)
    : target(_target)
{
    float angle_in_radians = DEGREE_TO_RADIAN_COEF_F * _angle;
    sin_theta = std::sin(angle_in_radians);
    cos_theta = std::cos(angle_in_radians);
    isBoundedByBox = target->bounding_box(0.0f, 1.0f, target_aabb);


    vec3 minimal(FLOAT_MAX, FLOAT_MAX, FLOAT_MAX);
    vec3 maximal(-FLOAT_MAX, -FLOAT_MAX, -FLOAT_MAX);

    for(int i = 0; i < 2; i++)
    {
        for(int j = 0; j < 2; j++)
        {
            for(int k = 0; k < 2; k++)
            {
                float x = i * target_aabb.get_max().x()
                    + (1 - i) * target_aabb.get_min().x();
                float y = j * target_aabb.get_max().y()     
                    + (1 - j) * target_aabb.get_min().y();
                float z = k * target_aabb.get_max().z()
                    + (1 - k) * target_aabb.get_min().z();

                float new_x = cos_theta * x + sin_theta * z;
                float new_z = -sin_theta * x + cos_theta * z;
                vec3 tester(new_x, y, new_z);
                for(int c = 0; c < 3; c++)
                {
                    if(tester[c] > maximal[c])
                        maximal[c] = tester[c];
                    if(tester[c] < minimal[c])
                        minimal[c] = tester[c];
                }
            }
        }
    }
    target_aabb = aabb(minimal, maximal);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r14
leaq 0x2ab87(%rip), %rax     # 0x4e958
movq %rax, (%rdi)
movq (%rsi), %rax
movq %rax, 0x8(%rdi)
movq 0x8(%rsi), %rax
movq %rax, 0x10(%rdi)
testq %rax, %rax
je 0x23dfd
movq 0x2b1b1(%rip), %rcx     # 0x4efa0
cmpb $0x0, (%rcx)
je 0x23df9
incl 0x8(%rax)
jmp 0x23dfd
lock
incl 0x8(%rax)
leaq 0x24(%r14), %rbx
cvtss2sd %xmm0, %xmm0
mulsd 0x19403(%rip), %xmm0    # 0x3d210
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x1c(%rsp)
callq 0x6340
movss %xmm0, 0x18(%r14)
movss 0x1c(%rsp), %xmm0
callq 0x62f0
movss %xmm0, 0x1c(%r14)
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movss 0x183e6(%rip), %xmm1    # 0x3c228
xorps %xmm0, %xmm0
movq %rbx, %rsi
callq *0x8(%rax)
movb %al, 0x20(%r14)
movabsq $0x7f7fffff7f7fffff, %rax # imm = 0x7F7FFFFF7F7FFFFF
movq %rax, 0x2c(%rsp)
movl $0x7f7fffff, 0x34(%rsp) # imm = 0x7F7FFFFF
movabsq $-0x80000000800001, %rax # imm = 0xFF7FFFFFFF7FFFFF
movq %rax, 0x20(%rsp)
movl $0xff7fffff, 0x28(%rsp) # imm = 0xFF7FFFFF
movsd 0x30(%r14), %xmm0
movss 0x38(%r14), %xmm1
movsd 0x24(%r14), %xmm2
movss 0x2c(%r14), %xmm3
movaps %xmm0, %xmm4
shufps $0x55, %xmm0, %xmm4     # xmm4 = xmm4[1,1],xmm0[1,1]
movaps %xmm2, %xmm5
shufps $0x55, %xmm2, %xmm5     # xmm5 = xmm5[1,1],xmm2[1,1]
movss 0x18(%r14), %xmm6
movss 0x1c(%r14), %xmm7
movaps 0x18449(%rip), %xmm8    # 0x3c300
xorps %xmm6, %xmm8
xorl %eax, %eax
xorps %xmm9, %xmm9
cvtsi2ss %eax, %xmm9
movl $0x1, %ecx
subl %eax, %ecx
xorps %xmm10, %xmm10
cvtsi2ss %ecx, %xmm10
mulss %xmm2, %xmm10
mulss %xmm0, %xmm9
addss %xmm10, %xmm9
movaps %xmm7, %xmm10
mulss %xmm9, %xmm10
mulss %xmm8, %xmm9
xorl %ecx, %ecx
xorps %xmm11, %xmm11
cvtsi2ss %ecx, %xmm11
movl $0x1, %edx
subl %ecx, %edx
xorps %xmm12, %xmm12
cvtsi2ss %edx, %xmm12
mulss %xmm5, %xmm12
mulss %xmm4, %xmm11
addss %xmm12, %xmm11
xorl %edx, %edx
xorps %xmm12, %xmm12
cvtsi2ss %edx, %xmm12
movl $0x1, %esi
subl %edx, %esi
xorps %xmm13, %xmm13
cvtsi2ss %esi, %xmm13
mulss %xmm1, %xmm12
mulss %xmm3, %xmm13
addss %xmm12, %xmm13
movaps %xmm6, %xmm12
mulss %xmm13, %xmm12
addss %xmm10, %xmm12
mulss %xmm7, %xmm13
addss %xmm9, %xmm13
movss %xmm12, (%rsp)
movss %xmm11, 0x4(%rsp)
movss %xmm13, 0x8(%rsp)
xorl %esi, %esi
movss (%rsp,%rsi,4), %xmm12
ucomiss 0x20(%rsp,%rsi,4), %xmm12
jbe 0x23f8a
movss %xmm12, 0x20(%rsp,%rsi,4)
movss 0x2c(%rsp,%rsi,4), %xmm13
ucomiss %xmm12, %xmm13
jbe 0x23f9e
movss %xmm12, 0x2c(%rsp,%rsi,4)
incq %rsi
cmpq $0x3, %rsi
jne 0x23f75
leal 0x1(%rdx), %esi
testl %edx, %edx
movl %esi, %edx
je 0x23f1f
leal 0x1(%rcx), %edx
testl %ecx, %ecx
movl %edx, %ecx
je 0x23ef5
leal 0x1(%rax), %ecx
testl %eax, %eax
movl %ecx, %eax
je 0x23ebd
movl 0x34(%rsp), %eax
movl %eax, 0x8(%rsp)
movq 0x2c(%rsp), %rax
movq %rax, (%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0xc(%rsp)
movl 0x28(%rsp), %eax
movl %eax, 0x14(%rsp)
movq (%rsp), %rax
movq %rax, (%rbx)
movl 0x8(%rsp), %eax
movl %eax, 0x8(%rbx)
movl 0xc(%rsp), %eax
movl %eax, 0xc(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x24028
callq 0x7768
movq %rbx, %rdi
callq 0x66e0