// File: 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
subq $0x10, %rsp
leaq 0x238d7d(%rip), %rdi    # 0x36cb0c
leaq 0x238d6a(%rip), %rsi    # 0x36cb00
callq 0x9350
callq 0x134050
cmpl $0x0, %eax
je 0x133db1
movl $0x0, -0x4(%rbp)
jmp 0x133f73
cmpl $0x0, 0x2a5ec0(%rip)    # 0x3d9c78
je 0x133df0
leaq 0x238d45(%rip), %rax    # 0x36cb06
cmpb $0x0, (%rax)
je 0x133dd9
leaq 0x238d3f(%rip), %rdi    # 0x36cb0c
leaq 0x238d32(%rip), %rsi    # 0x36cb06
callq 0x9350
movl 0x95a49(%rip), %eax     # 0x1c9828
subl $0x1, %eax
movl %eax, -0x8(%rbp)
movl 0x95a3d(%rip), %eax     # 0x1c9828
movl %eax, -0xc(%rbp)
jmp 0x133e05
movl 0x95a32(%rip), %eax     # 0x1c9828
movl %eax, -0x8(%rbp)
movl 0x95a29(%rip), %eax     # 0x1c9828
subl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x23891c(%rip), %rax    # 0x36c728
movsd (%rax), %xmm0
xorl %edi, %edi
callq 0x11dd00
leaq 0x238a5e(%rip), %rax    # 0x36c87c
movl (%rax), %eax
cmpl 0x2a5e46(%rip), %eax    # 0x3d9c6c
jge 0x133e36
movl 0x2a5e4a(%rip), %eax    # 0x3d9c78
movl %eax, -0x4(%rbp)
jmp 0x133f73
leaq 0x238a3f(%rip), %rax    # 0x36c87c
movl (%rax), %eax
cmpl 0x2a5e27(%rip), %eax    # 0x3d9c6c
jne 0x133e99
leaq 0x238a32(%rip), %rax    # 0x36c880
movl (%rax), %eax
cmpl 0x2a5e12(%rip), %eax    # 0x3d9c68
jge 0x133e66
movl 0x2a5e1a(%rip), %eax    # 0x3d9c78
movl %eax, -0x4(%rbp)
jmp 0x133f73
leaq 0x238a13(%rip), %rax    # 0x36c880
movl (%rax), %eax
cmpl 0x2a5df3(%rip), %eax    # 0x3d9c68
jne 0x133e95
leaq 0x238a0a(%rip), %rax    # 0x36c888
movl (%rax), %eax
cmpl -0x8(%rbp), %eax
jge 0x133e93
movl 0x2a5ded(%rip), %eax    # 0x3d9c78
movl %eax, -0x4(%rbp)
jmp 0x133f73
jmp 0x133e95
jmp 0x133e97
jmp 0x133e99
jmp 0x133e9b
leaq 0x2389da(%rip), %rax    # 0x36c87c
movl (%rax), %eax
cmpl 0x2a5dca(%rip), %eax    # 0x3d9c74
jle 0x133eba
movl 0x2a5dc6(%rip), %eax    # 0x3d9c78
movl %eax, -0x4(%rbp)
jmp 0x133f73
leaq 0x2389bb(%rip), %rax    # 0x36c87c
movl (%rax), %eax
cmpl 0x2a5dab(%rip), %eax    # 0x3d9c74
jne 0x133f1a
leaq 0x2389ae(%rip), %rax    # 0x36c880
movl (%rax), %eax
cmpl 0x2a5d96(%rip), %eax    # 0x3d9c70
jle 0x133eea
movl 0x2a5d96(%rip), %eax    # 0x3d9c78
movl %eax, -0x4(%rbp)
jmp 0x133f73
leaq 0x23898f(%rip), %rax    # 0x36c880
movl (%rax), %eax
cmpl 0x2a5d77(%rip), %eax    # 0x3d9c70
jne 0x133f16
leaq 0x238986(%rip), %rax    # 0x36c888
movl (%rax), %eax
cmpl -0xc(%rbp), %eax
jle 0x133f14
movl 0x2a5d69(%rip), %eax    # 0x3d9c78
movl %eax, -0x4(%rbp)
jmp 0x133f73
jmp 0x133f16
jmp 0x133f18
jmp 0x133f1a
jmp 0x133f1c
cmpl $0x0, 0x2a5d55(%rip)    # 0x3d9c78
je 0x133f4d
leaq 0x238bd4(%rip), %rax    # 0x36cb00
cmpb $0x0, (%rax)
je 0x133f44
leaq 0x238bd4(%rip), %rdi    # 0x36cb0c
leaq 0x238bc1(%rip), %rsi    # 0x36cb00
callq 0x9350
movl $0x0, -0x4(%rbp)
jmp 0x133f73
leaq 0x238bb2(%rip), %rax    # 0x36cb06
cmpb $0x0, (%rax)
je 0x133f6c
leaq 0x238bac(%rip), %rdi    # 0x36cb0c
leaq 0x238b9f(%rip), %rsi    # 0x36cb06
callq 0x9350
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)