// File: /workspace/github_cpp_makefile_star2_O1/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 0x22ce29(%rip), %rdi    # 0x30d930
leaq 0x22ce12(%rip), %rbx    # 0x30d920
movq %rbx, %rsi
callq 0x9340
callq 0xe0cb0
xorl %r14d, %r14d
testl %eax, %eax
jne 0xe0bb9
cmpl $0x0, 0x299ee3(%rip)    # 0x37aa10
je 0xe0b5b
leaq 0x22cdf2(%rip), %rax    # 0x30d928
cmpb $0x0, (%rax)
je 0xe0b4e
leaq 0x22cdee(%rip), %rdi    # 0x30d930
leaq 0x22cddf(%rip), %rsi    # 0x30d928
callq 0x9340
movl 0x89ccf(%rip), %r14d    # 0x16a824
leal -0x1(%r14), %r15d
jmp 0xe0b66
movl 0x89cc2(%rip), %r15d    # 0x16a824
leal -0x1(%r15), %r14d
leaq 0x22c9db(%rip), %rax    # 0x30d548
movsd (%rax), %xmm0
xorl %edi, %edi
callq 0xd0c46
leaq 0x22cb1d(%rip), %rax    # 0x30d69c
movl (%rax), %eax
cmpl 0x299e7d(%rip), %eax    # 0x37aa04
jl 0xe0bb2
jne 0xe0baa
leaq 0x22cb0e(%rip), %rcx    # 0x30d6a0
movl 0x299e68(%rip), %edx    # 0x37aa00
cmpl %edx, (%rcx)
jl 0xe0bb2
jne 0xe0baa
leaq 0x22cb03(%rip), %rcx    # 0x30d6a8
cmpl %r15d, (%rcx)
jl 0xe0bb2
cmpl 0x299e5c(%rip), %eax    # 0x37aa0c
jle 0xe0bc7
movl 0x299e57(%rip), %r14d   # 0x37aa10
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jne 0xe0be8
leaq 0x22cad0(%rip), %rax    # 0x30d6a0
movl 0x299e32(%rip), %ecx    # 0x37aa08
cmpl %ecx, (%rax)
jg 0xe0bb2
jne 0xe0be8
leaq 0x22cac5(%rip), %rax    # 0x30d6a8
cmpl %r14d, (%rax)
jg 0xe0bb2
cmpl $0x0, 0x299e21(%rip)    # 0x37aa10
je 0xe0c09
xorl %r14d, %r14d
cmpb $0x0, (%rbx)
je 0xe0bb9
leaq 0x22cd30(%rip), %rdi    # 0x30d930
leaq 0x22cd19(%rip), %rsi    # 0x30d920
jmp 0xe0c29
leaq 0x22cd18(%rip), %rax    # 0x30d928
movl $0x1, %r14d
cmpb $0x0, (%rax)
je 0xe0bb9
leaq 0x22cd0e(%rip), %rdi    # 0x30d930
leaq 0x22ccff(%rip), %rsi    # 0x30d928
callq 0x9340
jmp 0xe0bb9