// File: jkingan[P]ladyheather/heathgps.cpp
// Function: send_gsv()
void send_gsv()
{
int num_msgs;
int prn;
int i;
int msg_num;
char s[256];
int seen, tracked;

   // send NMEA GPGSV sky view sentences
   // !!!!!! we should handle GLONASS/GALILEO/BEIDOU

   num_msgs = (track_count + 3) / 4;
   i = 0;
   msg_num = 0;

   seen = tracked = 0;
   for(prn=1; prn<=MAX_PRN; prn++) {
      if(sat[prn].tracking) {
         ++seen;
         if((i%4) == 0) {  // start of new sentence
            sprintf(out, "GPGSV,%d,%d,%02d", num_msgs,(i/4)+1,track_count);
         }

         if(sat[prn].tracking > 0) {  // tracked sat
            sprintf(s, ",%02d,%02d,%03d,%02d",nmea_prn(prn),(int)sat[prn].elevation,(int)sat[prn].azimuth,(int)sat[prn].sig_level);
            ++tracked;
         }
         else {  // untracked sat
            sprintf(s, ",%02d,%02d,%03d,",nmea_prn(prn),(int)sat[prn].elevation,(int)sat[prn].azimuth);
         }
         strcat(out, s);
         
         ++i;
         if((i%4) == 0) {  // 4 sats per message
            echo_nmea_string(out);
            out[0] = 0;
            ++msg_num;
            if(msg_num >= num_msgs) break;
         }
      }
   }

   i = i%4;
   if(i) {  // fill out last message with null fields
      i = 4-i;
      while(i--) {
         strcat(out, ",,,,");   
      }
      echo_nmea_string(out);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
leaq 0x2218ae(%rip), %rax    # 0x29e0e0
movl (%rax), %eax
addl $0x3, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, -0x4(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movl $0x0, -0x118(%rbp)
movl $0x0, -0x114(%rbp)
movl $0x1, -0x8(%rbp)
cmpl $0x3e7, -0x8(%rbp)      # imm = 0x3E7
jg 0x7ca7e
movslq -0x8(%rbp), %rcx
leaq 0x22190d(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
cmpl $0x0, 0x218(%rax)
je 0x7ca6e
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
movl -0xc(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x7c8f7
movl -0x4(%rbp), %eax
movl %eax, -0x11c(%rbp)
movl -0xc(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl -0x11c(%rbp), %edx
movl %eax, %ecx
addl $0x1, %ecx
leaq 0x221801(%rip), %rax    # 0x29e0e0
movl (%rax), %r8d
leaq 0x31eb17(%rip), %rdi    # 0x39b400
leaq 0x106d5f(%rip), %rsi    # 0x18364f
movb $0x0, %al
callq 0x9060
movslq -0x8(%rbp), %rcx
leaq 0x22188e(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
cmpl $0x0, 0x218(%rax)
jle 0x7c9ad
leaq -0x110(%rbp), %rax
movq %rax, -0x128(%rbp)
movl -0x8(%rbp), %edi
callq 0x7ba80
movq -0x128(%rbp), %rdi
movl %eax, %edx
movslq -0x8(%rbp), %rcx
leaq 0x22184d(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
cvttss2si 0x20c(%rax), %ecx
movslq -0x8(%rbp), %rsi
leaq 0x221830(%rip), %rax    # 0x29e190
imulq $0x348, %rsi, %rsi      # imm = 0x348
addq %rsi, %rax
cvttss2si 0x208(%rax), %r8d
movslq -0x8(%rbp), %rsi
leaq 0x221812(%rip), %rax    # 0x29e190
imulq $0x348, %rsi, %rsi      # imm = 0x348
addq %rsi, %rax
cvttss2si 0x20(%rax), %r9d
leaq 0x106ccb(%rip), %rsi    # 0x183660
movb $0x0, %al
callq 0x9060
movl -0x118(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x118(%rbp)
jmp 0x7ca15
leaq -0x110(%rbp), %rax
movq %rax, -0x130(%rbp)
movl -0x8(%rbp), %edi
callq 0x7ba80
movq -0x130(%rbp), %rdi
movl %eax, %edx
movslq -0x8(%rbp), %rcx
leaq 0x2217b9(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
cvttss2si 0x20c(%rax), %ecx
movslq -0x8(%rbp), %rsi
leaq 0x22179c(%rip), %rax    # 0x29e190
imulq $0x348, %rsi, %rsi      # imm = 0x348
addq %rsi, %rax
cvttss2si 0x208(%rax), %r8d
leaq 0x106c67(%rip), %rsi    # 0x183675
movb $0x0, %al
callq 0x9060
leaq -0x110(%rbp), %rsi
leaq 0x31e9dd(%rip), %rdi    # 0x39b400
callq 0x96a0
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x7ca6c
leaq 0x31e9b8(%rip), %rdi    # 0x39b400
callq 0x7bad0
leaq 0x31e9ac(%rip), %rax    # 0x39b400
movb $0x0, (%rax)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x4(%rbp), %eax
jl 0x7ca6a
jmp 0x7ca7e
jmp 0x7ca6c
jmp 0x7ca6e
jmp 0x7ca70
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x7c86b
movl -0xc(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %edx, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x7cace
movl $0x4, %eax
subl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0xc(%rbp)
cmpl $0x0, %eax
je 0x7cac2
leaq 0x31e94c(%rip), %rdi    # 0x39b400
leaq 0x106bcb(%rip), %rsi    # 0x183686
callq 0x96a0
jmp 0x7ca9d
leaq 0x31e937(%rip), %rdi    # 0x39b400
callq 0x7bad0
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopw (%rax,%rax)