// File: /workspace/github_c_makefile_star2_O3/archer1357[P]Offline-Raytracer/math.c
// Function: mat4_rotateAxis
void mat4_rotateAxis(float *out,const float *axis,
                     float angle,bool norm,bool mul) {
  float axis2[3];
  float mat[16];
  float u,v,w,L,u2,v2,w2;

  mat4_identity(mat);

  if(norm) {
    vec3_normal(axis2,axis);
  } else {
    axis2[0]=axis[0];
    axis2[1]=axis[1];
    axis2[2]=axis[2];
  }

  u=axis2[0];
  v=axis2[1];
  w=axis2[2];

  L=(u*u+v*v+w*w);

  u2=axis2[0]*axis2[0];
  v2=axis2[1]*axis2[1];
  w2=axis2[2]*axis2[2];

  mat[0]=(u2+(v2+w2)*cosf(angle))/L;
  mat[1]=(u*v*(1.0f-cosf(angle))-w*sqrtf(L)*sinf(angle))/L;
  mat[2]=(u*w*(1.0f-cosf(angle))+v*sqrtf(L)*sinf(angle))/L;

  mat[4]=(u*v*(1.0f-cosf(angle))+w*sqrtf(L)*sinf(angle))/L;
  mat[5]=(v2+(u2+w2)*cosf(angle))/L;
  mat[6]=(v*w*(1.0f-cosf(angle))-u*sqrtf(L)*sinf(angle))/L;

  mat[8]=(u*w*(1.0f-cosf(angle))-v*sqrtf(L)*sinf(angle))/L;
  mat[9]=(v*w*(1.0f-cosf(angle))+u*sqrtf(L)*sinf(angle))/L;
  mat[10]=(w2+(u2+v2)*cosf(angle))/L;

  //
  if(mul) {
    mat4_mul(out,out,mat);
  } else {
    memcpy(out,mat,sizeof(mat));
  }
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movl %ecx, %ebp
movq %rdi, %rbx
movd 0xcfb1e(%rip), %xmm8    # 0x4d7c90
xorl %eax, %eax
movdqa 0xcfb24(%rip), %xmm1    # 0x4d7ca0
movdqa 0xcfb2c(%rip), %xmm2    # 0x4d7cb0
movdqa 0xcfb34(%rip), %xmm3    # 0x4d7cc0
movdqa 0xce2cc(%rip), %xmm4    # 0x4d6460
movdqa 0xcfb34(%rip), %xmm5    # 0x4d7cd0
movdqa %xmm8, %xmm6
punpcklbw %xmm6, %xmm6    # xmm6 = xmm6[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
pmullw %xmm1, %xmm6
pand %xmm2, %xmm6
packuswb %xmm6, %xmm6
movdqa %xmm6, %xmm7
pminub %xmm3, %xmm7
pcmpeqb %xmm6, %xmm7
punpcklbw %xmm7, %xmm7    # xmm7 = xmm7[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
punpcklwd %xmm7, %xmm7    # xmm7 = xmm7[0,0,1,1,2,2,3,3]
pand %xmm4, %xmm7
movdqa %xmm7, 0xc0(%rsp,%rax,4)
addq $0x4, %rax
paddb %xmm5, %xmm8
cmpq $0x10, %rax
jne 0x40819c
movsd (%rsi), %xmm3
testb %dl, %dl
je 0x40822b
movaps %xmm3, %xmm2
mulps %xmm3, %xmm2
shufps $0x55, %xmm2, %xmm2     # xmm2 = xmm2[1,1,1,1]
movaps %xmm3, %xmm1
mulss %xmm3, %xmm1
addss %xmm2, %xmm1
movss 0x8(%rsi), %xmm4
movaps %xmm4, %xmm2
mulss %xmm4, %xmm2
addss %xmm1, %xmm2
sqrtss %xmm2, %xmm2
movss 0xcf706(%rip), %xmm1    # 0x4d7920
divss %xmm2, %xmm1
mulss %xmm1, %xmm4
shufps $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
mulps %xmm1, %xmm3
jmp 0x408230
movss 0x8(%rsi), %xmm4
movaps %xmm3, 0x20(%rsp)
movaps %xmm4, 0x50(%rsp)
movaps %xmm4, %xmm1
mulss %xmm4, %xmm1
movaps %xmm1, 0xb0(%rsp)
movd %xmm0, (%rsp)
callq 0x401078
movdqa %xmm0, 0x10(%rsp)
movaps 0x20(%rsp), %xmm2
movaps %xmm2, %xmm0
shufps $0x55, %xmm2, %xmm0     # xmm0 = xmm0[1,1],xmm2[1,1]
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, %xmm1
mulss %xmm2, %xmm1
movaps %xmm1, 0x70(%rsp)
movss (%rsp), %xmm0
callq 0x401078
movss 0xcf695(%rip), %xmm1    # 0x4d7920
movss %xmm1, 0x30(%rsp)
subss %xmm0, %xmm1
movaps %xmm1, 0x60(%rsp)
movss (%rsp), %xmm0
callq 0x401118
movaps %xmm0, 0x40(%rsp)
movaps 0x50(%rsp), %xmm0
movaps %xmm0, %xmm1
xorps 0xcf698(%rip), %xmm1    # 0x4d7950
movaps %xmm1, 0x90(%rsp)
movaps 0x10(%rsp), %xmm1
unpcklps 0x70(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
movaps %xmm1, 0x10(%rsp)
shufps $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
mulps 0x20(%rsp), %xmm0
movaps %xmm0, 0xa0(%rsp)
movss (%rsp), %xmm0
callq 0x401078
movss 0xcf62e(%rip), %xmm1    # 0x4d7920
subss %xmm0, %xmm1
movss %xmm1, 0xc(%rsp)
movss (%rsp), %xmm0
callq 0x401118
movss %xmm0, 0x8(%rsp)
movss (%rsp), %xmm0
callq 0x401078
movss 0xcf602(%rip), %xmm1    # 0x4d7920
subss %xmm0, %xmm1
movaps %xmm1, 0x100(%rsp)
movss (%rsp), %xmm0
callq 0x401118
movss %xmm0, 0x4(%rsp)
movss (%rsp), %xmm0
callq 0x401078
movaps 0x80(%rsp), %xmm4
movaps %xmm4, %xmm5
mulss %xmm4, %xmm5
movaps 0xb0(%rsp), %xmm2
movaps %xmm2, %xmm1
addss %xmm5, %xmm1
unpcklps 0x60(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
movaps 0x20(%rsp), %xmm3
movaps %xmm3, %xmm6
mulss %xmm3, %xmm6
addss %xmm5, %xmm6
movaps %xmm5, %xmm7
movaps %xmm5, 0x110(%rsp)
addss %xmm2, %xmm6
movaps %xmm2, %xmm5
mulps 0x10(%rsp), %xmm1
xorps %xmm2, %xmm2
sqrtss %xmm6, %xmm2
movaps 0x90(%rsp), %xmm9
mulss %xmm2, %xmm9
movaps %xmm2, %xmm8
movaps %xmm2, 0x10(%rsp)
movlhps %xmm3, %xmm9            # xmm9 = xmm9[0],xmm3[0]
shufps $0xe2, %xmm3, %xmm9     # xmm9 = xmm9[2,0],xmm3[2,3]
movaps 0x40(%rsp), %xmm2
movlhps %xmm3, %xmm2            # xmm2 = xmm2[0],xmm3[0]
shufps $0xe2, %xmm3, %xmm2     # xmm2 = xmm2[2,0],xmm3[2,3]
mulps %xmm9, %xmm2
addps %xmm2, %xmm1
movaps %xmm2, %xmm3
movaps %xmm2, 0x40(%rsp)
movaps %xmm6, 0x60(%rsp)
movaps %xmm6, %xmm2
shufps $0x0, %xmm6, %xmm2      # xmm2 = xmm2[0,0],xmm6[0,0]
divps %xmm2, %xmm1
movaps %xmm2, %xmm9
movaps %xmm2, 0x90(%rsp)
movlps %xmm1, 0xc0(%rsp)
movaps %xmm4, %xmm1
mulss %xmm8, %xmm1
mulss 0x8(%rsp), %xmm1
movss 0xc(%rsp), %xmm2
mulss 0xa0(%rsp), %xmm2
addss %xmm1, %xmm2
divss %xmm6, %xmm2
movss %xmm2, 0xc8(%rsp)
movaps 0x50(%rsp), %xmm2
mulss %xmm8, %xmm2
mulss 0x4(%rsp), %xmm2
movaps %xmm5, %xmm1
addss %xmm3, %xmm1
movaps 0x70(%rsp), %xmm3
unpcklps %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
movaps 0x100(%rsp), %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
mulps %xmm3, %xmm1
unpcklps %xmm7, %xmm2            # xmm2 = xmm2[0],xmm7[0],xmm2[1],xmm7[1]
addps %xmm1, %xmm2
divps %xmm9, %xmm2
movlps %xmm2, 0xd0(%rsp)
movss (%rsp), %xmm0
callq 0x401078
movss 0x30(%rsp), %xmm1
subss %xmm0, %xmm1
movss %xmm1, 0x30(%rsp)
movss (%rsp), %xmm0
callq 0x401118
movaps 0x10(%rsp), %xmm1
mulss 0x20(%rsp), %xmm1
mulss %xmm0, %xmm1
movaps 0xa0(%rsp), %xmm0
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
mulss 0x30(%rsp), %xmm0
subss %xmm1, %xmm0
divss 0x60(%rsp), %xmm0
movss %xmm0, 0xd8(%rsp)
movss (%rsp), %xmm0
callq 0x401078
movaps %xmm0, 0x70(%rsp)
movss (%rsp), %xmm0
callq 0x401118
movaps %xmm0, 0x30(%rsp)
movaps 0x80(%rsp), %xmm0
xorps 0xcf46b(%rip), %xmm0    # 0x4d7950
movaps %xmm0, 0x80(%rsp)
movss (%rsp), %xmm0
callq 0x401078
movaps %xmm0, 0x50(%rsp)
movss (%rsp), %xmm0
callq 0x401118
movaps 0x70(%rsp), %xmm2
unpcklps 0x50(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
movaps 0xcf7c9(%rip), %xmm1    # 0x4d7ce0
subps %xmm2, %xmm1
movaps 0x10(%rsp), %xmm3
unpcklps %xmm3, %xmm3            # xmm3 = xmm3[0,0,1,1]
movaps 0x80(%rsp), %xmm2
unpcklps 0x20(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
mulps %xmm3, %xmm2
movaps 0x30(%rsp), %xmm3
unpcklps %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1]
mulps %xmm2, %xmm3
mulps 0xa0(%rsp), %xmm1
addps %xmm3, %xmm1
divps 0x90(%rsp), %xmm1
movlps %xmm1, 0xe0(%rsp)
movaps 0x40(%rsp), %xmm0
addss 0x110(%rsp), %xmm0
movaps %xmm0, 0x40(%rsp)
movss (%rsp), %xmm0
callq 0x401078
mulss 0x40(%rsp), %xmm0
addss 0xb0(%rsp), %xmm0
divss 0x60(%rsp), %xmm0
movss %xmm0, 0xe8(%rsp)
testb %bpl, %bpl
je 0x408621
xorl %eax, %eax
leaq 0xc0(%rsp), %rcx
movq %rbx, %rdx
leaq (,%rax,4), %rsi
movq %rcx, %rdi
xorl %r8d, %r8d
xorps %xmm0, %xmm0
xorl %r9d, %r9d
movss (%rdx,%r9), %xmm1
mulss (%rdi,%r9,4), %xmm1
addss %xmm1, %xmm0
addq $0x4, %r9
cmpq $0x10, %r9
jne 0x4085bd
leaq (%r8,%rsi), %r9
movss %xmm0, 0x120(%rsp,%r9,4)
incq %r8
addq $0x4, %rdi
cmpq $0x4, %r8
jne 0x4085b7
incq %rax
addq $0x10, %rdx
cmpq $0x4, %rax
jne 0x4085a9
movaps 0x120(%rsp), %xmm0
movaps 0x130(%rsp), %xmm1
movaps 0x140(%rsp), %xmm2
movaps 0x150(%rsp), %xmm3
jmp 0x408641
movaps 0xc0(%rsp), %xmm0
movaps 0xd0(%rsp), %xmm1
movaps 0xe0(%rsp), %xmm2
movaps 0xf0(%rsp), %xmm3
movups %xmm3, 0x30(%rbx)
movups %xmm2, 0x20(%rbx)
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %rbp
retq