// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: maidenhead_square(double, double)
char *maidenhead_square(double Lat, double Long)
{
static char mls[16];
int i;
int Ext;
Ext = 2;

   // calculate the Maidenhead grid square
   //
   // Based on code by Yves Goergen, http://unclassified.software/source/maidenheadlocator
   // which was based upon code by Dirk Koopman, G1TLH

   Lat = Lat * 180.0 / PI;
   Long = Long * 180.0 / PI;

   i = 0;
   mls[i] = 0;

   Lat += 90.0;
   Long += 180.0;

   mls[i++] = (char) ('A' + (int) (Long / 20.0));
   mls[i++] = (char) ('A' + (int) (Lat / 10.0));

   Long = fmod(Long, 20.0);
   if(Long < 0.0) Long += 20.0;
   Lat = fmod(Lat, 10.0);
   if(Lat < 0.0) Lat += 10.0;

   mls[i++] = (char) ('0' + (int)(Long / 2.0));
   mls[i++] = (char) ('0' + (int)(Lat / 1.0));
   Long = fmod(Long, 2.0);
   if(Long < 0.0) Long += 2.0;
   Lat = fmod(Lat, 1.0);
   if(Lat < 0.0) Lat += 1.0;

   mls[i++] = (char) ('a' + (int)(Long * 12.0));
   mls[i++] = (char) ('a' + (int)(Lat * 24.0));
   Long = fmod(Long, 1.0 / 12.0);
   if(Long < 0) Long += 1.0/12.0;
   Lat = fmod(Lat, 1.0 / 24.0);
   if(Lat < 0.0) Lat += 1.0/24.0;
   mls[i] = 0;

   if(Ext >= 1) {
      mls[i++] = ' ';
      mls[i++] = (char) ('0' + (int)(Long * 120.0));
      mls[i++] = (char) ('0' + (int)(Lat * 240.0));
      Long = fmod(Long, 1.0/120.0);
      if(Long < 0.0) Long += 1.0 / 120.0;
      Lat = fmod(Lat, 1.0 / 240.0);
      if(Lat < 0.0) Lat += 1.0 / 240.0;
      mls[i] = 0;
   }

   if(Ext >= 2) {
      mls[i++] = ' ';
      mls[i++] = (char) ('A' + (int)(Long * 120.0 * 24.0));
      mls[i++] = (char) ('A' + (int)(Lat * 240.0 * 24.0));
      Long = fmod(Long, 1.0 / 120.0 / 24.0);
      if(Long < 0) Long += 1.0 / 120.0 / 24.0;
      Lat = fmod(Lat, 1.0 / 240.0 / 24.0);
      if(Lat < 0) Lat += 1.0 / 240.0 / 24.0;
      mls[i] = 0;
   }

   return &mls[0];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movapd %xmm0, %xmm3
movsd 0x5294b(%rip), %xmm0    # 0xf58a8
mulsd %xmm0, %xmm3
movsd 0x52937(%rip), %xmm2    # 0xf58a0
divsd %xmm2, %xmm3
mulsd %xmm0, %xmm1
divsd %xmm2, %xmm1
addsd 0x52a13(%rip), %xmm3    # 0xf5990
movsd %xmm3, -0x20(%rbp)
addsd %xmm1, %xmm0
movsd 0x52c2a(%rip), %xmm2    # 0xf5bb8
movapd %xmm0, %xmm4
divsd %xmm2, %xmm4
movapd %xmm2, %xmm1
cvttsd2si %xmm4, %eax
addb $0x41, %al
movb %al, 0x2bd57a(%rip)     # 0x360520
leaq 0x2bd573(%rip), %rbx    # 0x360520
movsd 0x500f3(%rip), %xmm2    # 0xf30a8
divsd %xmm2, %xmm3
cvttsd2si %xmm3, %eax
addb $0x41, %al
movb %al, 0x2bd55c(%rip)     # 0x360521
callq 0x94d0
movsd 0x52be6(%rip), %xmm3    # 0xf5bb8
addsd %xmm0, %xmm3
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm2
cmpltsd %xmm1, %xmm2
andpd %xmm2, %xmm3
andnpd %xmm0, %xmm2
orpd %xmm3, %xmm2
movapd %xmm2, -0x30(%rbp)
movsd -0x20(%rbp), %xmm0
movsd 0x500a7(%rip), %xmm1    # 0xf30a8
callq 0x94d0
movsd 0x5009a(%rip), %xmm1    # 0xf30a8
addsd %xmm0, %xmm1
movapd %xmm0, %xmm2
cmpltsd 0x500f9(%rip), %xmm2    # 0xf3118
andpd %xmm2, %xmm1
andnpd %xmm0, %xmm2
orpd %xmm1, %xmm2
movapd %xmm2, -0x20(%rbp)
movapd -0x30(%rbp), %xmm0
movapd %xmm0, %xmm1
mulsd 0x50027(%rip), %xmm1    # 0xf3068
cvttsd2si %xmm1, %eax
addb $0x30, %al
movb %al, 0x2bd4d5(%rip)     # 0x360522
cvttsd2si %xmm2, %eax
addb $0x30, %al
movb %al, 0x2bd4ca(%rip)     # 0x360523
movsd 0x529e7(%rip), %xmm1    # 0xf5a48
callq 0x94d0
movsd 0x529da(%rip), %xmm2    # 0xf5a48
addsd %xmm0, %xmm2
movapd %xmm0, %xmm1
cmpltsd 0x50099(%rip), %xmm1    # 0xf3118
andpd %xmm1, %xmm2
andnpd %xmm0, %xmm1
orpd %xmm2, %xmm1
movapd %xmm1, -0x30(%rbp)
movsd 0x4ffd8(%rip), %xmm1    # 0xf3070
movapd -0x20(%rbp), %xmm0
callq 0x94d0
movsd 0x4ffc6(%rip), %xmm2    # 0xf3070
addsd %xmm0, %xmm2
movapd %xmm0, %xmm1
cmpltsd 0x5005d(%rip), %xmm1    # 0xf3118
andpd %xmm1, %xmm2
movapd %xmm2, %xmm3
andnpd %xmm0, %xmm1
movapd -0x30(%rbp), %xmm0
movapd %xmm0, %xmm2
mulsd 0x65710(%rip), %xmm2    # 0x1087e8
orpd %xmm3, %xmm1
movapd %xmm1, -0x20(%rbp)
cvttsd2si %xmm2, %eax
addb $0x61, %al
movb %al, 0x2bd437(%rip)     # 0x360524
movapd %xmm1, %xmm2
mulsd 0x4ff47(%rip), %xmm2    # 0xf3040
cvttsd2si %xmm2, %eax
addb $0x61, %al
movb %al, 0x2bd420(%rip)     # 0x360525
movsd 0x656e3(%rip), %xmm1    # 0x1087f0
callq 0x94d0
movsd 0x656d6(%rip), %xmm2    # 0x1087f0
addsd %xmm0, %xmm2
movapd %xmm0, %xmm1
cmpltsd 0x4ffed(%rip), %xmm1    # 0xf3118
andpd %xmm1, %xmm2
andnpd %xmm0, %xmm1
orpd %xmm2, %xmm1
movapd %xmm1, -0x30(%rbp)
movsd 0x656b4(%rip), %xmm1    # 0x1087f8
movapd -0x20(%rbp), %xmm0
callq 0x94d0
movsd 0x656a2(%rip), %xmm2    # 0x1087f8
addsd %xmm0, %xmm2
movapd %xmm0, %xmm1
cmpltsd 0x4ffb1(%rip), %xmm1    # 0xf3118
andpd %xmm1, %xmm2
andnpd %xmm0, %xmm1
orpd %xmm2, %xmm1
movapd %xmm1, %xmm2
movapd %xmm1, -0x20(%rbp)
movb $0x20, %r14b
movb %r14b, 0x2bd3a0(%rip)   # 0x360526
movapd -0x30(%rbp), %xmm0
movapd %xmm0, %xmm1
mulsd 0x52831(%rip), %xmm1    # 0xf59c8
cvttsd2si %xmm1, %eax
addb $0x30, %al
movb %al, 0x2bd384(%rip)     # 0x360527
movapd %xmm2, %xmm1
mulsd 0x65651(%rip), %xmm1    # 0x108800
cvttsd2si %xmm1, %eax
addb $0x30, %al
movb %al, 0x2bd36d(%rip)     # 0x360528
movsd 0x65645(%rip), %xmm1    # 0x108808
callq 0x94d0
movsd 0x65638(%rip), %xmm2    # 0x108808
addsd %xmm0, %xmm2
movapd %xmm0, %xmm1
cmpltsd 0x4ff37(%rip), %xmm1    # 0xf3118
andpd %xmm1, %xmm2
andnpd %xmm0, %xmm1
orpd %xmm2, %xmm1
movapd %xmm1, -0x30(%rbp)
movsd 0x65616(%rip), %xmm1    # 0x108810
movapd -0x20(%rbp), %xmm0
callq 0x94d0
movsd 0x65604(%rip), %xmm2    # 0x108810
addsd %xmm0, %xmm2
movapd %xmm0, %xmm1
cmpltsd 0x4fefb(%rip), %xmm1    # 0xf3118
andpd %xmm1, %xmm2
andnpd %xmm0, %xmm1
orpd %xmm2, %xmm1
movapd %xmm1, %xmm3
movapd %xmm1, -0x20(%rbp)
movb %r14b, 0x2bd2f0(%rip)   # 0x360529
movapd -0x30(%rbp), %xmm0
movapd %xmm0, %xmm2
mulsd 0x5277e(%rip), %xmm2    # 0xf59c8
movsd 0x4fdee(%rip), %xmm1    # 0xf3040
mulsd %xmm1, %xmm2
cvttsd2si %xmm2, %eax
addb $0x41, %al
movb %al, 0x2bd2c8(%rip)     # 0x36052a
movapd %xmm3, %xmm2
mulsd 0x65592(%rip), %xmm2    # 0x108800
mulsd %xmm1, %xmm2
cvttsd2si %xmm2, %eax
addb $0x41, %al
movb %al, 0x2bd2ad(%rip)     # 0x36052b
movsd 0x65592(%rip), %xmm1    # 0x108818
callq 0x94d0
movsd 0x6558d(%rip), %xmm1    # 0x108820
movaps -0x20(%rbp), %xmm0
callq 0x94d0
movb $0x0, 0x2bd289(%rip)    # 0x36052c
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq