// File: /workspace/github_c_makefile_star2_O0/skeeto[P]flappy/sqlite3.c
// Function: localtimeOffset
static sqlite3_int64 localtimeOffset(
  DateTime *p,                    /* Date at which to calculate offset */
  sqlite3_context *pCtx,          /* Write error here if one occurs */
  int *pRc                        /* OUT: Error code. SQLITE_OK or ERROR */
){
  DateTime x, y;
  time_t t;
  struct tm sLocal;

  /* Initialize the contents of sLocal to avoid a compiler warning. */
  memset(&sLocal, 0, sizeof(sLocal));

  x = *p;
  computeYMD_HMS(&x);
  if( x.Y<1971 || x.Y>=2038 ){
    /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only
    ** works for years between 1970 and 2037. For dates outside this range,
    ** SQLite attempts to map the year into an equivalent year within this
    ** range, do the calculation, then map the year back.
    */
    x.Y = 2000;
    x.M = 1;
    x.D = 1;
    x.h = 0;
    x.m = 0;
    x.s = 0.0;
  } else {
    int s = (int)(x.s + 0.5);
    x.s = s;
  }
  x.tz = 0;
  x.validJD = 0;
  computeJD(&x);
  t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);
  if( osLocaltime(&t, &sLocal) ){
    sqlite3_result_error(pCtx, "local time unavailable", -1);
    *pRc = SQLITE_ERROR;
    return 0;
  }
  y.Y = sLocal.tm_year + 1900;
  y.M = sLocal.tm_mon + 1;
  y.D = sLocal.tm_mday;
  y.h = sLocal.tm_hour;
  y.m = sLocal.tm_min;
  y.s = sLocal.tm_sec;
  y.validYMD = 1;
  y.validHMS = 1;
  y.validJD = 0;
  y.validTZ = 0;
  computeJD(&y);
  *pRc = SQLITE_OK;
  return y.iJD - x.iJD;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x71a0
movq -0x10(%rbp), %rsi
leaq -0x50(%rbp), %rdi
movl $0x30, %edx
callq 0x7260
leaq -0x50(%rbp), %rdi
callq 0x91600
cmpl $0x7b3, -0x48(%rbp)     # imm = 0x7B3
jl 0x91487
cmpl $0x7f6, -0x48(%rbp)     # imm = 0x7F6
jl 0x914b4
movl $0x7d0, -0x48(%rbp)     # imm = 0x7D0
movl $0x1, -0x44(%rbp)
movl $0x1, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
jmp 0x914d8
movsd 0x7664(%rip), %xmm0     # 0x98b20
addsd -0x30(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xc4(%rbp)
cvtsi2sdl -0xc4(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movb $0x0, -0x26(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x8fe60
movq -0x50(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movabsq $0x3118a36940, %rcx     # imm = 0x3118A36940
subq %rcx, %rax
movq %rax, -0x88(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x917c0
cmpl $0x0, %eax
je 0x9154f
movq -0x18(%rbp), %rdi
leaq 0xb490(%rip), %rsi      # 0x9c9c1
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x13930
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0x915c0
movl -0xac(%rbp), %eax
addl $0x76c, %eax            # imm = 0x76C
movl %eax, -0x78(%rbp)
movl -0xb0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movl -0xb4(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0xb8(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0xbc(%rbp), %eax
movl %eax, -0x68(%rbp)
cvtsi2sdl -0xc0(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movb $0x1, -0x58(%rbp)
movb $0x1, -0x57(%rbp)
movb $0x0, -0x56(%rbp)
movb $0x0, -0x55(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x8fe60
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x80(%rbp), %rax
subq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)