// File: matthewarcus[P]mmps/transform.cpp
// Function: Transform::DrawGrid(Image&, TransformParams const&, Transform::CmdParams const&) const
void Transform::DrawGrid (Image& image, 
			  const TransformParams& params,
			  const CmdParams &cmdparams) const
{
  int gridx = cmdparams.gridx;
  int gridy = cmdparams.gridy;
  int gridoff = cmdparams.gridoff;
  double loff = 2*pi*gridoff/360.0;
  int nx = 360/gridx;
  int ny = 180/gridy;
  for (int i = 0; i < nx; i++) {
    LatPlotter latplotter(image, params, *this);
    double lambda = (i - nx/2) * 2 * pi / nx + loff;
    latplotter.lambda = lambda;
    // Omit the last section of the lines of latitude.
    //image.PlotLine(-pi/2+radians(gridy), pi/2-radians(gridy), latplotter, cmdparams.color, 16);
    image.PlotLine(-pi/2, pi/2, latplotter, cmdparams.color, 16);
  }
  LongPlotter longplotter(image, params, *this);
  for (int i = 0; i <= ny; i++) {
    longplotter.phi = (i - ny/2) * pi / ny;
    image.PlotLine(-pi, pi, longplotter, cmdparams.color,16);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rax
cvttsd2si 0x10(%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0xb8(%rbp)
fildl -0xb8(%rbp)
fldl 0x83bd(%rip)            # 0x15038
fmulp %st, %st(1)
flds 0x87f9(%rip)            # 0x1547c
fdivrp %st, %st(1)
fstpl -0xc0(%rbp)
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x168, %eax            # imm = 0x168
cltd
idivl -0x24(%rbp)
movl %eax, -0x3c(%rbp)
movl $0xb4, %eax
cltd
idivl -0x28(%rbp)
movl %eax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0xcd8a
movq -0xd8(%rbp), %rcx
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x70(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0xe3e0
movq -0xe0(%rbp), %rsi
movl -0x44(%rbp), %ecx
movl -0x3c(%rbp), %eax
movl %eax, %edi
shrl $0x1f, %edi
movl %eax, %edx
addl %edi, %edx
shrl %edx
subl %edx, %ecx
addl %ecx, %ecx
movl %ecx, -0xcc(%rbp)
fildl -0xcc(%rbp)
fldl 0x82f8(%rip)            # 0x15008
fmulp %st, %st(1)
movl %eax, -0xd0(%rbp)
fildl -0xd0(%rbp)
fdivrp %st, %st(1)
fldl -0x38(%rbp)
faddp %st, %st(1)
fstpl -0x78(%rbp)
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
movsd 0x82e6(%rip), %xmm0     # 0x15028
movsd 0x82d6(%rip), %xmm1     # 0x15020
movl $0x10, %ecx
callq 0x13e50
jmp 0xcd56
leaq -0x70(%rbp), %rdi
callq 0xe440
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xccb7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x70(%rbp), %rdi
callq 0xe440
jmp 0xce6f
movq -0xd8(%rbp), %rcx
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0xe460
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0x40(%rbp), %eax
jg 0xce5a
movl -0xb4(%rbp), %ecx
movl -0x40(%rbp), %eax
movl %eax, %esi
shrl $0x1f, %esi
movl %eax, %edx
addl %esi, %edx
sarl %edx
subl %edx, %ecx
movl %ecx, -0xc4(%rbp)
fildl -0xc4(%rbp)
fldl 0x8222(%rip)            # 0x15008
fmulp %st, %st(1)
movl %eax, -0xc8(%rbp)
fildl -0xc8(%rbp)
fdivrp %st, %st(1)
fstpl -0x90(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
movsd 0x8224(%rip), %xmm0     # 0x15030
movsd 0x81f4(%rip), %xmm1     # 0x15008
leaq -0xb0(%rbp), %rsi
movl $0x10, %ecx
callq 0x13e50
jmp 0xce27
jmp 0xce29
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0xcdaf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0xe4c0
jmp 0xce6f
leaq -0xb0(%rbp), %rdi
callq 0xe4c0
addq $0xe0, %rsp
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x5420
nopl (%rax,%rax)