// File: /workspace/github_cpp_makefile_star2_O3/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 $0x118, %rsp            # imm = 0x118
leaq 0x1e4ac6(%rip), %rax    # 0x23ef00
movl (%rax), %ecx
leal 0x3(%rcx), %eax
addl $0x6, %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x2, %ecx
movq %rcx, -0x38(%rbp)
movl $0xffffff89, %r12d      # imm = 0xFFFFFF89
movl $0x560, %r13d           # imm = 0x560
leaq 0x1e4b4f(%rip), %rsi    # 0x23efb0
leaq -0x140(%rbp), %rbx
movl $0x0, -0x2c(%rbp)
xorl %r15d, %r15d
movl (%rsi,%r13), %eax
testl %eax, %eax
je 0x5a572
testb $0x3, %r15b
jne 0x5a4c1
movl %r15d, %ecx
sarl $0x2, %ecx
incl %ecx
leaq 0x1e4a6d(%rip), %rax    # 0x23ef00
movl (%rax), %r8d
leaq 0x2e1d83(%rip), %rdi    # 0x33c220
leaq 0xc5f2b(%rip), %rsi     # 0x1203cf
movq -0x38(%rbp), %rdx
xorl %eax, %eax
callq 0x9060
leaq -0x140(%rbp), %rbx
leaq 0x1e4af3(%rip), %rsi    # 0x23efb0
movl (%rsi,%r13), %eax
leal 0x78(%r12), %ecx
leal 0x21(%r12), %edx
leaq 0x1be3fe(%rip), %rdi    # 0x2188d0
cmpq $0x2, (%rdi)
cmovel %ecx, %edx
cmpl $0x20, %r12d
cmovael %ecx, %edx
cvttss2si -0xc(%rsi,%r13), %ecx
cvttss2si -0x10(%rsi,%r13), %r8d
testl %eax, %eax
jle 0x5a50f
cvttss2si -0x1f8(%rsi,%r13), %r9d
movq %rbx, %rdi
leaq 0xc5eda(%rip), %rsi     # 0x1203e0
xorl %eax, %eax
callq 0x9060
jmp 0x5a520
movq %rbx, %rdi
leaq 0xc5edc(%rip), %rsi     # 0x1203f5
xorl %eax, %eax
callq 0x9060
leaq 0x2e1cf9(%rip), %r14    # 0x33c220
movq %r14, %rdi
movq %rbx, %rsi
callq 0x96c0
incl %r15d
testb $0x3, %r15b
je 0x5a54b
leaq 0x1e4a6e(%rip), %rsi    # 0x23efb0
leaq -0x140(%rbp), %rbx
jmp 0x5a572
movq %r14, %rdi
callq 0x5962f
movb $0x0, (%r14)
movl -0x2c(%rbp), %eax
incl %eax
movl %eax, -0x2c(%rbp)
cmpl -0x38(%rbp), %eax
leaq 0x1e4a47(%rip), %rsi    # 0x23efb0
leaq -0x140(%rbp), %rbx
jge 0x5a589
incl %r12d
addq $0x348, %r13            # imm = 0x348
cmpq $0xcd358, %r13          # imm = 0xCD358
jne 0x5a472
leal 0x3(%r15), %eax
testl %r15d, %r15d
cmovnsl %r15d, %eax
andl $-0x4, %eax
subl %eax, %r15d
je 0x5a5dd
addl $-0x4, %r15d
leaq 0x2e1c79(%rip), %rbx    # 0x33c220
movq %rbx, %rdi
callq 0x9120
movl $0x2c2c2c2c, (%rbx,%rax) # imm = 0x2C2C2C2C
movb $0x0, 0x4(%rbx,%rax)
incl %r15d
jne 0x5a5a7
leaq 0x2e1c59(%rip), %rdi    # 0x33c220
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5962f
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq