// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
leaq 0x1d5c0a(%rip), %rax    # 0x228f00
movl (%rax), %eax
addl $0x3, %eax
pushq $0x4
popq %rcx
cltd
idivl %ecx
movl %eax, -0x30(%rbp)
pushq $-0x77
popq %r13
movl $0x560, %r14d           # imm = 0x560
leaq 0x1d5c9b(%rip), %rsi    # 0x228fb0
leaq -0x130(%rbp), %rbx
xorl %r12d, %r12d
movl $0x0, -0x2c(%rbp)
cmpq $0xcd358, %r14          # imm = 0xCD358
je 0x5343f
movl (%rsi,%r14), %eax
testl %eax, %eax
je 0x53430
testb $0x3, %r12b
jne 0x53381
movl %r12d, %ecx
sarl $0x2, %ecx
incl %ecx
leaq 0x1d5bac(%rip), %rax    # 0x228f00
movl (%rax), %r8d
leaq 0x2d2ec2(%rip), %rdi    # 0x326220
leaq 0xb6fb2(%rip), %rsi     # 0x10a317
movl -0x30(%rbp), %edx
xorl %eax, %eax
callq 0x9060
leaq -0x130(%rbp), %rbx
leaq 0x1d5c33(%rip), %rsi    # 0x228fb0
movl (%rsi,%r14), %eax
leal 0x78(%r13), %ecx
leal 0x21(%r13), %edx
leaq 0x1af540(%rip), %rdi    # 0x2028d0
cmpq $0x2, (%rdi)
cmovel %ecx, %edx
cmpl $0x20, %r13d
cmovael %ecx, %edx
cvttss2si -0xc(%rsi,%r14), %ecx
cvttss2si -0x10(%rsi,%r14), %r8d
testl %eax, %eax
jle 0x533cd
cvttss2si -0x1f8(%rsi,%r14), %r9d
movq %rbx, %rdi
leaq 0xb6f64(%rip), %rsi     # 0x10a328
xorl %eax, %eax
callq 0x9060
jmp 0x533de
movq %rbx, %rdi
leaq 0xb6f66(%rip), %rsi     # 0x10a33d
xorl %eax, %eax
callq 0x9060
leaq 0x2d2e3b(%rip), %r15    # 0x326220
movq %r15, %rdi
movq %rbx, %rsi
callq 0x96c0
incl %r12d
testb $0x3, %r12b
je 0x53409
leaq 0x1d5bb0(%rip), %rsi    # 0x228fb0
leaq -0x130(%rbp), %rbx
jmp 0x53430
movq %r15, %rdi
callq 0x52935
movb $0x0, (%r15)
movl -0x2c(%rbp), %eax
incl %eax
movl %eax, -0x2c(%rbp)
cmpl -0x30(%rbp), %eax
leaq 0x1d5b89(%rip), %rsi    # 0x228fb0
leaq -0x130(%rbp), %rbx
jge 0x5343f
incl %r13d
addq $0x348, %r14            # imm = 0x348
jmp 0x53326
movl %r12d, %eax
cltd
pushq $0x4
popq %rcx
idivl %ecx
testl %edx, %edx
je 0x53495
movl %edx, %r14d
addl $-0x4, %r14d
leaq 0x2d2dc6(%rip), %rbx    # 0x326220
testl %r14d, %r14d
je 0x53478
movq %rbx, %rdi
callq 0x9120
movl $0x2c2c2c2c, (%rbx,%rax) # imm = 0x2C2C2C2C
movb $0x0, 0x4(%rbx,%rax)
incl %r14d
jmp 0x5345a
leaq 0x2d2da1(%rip), %rdi    # 0x326220
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x52935
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq