// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathmsc.cpp
// Function: dst_offset()
int dst_offset()
{
int before_switch_hour;
int after_switch_hour;

   // calculate time zone adjustment for daylight savings time settings
   strcpy(tz_string, std_string);  // assume dst not in effect

   if(dst_disabled()) {   // dst switchover times not set, use standard time
      return 0;
   }

   if(down_under) {  // southern hemisphere spins backwards
      if(dst_string[0]) strcpy(tz_string, dst_string);
      before_switch_hour = dst_hour-1;
      after_switch_hour = dst_hour;
   }
   else {
      before_switch_hour = dst_hour;
      after_switch_hour = dst_hour-1;
   }

   // see if it is before dst start time
   gregorian(0, jd_local);
//sprintf(debug_text,  "local:%04d/%02d/%02d %02d:", g_year,g_month,g_day, g_hours);
//sprintf(debug_text2, "start:%04d/%02d/%02d %02d:", g_year,dst_start_month,dst_start_day,before_switch_hour);
//sprintf(debug_text3, "end:  %04d/%02d/%02d %02d:", g_year,dst_end_month,dst_end_day,after_switch_hour);


   if(g_month < dst_start_month) {
      return down_under;
   }
   else if(g_month == dst_start_month) {
      if(g_day < dst_start_day)  {
         return down_under; 
      }
      else if(g_day == dst_start_day) {
         if(g_hours < before_switch_hour) {
            return down_under;
         }
      }
   }
   
   // it is after dst start time,  is it before dst end time?
   if(g_month > dst_end_month) {
      return down_under; 
   }
   else if(g_month == dst_end_month) {
      if(g_day > dst_end_day) {
         return down_under; 
      }
      else if(g_day == dst_end_day) {
         if(g_hours > after_switch_hour) {
//sprintf(debug_text4, "x6  gh:%d  ash:%d", g_hours,after_switch_hour);
            return down_under; 
         }
      }
   }
//sprintf(debug_text5, "down under:%d", down_under);

   if(down_under) { // daylight savings time is not in effect
      if(std_string[0]) strcpy(tz_string, std_string);
//sprintf(debug_text6, "dst off");
      return 0;
   }
   else {           // daylight savings time is in effect
      if(dst_string[0]) strcpy(tz_string, dst_string);
//sprintf(debug_text6, "dst on");
      return 1;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0x229430(%rip), %rdi    # 0x2f7930
leaq 0x229419(%rip), %rbx    # 0x2f7920
movq %rbx, %rsi
callq 0x9330
callq 0xce6a7
xorl %r14d, %r14d
testl %eax, %eax
jne 0xce5b2
cmpl $0x0, 0x2964ea(%rip)    # 0x364a10
je 0xce554
leaq 0x2293f9(%rip), %rax    # 0x2f7928
cmpb $0x0, (%rax)
je 0xce547
leaq 0x2293f5(%rip), %rdi    # 0x2f7930
leaq 0x2293e6(%rip), %rsi    # 0x2f7928
callq 0x9330
movl 0x862d6(%rip), %r14d    # 0x154824
leal -0x1(%r14), %r15d
jmp 0xce55f
movl 0x862c9(%rip), %r15d    # 0x154824
leal -0x1(%r15), %r14d
leaq 0x228fe2(%rip), %rax    # 0x2f7548
movsd (%rax), %xmm0
xorl %edi, %edi
callq 0xbfac2
leaq 0x229124(%rip), %rax    # 0x2f769c
movl (%rax), %eax
cmpl 0x296484(%rip), %eax    # 0x364a04
jl 0xce5ab
jne 0xce5a3
leaq 0x229115(%rip), %rcx    # 0x2f76a0
movl 0x29646f(%rip), %edx    # 0x364a00
cmpl %edx, (%rcx)
jl 0xce5ab
jne 0xce5a3
leaq 0x22910a(%rip), %rcx    # 0x2f76a8
cmpl %r15d, (%rcx)
jl 0xce5ab
cmpl 0x296463(%rip), %eax    # 0x364a0c
jle 0xce5c0
movl 0x29645e(%rip), %r14d   # 0x364a10
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jne 0xce5e1
leaq 0x2290d7(%rip), %rax    # 0x2f76a0
movl 0x296439(%rip), %ecx    # 0x364a08
cmpl %ecx, (%rax)
jg 0xce5ab
jne 0xce5e1
leaq 0x2290cc(%rip), %rax    # 0x2f76a8
cmpl %r14d, (%rax)
jg 0xce5ab
cmpl $0x0, 0x296428(%rip)    # 0x364a10
je 0xce602
xorl %r14d, %r14d
cmpb $0x0, (%rbx)
je 0xce5b2
leaq 0x229337(%rip), %rdi    # 0x2f7930
leaq 0x229320(%rip), %rsi    # 0x2f7920
jmp 0xce620
leaq 0x22931f(%rip), %rax    # 0x2f7928
pushq $0x1
popq %r14
cmpb $0x0, (%rax)
je 0xce5b2
leaq 0x229317(%rip), %rdi    # 0x2f7930
leaq 0x229308(%rip), %rsi    # 0x2f7928
callq 0x9330
jmp 0xce5b2