// File: BartMassey[P]ancient-raytracer/xform.cc
// Function: xform::xform(xform_types, float)
xform::xform( enum xform_types t, float a ) {
  int i, j;
  float ca = cos(a);
  float sa = sin(a);

#if DEBUGLEVEL > 0
  // check for small floating-point errors in trig functions
  assert( ca <= 1 );
  assert( ca >= -1 );
  assert( sa <= 1 );
  assert( ca >= -1 );
#endif
  // now generate the xform
  m = &mv;
  mi = &miv;
  for( i = 0; i < 4; i++ )
    for( j = 0; j < 4; j++ ) {
      (*m)[i][j] = 0;
      (*mi)[i][j] = 0;
    }
  switch( t ) {
  case XFORM_ROTATE_X:
    (*m)[0][0] = 1;
    (*m)[3][3] = 1;
    (*m)[1][1] = ca;
    (*m)[2][2] = ca;
    (*m)[1][2] = -sa;
    (*m)[2][1] = sa;
    (*mi)[0][0] = 1;
    (*mi)[3][3] = 1;
    (*mi)[1][1] = ca;
    (*mi)[2][2] = ca;
    (*mi)[1][2] = sa;
    (*mi)[2][1] = -sa;
    break;
  case XFORM_ROTATE_Y:
    (*m)[1][1] = 1;
    (*m)[3][3] = 1;
    (*m)[0][0] = ca;
    (*m)[2][2] = ca;
    (*m)[2][0] = -sa;
    (*m)[0][2] = sa;
    (*mi)[1][1] = 1;
    (*mi)[3][3] = 1;
    (*mi)[0][0] = ca;
    (*mi)[2][2] = ca;
    (*mi)[2][0] = sa;
    (*mi)[0][2] = -sa;
    break;
  case XFORM_ROTATE_Z:
    (*m)[2][2] = 1;
    (*m)[3][3] = 1;
    (*m)[0][0] = ca;
    (*m)[1][1] = ca;
    (*m)[0][1] = -sa;
    (*m)[1][0] = sa;
    (*mi)[2][2] = 1;
    (*mi)[3][3] = 1;
    (*mi)[0][0] = ca;
    (*mi)[1][1] = ca;
    (*mi)[0][1] = sa;
    (*mi)[1][0] = -sa;
    break;
  default:
    assert( 0 );
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movss %xmm0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq 0x8b1d(%rip), %rcx      # 0xea50
addq $0x10, %rcx
movq %rcx, (%rax)
movss -0x10(%rbp), %xmm0
callq 0x6810
movss %xmm0, -0x1c(%rbp)
movss -0x10(%rbp), %xmm0
callq 0x6830
movq -0x28(%rbp), %rax
movss %xmm0, -0x20(%rbp)
movq %rax, %rcx
addq $0x18, %rcx
movq %rcx, 0x8(%rax)
movq %rax, %rcx
addq $0x58, %rcx
movq %rcx, 0x10(%rax)
movl $0x0, -0x14(%rbp)
cmpl $0x4, -0x14(%rbp)
jge 0x5fde
movl $0x0, -0x18(%rbp)
cmpl $0x4, -0x18(%rbp)
jge 0x5fd1
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
movslq -0x14(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movslq -0x18(%rbp), %rdx
xorps %xmm0, %xmm0
movss %xmm0, (%rcx,%rdx,4)
movq 0x10(%rax), %rax
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq -0x18(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x5f86
jmp 0x5fd3
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5f79
movl -0xc(%rbp), %eax
movl %eax, -0x2c(%rbp)
subl $0x3, %eax
je 0x600a
jmp 0x5feb
movl -0x2c(%rbp), %eax
subl $0x4, %eax
je 0x60e1
jmp 0x5ff9
movl -0x2c(%rbp), %eax
subl $0x5, %eax
je 0x61b8
jmp 0x628c
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
movss 0x4fea(%rip), %xmm0     # 0xb004
movss %xmm0, (%rcx)
movq 0x8(%rax), %rcx
movss 0x4fda(%rip), %xmm0     # 0xb004
movss %xmm0, 0x3c(%rcx)
movss -0x1c(%rbp), %xmm0
movq 0x8(%rax), %rcx
movss %xmm0, 0x14(%rcx)
movss -0x1c(%rbp), %xmm0
movq 0x8(%rax), %rcx
movss %xmm0, 0x28(%rcx)
movss -0x20(%rbp), %xmm0
movd %xmm0, %ecx
xorl $0x80000000, %ecx       # imm = 0x80000000
movd %ecx, %xmm0
movq 0x8(%rax), %rcx
movss %xmm0, 0x18(%rcx)
movss -0x20(%rbp), %xmm0
movq 0x8(%rax), %rcx
movss %xmm0, 0x24(%rcx)
movq 0x10(%rax), %rcx
movss 0x4f83(%rip), %xmm0     # 0xb004
movss %xmm0, (%rcx)
movq 0x10(%rax), %rcx
movss 0x4f73(%rip), %xmm0     # 0xb004
movss %xmm0, 0x3c(%rcx)
movss -0x1c(%rbp), %xmm0
movq 0x10(%rax), %rcx
movss %xmm0, 0x14(%rcx)
movss -0x1c(%rbp), %xmm0
movq 0x10(%rax), %rcx
movss %xmm0, 0x28(%rcx)
movss -0x20(%rbp), %xmm0
movq 0x10(%rax), %rcx
movss %xmm0, 0x18(%rcx)
movss -0x20(%rbp), %xmm0
movd %xmm0, %ecx
xorl $0x80000000, %ecx       # imm = 0x80000000
movd %ecx, %xmm0
movq 0x10(%rax), %rax
movss %xmm0, 0x24(%rax)
jmp 0x62ab
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
movss 0x4f13(%rip), %xmm0     # 0xb004
movss %xmm0, 0x14(%rcx)
movq 0x8(%rax), %rcx
movss 0x4f02(%rip), %xmm0     # 0xb004
movss %xmm0, 0x3c(%rcx)
movss -0x1c(%rbp), %xmm0
movq 0x8(%rax), %rcx
movss %xmm0, (%rcx)
movss -0x1c(%rbp), %xmm0
movq 0x8(%rax), %rcx
movss %xmm0, 0x28(%rcx)
movss -0x20(%rbp), %xmm0
movd %xmm0, %ecx
xorl $0x80000000, %ecx       # imm = 0x80000000
movd %ecx, %xmm0
movq 0x8(%rax), %rcx
movss %xmm0, 0x20(%rcx)
movss -0x20(%rbp), %xmm0
movq 0x8(%rax), %rcx
movss %xmm0, 0x8(%rcx)
movq 0x10(%rax), %rcx
movss 0x4eac(%rip), %xmm0     # 0xb004
movss %xmm0, 0x14(%rcx)
movq 0x10(%rax), %rcx
movss 0x4e9b(%rip), %xmm0     # 0xb004
movss %xmm0, 0x3c(%rcx)
movss -0x1c(%rbp), %xmm0
movq 0x10(%rax), %rcx
movss %xmm0, (%rcx)
movss -0x1c(%rbp), %xmm0
movq 0x10(%rax), %rcx
movss %xmm0, 0x28(%rcx)
movss -0x20(%rbp), %xmm0
movq 0x10(%rax), %rcx
movss %xmm0, 0x20(%rcx)
movss -0x20(%rbp), %xmm0
movd %xmm0, %ecx
xorl $0x80000000, %ecx       # imm = 0x80000000
movd %ecx, %xmm0
movq 0x10(%rax), %rax
movss %xmm0, 0x8(%rax)
jmp 0x62ab
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
movss 0x4e3c(%rip), %xmm0     # 0xb004
movss %xmm0, 0x28(%rcx)
movq 0x8(%rax), %rcx
movss 0x4e2b(%rip), %xmm0     # 0xb004
movss %xmm0, 0x3c(%rcx)
movss -0x1c(%rbp), %xmm0
movq 0x8(%rax), %rcx
movss %xmm0, (%rcx)
movss -0x1c(%rbp), %xmm0
movq 0x8(%rax), %rcx
movss %xmm0, 0x14(%rcx)
movss -0x20(%rbp), %xmm0
movd %xmm0, %ecx
xorl $0x80000000, %ecx       # imm = 0x80000000
movd %ecx, %xmm0
movq 0x8(%rax), %rcx
movss %xmm0, 0x4(%rcx)
movss -0x20(%rbp), %xmm0
movq 0x8(%rax), %rcx
movss %xmm0, 0x10(%rcx)
movq 0x10(%rax), %rcx
movss 0x4dd5(%rip), %xmm0     # 0xb004
movss %xmm0, 0x28(%rcx)
movq 0x10(%rax), %rcx
movss 0x4dc4(%rip), %xmm0     # 0xb004
movss %xmm0, 0x3c(%rcx)
movss -0x1c(%rbp), %xmm0
movq 0x10(%rax), %rcx
movss %xmm0, (%rcx)
movss -0x1c(%rbp), %xmm0
movq 0x10(%rax), %rcx
movss %xmm0, 0x14(%rcx)
movss -0x20(%rbp), %xmm0
movq 0x10(%rax), %rcx
movss %xmm0, 0x4(%rcx)
movss -0x20(%rbp), %xmm0
movd %xmm0, %ecx
xorl $0x80000000, %ecx       # imm = 0x80000000
movd %ecx, %xmm0
movq 0x10(%rax), %rax
movss %xmm0, 0x10(%rax)
jmp 0x62ab
leaq 0x5050(%rip), %rdi      # 0xb2e3
leaq 0x5166(%rip), %rsi      # 0xb400
movl $0x58, %edx
leaq 0x5182(%rip), %rcx      # 0xb428
callq 0x20b0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)