// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: set_cs_time(char)
void set_cs_time(char mode)
{
double mjd;

   // sets the H5071 date and time from the system clock.
   // The 5071A must be in REMOTE mode for this to work
   if(read_only) return;

   if(rcvr_type == CS_RCVR) {
      need_cs_timeset = 0;
      get_clock_time();   // get system clock time in UTC

      if(mode == 'L') {  // set to local (displayed) time
         adjust_tz(987);
         clk_year = pri_year;
         clk_month = pri_month;
         clk_day = pri_day;
         clk_hours = pri_hours;
         clk_minutes = pri_minutes;
         clk_seconds = pri_seconds;
         clk_frac = pri_frac;
      }
      else if(mode == 'U') {  // set to UTC time
      }
      else return;

      mjd = jdate(clk_year,clk_month,clk_day) - JD_MJD;

      sprintf(out, "PTIM:TIME %d,%d,%d", clk_hours,clk_minutes,clk_seconds);
      send_polled_cmd(out, CS_TIME_MSG);

      sprintf(out, "PTIM:MJD %d", (int) (mjd+0.50));
      send_polled_cmd(out, CS_MJD_MSG);

      BEEP(511);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq 0x294900(%rip), %rax    # 0x33701a
cmpb $0x0, (%rax)
jne 0xa276d
leaq 0x1761aa(%rip), %rax    # 0x2188d0
cmpq $0x20000, (%rax)        # imm = 0x20000
jne 0xa276d
movl %edi, %ebx
leaq 0x1782d8(%rip), %rax    # 0x21aa10
movb $0x0, (%rax)
callq 0xa477
movsbl %bl, %eax
cmpl $0x4c, %eax
je 0xa2774
cmpl $0x55, %eax
jne 0xa276d
leaq 0x26af74(%rip), %rax    # 0x30d6c8
movl (%rax), %edi
leaq 0x26af63(%rip), %rax    # 0x30d6c0
movl (%rax), %esi
leaq 0x26af5e(%rip), %rax    # 0x30d6c4
movl (%rax), %edx
jmp 0xa2800
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movl $0x3db, %edi            # imm = 0x3DB
callq 0xe2692
leaq 0x26ad8f(%rip), %rax    # 0x30d514
movl (%rax), %edi
leaq 0x26af3a(%rip), %rax    # 0x30d6c8
movl %edi, (%rax)
leaq 0x26ad79(%rip), %rax    # 0x30d510
movl (%rax), %esi
leaq 0x26af20(%rip), %rax    # 0x30d6c0
movl %esi, (%rax)
leaq 0x26ad63(%rip), %rax    # 0x30d50c
movl (%rax), %edx
leaq 0x26af12(%rip), %rax    # 0x30d6c4
movl %edx, (%rax)
leaq 0x26ad4d(%rip), %rax    # 0x30d508
movl (%rax), %eax
leaq 0x26af08(%rip), %rcx    # 0x30d6cc
movl %eax, (%rcx)
leaq 0x26ad37(%rip), %rax    # 0x30d504
movl (%rax), %eax
leaq 0x26aefa(%rip), %rcx    # 0x30d6d0
movl %eax, (%rcx)
leaq 0x26ad21(%rip), %rax    # 0x30d500
movl (%rax), %eax
leaq 0x26aeec(%rip), %rcx    # 0x30d6d4
movl %eax, (%rcx)
leaq 0x26ad27(%rip), %rax    # 0x30d518
movsd (%rax), %xmm0
leaq 0x26aedc(%rip), %rax    # 0x30d6d8
movsd %xmm0, (%rax)
callq 0xd485e
addsd 0x69073(%rip), %xmm0    # 0x10b880
movsd %xmm0, -0x10(%rbp)
leaq 0x26aeb3(%rip), %rax    # 0x30d6cc
movl (%rax), %edx
leaq 0x26aeae(%rip), %rax    # 0x30d6d0
movl (%rax), %ecx
leaq 0x26aea9(%rip), %rax    # 0x30d6d4
movl (%rax), %r8d
leaq 0x2999eb(%rip), %rbx    # 0x33c220
leaq 0x83224(%rip), %rsi     # 0x125a60
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
movl $0x12c, %esi            # imm = 0x12C
callq 0x6e2d1
movsd -0x10(%rbp), %xmm0
addsd 0x66808(%rip), %xmm0    # 0x109068
cvttsd2si %xmm0, %edx
leaq 0x83208(%rip), %rsi     # 0x125a73
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
movl $0x12d, %esi            # imm = 0x12D
callq 0x6e2d1
movl $0x1ff, %edi            # imm = 0x1FF
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x9d78