// File: /workspace/github_cpp_makefile_star2_O3/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 0x22c2ef(%rip), %rdi    # 0x30d930
leaq 0x22c2d8(%rip), %rbx    # 0x30d920
movq %rbx, %rsi
callq 0x9340
callq 0xe17ea
xorl %r14d, %r14d
testl %eax, %eax
jne 0xe16f3
cmpl $0x0, 0x2993a9(%rip)    # 0x37aa10
je 0xe1695
leaq 0x22c2b8(%rip), %rax    # 0x30d928
cmpb $0x0, (%rax)
je 0xe1688
leaq 0x22c2b4(%rip), %rdi    # 0x30d930
leaq 0x22c2a5(%rip), %rsi    # 0x30d928
callq 0x9340
movl 0x89195(%rip), %r14d    # 0x16a824
leal -0x1(%r14), %r15d
jmp 0xe16a0
movl 0x89188(%rip), %r15d    # 0x16a824
leal -0x1(%r15), %r14d
leaq 0x22bea1(%rip), %rax    # 0x30d548
movsd (%rax), %xmm0
xorl %edi, %edi
callq 0xd12da
leaq 0x22bfe3(%rip), %rax    # 0x30d69c
movl (%rax), %eax
cmpl 0x299343(%rip), %eax    # 0x37aa04
jl 0xe16ec
jne 0xe16e4
leaq 0x22bfd4(%rip), %rcx    # 0x30d6a0
movl 0x29932e(%rip), %edx    # 0x37aa00
cmpl %edx, (%rcx)
jl 0xe16ec
jne 0xe16e4
leaq 0x22bfc9(%rip), %rcx    # 0x30d6a8
cmpl %r15d, (%rcx)
jl 0xe16ec
cmpl 0x299322(%rip), %eax    # 0x37aa0c
jle 0xe1701
movl 0x29931d(%rip), %r14d   # 0x37aa10
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jne 0xe1722
leaq 0x22bf96(%rip), %rax    # 0x30d6a0
movl 0x2992f8(%rip), %ecx    # 0x37aa08
cmpl %ecx, (%rax)
jg 0xe16ec
jne 0xe1722
leaq 0x22bf8b(%rip), %rax    # 0x30d6a8
cmpl %r14d, (%rax)
jg 0xe16ec
cmpl $0x0, 0x2992e7(%rip)    # 0x37aa10
je 0xe1743
xorl %r14d, %r14d
cmpb $0x0, (%rbx)
je 0xe16f3
leaq 0x22c1f6(%rip), %rdi    # 0x30d930
leaq 0x22c1df(%rip), %rsi    # 0x30d920
jmp 0xe1763
leaq 0x22c1de(%rip), %rax    # 0x30d928
movl $0x1, %r14d
cmpb $0x0, (%rax)
je 0xe16f3
leaq 0x22c1d4(%rip), %rdi    # 0x30d930
leaq 0x22c1c5(%rip), %rsi    # 0x30d928
callq 0x9340
jmp 0xe16f3