// File: /workspace/github_cpp_makefile_star2_O1/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 0x294b1c(%rip), %rax    # 0x33701a
cmpb $0x0, (%rax)
jne 0xa267a
leaq 0x1763c2(%rip), %rax    # 0x2188d0
cmpq $0x20000, (%rax)        # imm = 0x20000
jne 0xa267a
movl %edi, %ebx
leaq 0x1784ec(%rip), %rax    # 0x21aa10
movb $0x0, (%rax)
callq 0xa495
movsbl %bl, %eax
cmpl $0x55, %eax
je 0xa25cd
cmpl $0x4c, %eax
jne 0xa267a
movl $0x3db, %edi            # imm = 0x3DB
callq 0xe1b3f
leaq 0x26afc2(%rip), %rax    # 0x30d514
movl (%rax), %eax
leaq 0x26b16d(%rip), %rcx    # 0x30d6c8
movl %eax, (%rcx)
leaq 0x26afac(%rip), %rax    # 0x30d510
movl (%rax), %eax
leaq 0x26b153(%rip), %rcx    # 0x30d6c0
movl %eax, (%rcx)
leaq 0x26af96(%rip), %rax    # 0x30d50c
movl (%rax), %eax
leaq 0x26b145(%rip), %rcx    # 0x30d6c4
movl %eax, (%rcx)
leaq 0x26af80(%rip), %rax    # 0x30d508
movl (%rax), %eax
leaq 0x26b13b(%rip), %rcx    # 0x30d6cc
movl %eax, (%rcx)
leaq 0x26af6a(%rip), %rax    # 0x30d504
movl (%rax), %eax
leaq 0x26b12d(%rip), %rcx    # 0x30d6d0
movl %eax, (%rcx)
leaq 0x26af54(%rip), %rax    # 0x30d500
movl (%rax), %eax
leaq 0x26b11f(%rip), %rcx    # 0x30d6d4
movl %eax, (%rcx)
leaq 0x26af5a(%rip), %rax    # 0x30d518
movsd (%rax), %xmm0
leaq 0x26b10f(%rip), %rax    # 0x30d6d8
movsd %xmm0, (%rax)
leaq 0x26b0f4(%rip), %rax    # 0x30d6c8
movl (%rax), %edi
leaq 0x26b0e3(%rip), %rax    # 0x30d6c0
movl (%rax), %esi
leaq 0x26b0de(%rip), %rax    # 0x30d6c4
movl (%rax), %edx
callq 0xd4110
addsd 0x6927b(%rip), %xmm0    # 0x10b870
movsd %xmm0, -0x10(%rbp)
leaq 0x26b0cb(%rip), %rax    # 0x30d6cc
movl (%rax), %edx
leaq 0x26b0c6(%rip), %rax    # 0x30d6d0
movl (%rax), %ecx
leaq 0x26b0c1(%rip), %rax    # 0x30d6d4
movl (%rax), %r8d
leaq 0x299c03(%rip), %rbx    # 0x33c220
leaq 0x8335c(%rip), %rsi     # 0x125980
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
movl $0x12c, %esi            # imm = 0x12C
callq 0x6e3bc
movsd -0x10(%rbp), %xmm0
addsd 0x66a20(%rip), %xmm0    # 0x109068
cvttsd2si %xmm0, %edx
leaq 0x83340(%rip), %rsi     # 0x125993
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9060
movq %rbx, %rdi
movl $0x12d, %esi            # imm = 0x12D
callq 0x6e3bc
movl $0x1ff, %edi            # imm = 0x1FF
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x9d80
addq $0x8, %rsp
popq %rbx
popq %rbp
retq