// File: /workspace/github_cpp_makefile_star2_O3/matthewarcus[P]mmps/transform.cpp
// Function: Transform::TransformImageInv(Image const&, Image&, TransformParams const&)
void Transform::TransformImageInv(const Image& inImage, Image& outImage,
				  const TransformParams& params)
{
  int ow = outImage.Width();
  int oh = outImage.Height();
  double orgx = 0.5 * ow;
  double orgy = 0.5 * oh;
  // Now scan across the output image
  int ox, oy; int outIndex = 0;
  for (oy = 0; oy < oh; oy++) {
    for (ox = 0; ox < ow; ox++, outIndex++) {
      // Compute lat and long
      double phi = (orgy - oy - 0.5) * pi / oh;
      double lambda = (ox + 0.5 - orgx) * twopi / ow;
      
      // Compute the scaled x,y coordinates for <phi,lambda>
      double x = 0.0, y = 0.0;
      if (!CheckPoint(params,phi,lambda) ||
	  !ProjectInv(params, phi, lambda, x, y) ||
	  !SetDataInv(inImage, outImage, params, ox, oy, x, y, outIndex)) {
	if (!params.noback) {
	  outImage.SetRgb(outIndex, params.background);
	}
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, 0x50(%rsp)
movq %rdx, 0x10(%rsp)
movl 0x8(%rdx), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
jle 0x6c42
movq %rcx, %rbx
movq %rdi, %r12
movq 0x10(%rsp), %rax
movl (%rax), %r14d
cvtsi2sd %r14d, %xmm0
movsd 0x69bb(%rip), %xmm1     # 0xd428
mulsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
movl 0xc(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
movl %eax, 0x20(%rsp)
fildl 0x20(%rsp)
fstpt 0x90(%rsp)
movl %r14d, 0x24(%rsp)
xorl %r13d, %r13d
xorpd %xmm1, %xmm1
fildl 0x24(%rsp)
fstpt 0x9c(%rsp)
xorl %eax, %eax
xorl %r15d, %r15d
movl %r14d, 0x18(%rsp)
movl %eax, 0x1c(%rsp)
testl %r14d, %r14d
movsd %xmm1, 0x48(%rsp)
jle 0x6c1f
movsd 0x40(%rsp), %xmm0
subsd %xmm1, %xmm0
addsd 0x6967(%rip), %xmm0     # 0xd448
movsd %xmm0, 0x88(%rsp)
fldl 0x88(%rsp)
fmull 0x6511(%rip)            # 0xd008
fldt 0x90(%rsp)
fdivrp %st, %st(1)
fstpl 0x80(%rsp)
movsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movslq %r15d, %rax
leaq (%rax,%rax,2), %rbp
addq $0x2, %rbp
xorpd %xmm0, %xmm0
movsd %xmm0, 0x68(%rsp)
addsd 0x68f5(%rip), %xmm0     # 0xd428
subsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
fldl 0x78(%rsp)
fmull 0x64ef(%rip)            # 0xd038
fldt 0x9c(%rsp)
fdivrp %st, %st(1)
fstpl 0x70(%rsp)
movsd 0x70(%rsp), %xmm1
movq %r13, 0x38(%rsp)
movq %r13, 0x30(%rsp)
movq (%r12), %rax
movq %r12, %rdi
movq %rbx, %rsi
movsd 0x28(%rsp), %xmm0
movsd %xmm1, 0x60(%rsp)
callq *0x30(%rax)
testb %al, %al
je 0x6bd2
movq (%r12), %rax
movq %r12, %rdi
movq %rbx, %rsi
movsd 0x28(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
leaq 0x38(%rsp), %rdx
leaq 0x30(%rsp), %rcx
callq *0x28(%rax)
testb %al, %al
je 0x6bd2
movsd 0x38(%rsp), %xmm2
movsd 0x30(%rsp), %xmm3
movq %r12, %rdi
movq 0x50(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rcx
movl %r15d, %r8d
callq 0x6c54
testb %al, %al
jne 0x6c01
cmpb $0x0, 0x98(%rbx)
jne 0x6c01
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
movb 0xc0(%rbx), %cl
movb %cl, -0x2(%rax,%rbp)
movb 0xc1(%rbx), %cl
movb %cl, -0x1(%rax,%rbp)
movb 0xc2(%rbx), %cl
movb %cl, (%rax,%rbp)
movsd 0x68(%rsp), %xmm0
addsd 0x6439(%rip), %xmm0     # 0xd048
incl %r15d
addq $0x3, %rbp
decl %r14d
jne 0x6b25
movsd 0x48(%rsp), %xmm1
addsd 0x641b(%rip), %xmm1     # 0xd048
movl 0x1c(%rsp), %eax
incl %eax
cmpl 0xc(%rsp), %eax
movl 0x18(%rsp), %r14d
jne 0x6abc
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq