// File: 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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rdi
callq 0x74e0
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rdi
callq 0x7500
movl %eax, -0x28(%rbp)
cvtsi2sdl -0x24(%rbp), %xmm1
movsd 0xc29d(%rip), %xmm0     # 0x15408
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
cvtsi2sdl -0x28(%rbp), %xmm1
movsd 0xc287(%rip), %xmm0     # 0x15408
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x930d
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x92fd
movq -0x90(%rbp), %rdi
movsd -0x38(%rbp), %xmm0
cvtsi2sdl -0x40(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd 0xc234(%rip), %xmm1     # 0x15408
subsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
fldl -0x78(%rbp)
fldl 0xbe22(%rip)            # 0x15008
fmulp %st, %st(1)
movl -0x28(%rbp), %eax
movl %eax, -0x70(%rbp)
fildl -0x70(%rbp)
fdivrp %st, %st(1)
fstpl -0x50(%rbp)
cvtsi2sdl -0x3c(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd -0x30(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
fldl -0x80(%rbp)
fldl 0xbe22(%rip)            # 0x15038
fmulp %st, %st(1)
movl -0x24(%rbp), %eax
movl %eax, -0x6c(%rbp)
fildl -0x6c(%rbp)
fdivrp %st, %st(1)
fstpl -0x88(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x20(%rbp), %rsi
movsd -0x50(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
movq (%rdi), %rax
callq *0x30(%rax)
testb $0x1, %al
jne 0x9260
jmp 0x92bd
movq -0x90(%rbp), %rdi
movq -0x20(%rbp), %rsi
movsd -0x50(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
movq (%rdi), %rax
leaq -0x60(%rbp), %rdx
leaq -0x68(%rbp), %rcx
callq *0x28(%rax)
testb $0x1, %al
jne 0x9289
jmp 0x92bd
movq -0x90(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
cvtsi2sdl -0x3c(%rbp), %xmm0
cvtsi2sdl -0x40(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
movsd -0x68(%rbp), %xmm3
movl -0x44(%rbp), %r8d
callq 0x9320
testb $0x1, %al
jne 0x92e4
movq -0x20(%rbp), %rax
testb $0x1, 0x98(%rax)
jne 0x92e2
movq -0x18(%rbp), %rdi
movslq -0x44(%rbp), %rsi
movq -0x20(%rbp), %rdx
addq $0xc0, %rdx
callq 0x7590
jmp 0x92e4
jmp 0x92e6
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x91ab
jmp 0x92ff
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x9198
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)