// File: /workspace/github_cpp_makefile_star2_O2/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 $0x98, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, 0x40(%rsp)
movq %rdi, %r12
movl (%rdx), %eax
movl 0x8(%rdx), %ecx
cvtsi2sd %eax, %xmm0
movsd 0x6152(%rip), %xmm1     # 0xc3f0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
cvtsi2sd %ecx, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movl %ecx, 0x1c(%rsp)
fildl 0x1c(%rsp)
fstpt 0x80(%rsp)
movl %eax, 0x18(%rsp)
fildl 0x18(%rsp)
fstpt 0x8c(%rsp)
xorl %r13d, %r13d
testl %eax, %eax
cmovlel %r13d, %eax
movl %eax, 0xc(%rsp)
testl %ecx, %ecx
cmovlel %r13d, %ecx
movl %ecx, 0x10(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
xorl %eax, %eax
cmpl 0x10(%rsp), %eax
je 0x646f
movl %eax, 0x14(%rsp)
movsd 0x38(%rsp), %xmm0
subsd (%rsp), %xmm0
addsd 0x60f9(%rip), %xmm0     # 0xc410
movsd %xmm0, 0x78(%rsp)
fldl 0x78(%rsp)
fmull 0x5ce1(%rip)            # 0xc008
fldt 0x80(%rsp)
fdivrp %st, %st(1)
fstpl 0x70(%rsp)
movsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movslq %r13d, %r13
leaq 0x2(,%r13,2), %rbp
addq %r13, %rbp
xorpd %xmm0, %xmm0
movl 0xc(%rsp), %r15d
subl $0x1, %r15d
jb 0x6452
movsd %xmm0, 0x58(%rsp)
addsd 0x6081(%rip), %xmm0     # 0xc3f0
subsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
fldl 0x68(%rsp)
fmull 0x5cb3(%rip)            # 0xc038
fldt 0x8c(%rsp)
fdivrp %st, %st(1)
fstpl 0x60(%rsp)
movsd 0x60(%rsp), %xmm1
andq $0x0, 0x30(%rsp)
andq $0x0, 0x28(%rsp)
movq (%r12), %rax
movq %r12, %rdi
movq %rbx, %rsi
movsd 0x20(%rsp), %xmm0
movsd %xmm1, 0x50(%rsp)
callq *0x30(%rax)
testb %al, %al
je 0x640e
movq (%r12), %rax
movq %r12, %rdi
movq %rbx, %rsi
movsd 0x20(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
leaq 0x30(%rsp), %rdx
leaq 0x28(%rsp), %rcx
callq *0x28(%rax)
testb %al, %al
je 0x640e
movsd 0x30(%rsp), %xmm2
movsd 0x28(%rsp), %xmm3
movq %r12, %rdi
movq 0x40(%rsp), %rsi
movq %r14, %rdx
movq %rbx, %rcx
movl %r13d, %r8d
callq 0x6482
testb %al, %al
jne 0x6438
cmpb $0x0, 0x98(%rbx)
jne 0x6438
movq 0x10(%r14), %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 0x58(%rsp), %xmm0
addsd 0x5c02(%rip), %xmm0     # 0xc048
incq %r13
addq $0x3, %rbp
jmp 0x6357
movsd (%rsp), %xmm0
addsd 0x5be9(%rip), %xmm0     # 0xc048
movsd %xmm0, (%rsp)
movl 0x14(%rsp), %eax
incl %eax
jmp 0x62f6
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop