// File: /workspace/github_cpp_makefile_star2_O1/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 0x1e4a18(%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 0x1e4aa1(%rip), %r14    # 0x23efb0
leaq -0x140(%rbp), %rbx
movl $0x0, -0x2c(%rbp)
xorl %r15d, %r15d
cmpl $0x0, (%r14,%r13)
je 0x5a617
testb $0x3, %r15b
jne 0x5a563
movl %r15d, %ecx
sarl $0x2, %ecx
incl %ecx
leaq 0x1e49c0(%rip), %rax    # 0x23ef00
movl (%rax), %r8d
leaq 0x2e1cd6(%rip), %rdi    # 0x33c220
leaq 0xc5d9e(%rip), %rsi     # 0x1202ef
movq -0x38(%rbp), %rdx
xorl %eax, %eax
callq 0x9060
leaq -0x140(%rbp), %rbx
leal 0x21(%r12), %edx
leaq 0x1be361(%rip), %rax    # 0x2188d0
cmpq $0x2, (%rax)
leal 0x78(%r12), %eax
cmovel %eax, %edx
cmpl $0x20, %r12d
cmovael %eax, %edx
cmpl $0x0, (%r14,%r13)
cvttss2si -0xc(%r14,%r13), %ecx
cvttss2si -0x10(%r14,%r13), %r8d
jle 0x5a5b4
cvttss2si -0x1f8(%r14,%r13), %r9d
movq %rbx, %rdi
leaq 0xc5d55(%rip), %rsi     # 0x120300
xorl %eax, %eax
callq 0x9060
jmp 0x5a5c5
movq %rbx, %rdi
leaq 0xc5d57(%rip), %rsi     # 0x120315
xorl %eax, %eax
callq 0x9060
leaq 0x2e1c54(%rip), %r14    # 0x33c220
movq %r14, %rdi
movq %rbx, %rsi
callq 0x96c0
incl %r15d
testb $0x3, %r15b
je 0x5a5f0
leaq 0x1e49c9(%rip), %r14    # 0x23efb0
leaq -0x140(%rbp), %rbx
jmp 0x5a617
movq %r14, %rdi
callq 0x596f9
movb $0x0, (%r14)
movl -0x2c(%rbp), %eax
incl %eax
movl %eax, -0x2c(%rbp)
cmpl -0x38(%rbp), %eax
leaq 0x1e49a2(%rip), %r14    # 0x23efb0
leaq -0x140(%rbp), %rbx
jge 0x5a62e
incl %r12d
addq $0x348, %r13            # imm = 0x348
cmpq $0xcd358, %r13          # imm = 0xCD358
jne 0x5a520
leal 0x3(%r15), %eax
testl %r15d, %r15d
cmovnsl %r15d, %eax
andl $-0x4, %eax
subl %eax, %r15d
je 0x5a682
addl $-0x4, %r15d
leaq 0x2e1bd4(%rip), %rbx    # 0x33c220
movq %rbx, %rdi
callq 0x9120
movl $0x2c2c2c2c, (%rbx,%rax) # imm = 0x2C2C2C2C
movb $0x0, 0x4(%rbx,%rax)
incl %r15d
jne 0x5a64c
leaq 0x2e1bb4(%rip), %rdi    # 0x33c220
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x596f9
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq