#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int time_t;

/* Variables and functions */
int /*<<< orphan*/ gmtime(int *);
int /*<<< orphan*/ localtime(int *);
int mktime(int /*<<< orphan*/);
int time(int /*<<< orphan*/ *);
double LocalTZA(void) {
  static int once = 1;
  static double tza = 0;
  if (once) {
    time_t now = time(NULL);
    time_t utc = mktime(gmtime(&now));
    time_t loc = mktime(localtime(&now));
    tza = (loc - utc) * 1000;
    once = 0;
  }
  return tza;
}


x86 assembly (clang, -O0):
<LocalTZA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpl   $0x0,0x2ef1(%rip)
je     11a9 <LocalTZA+0x69>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1060 <gmtime@plt>
mov    %eax,%edi
call   1050 <mktime@plt>
mov    %eax,-0x8(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1050 <mktime@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
imul   $0x3e8,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x2eb1(%rip)
movl   $0x0,0x2e97(%rip)
movsd  0x2e9f(%rip),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LocalTZA>:
push   %rbp
push   %rbx
push   %rax
cmpb   $0x1,0x2efe(%rip)
jne    1156 <LocalTZA+0x16>
movsd  0x2efc(%rip),%xmm0
jmp    11a1 <LocalTZA+0x61>
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <gmtime@plt>
mov    %eax,%edi
call   1050 <mktime@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1050 <mktime@plt>
sub    %ebp,%eax
imul   $0x3e8,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x2eb6(%rip)
movb   $0x1,0x2ea7(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@LocalTZA.once = internal global i32 1
@LocalTZA.tza = internal global double 0.000000e+00
define double @LocalTZA() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = load i32, i32* @LocalTZA.once
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %0
%7 = call i32 @time(i32* null)
store i32 %7, i32* %1
%8 = call i32 @gmtime(i32* %1)
%9 = call i32 @mktime(i32 %8)
store i32 %9, i32* %2
%10 = call i32 @localtime(i32* %1)
%11 = call i32 @mktime(i32 %10)
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = sub nsw i32 %12, %13
%15 = mul nsw i32 %14, 1000
%16 = sitofp i32 %15 to double
store double %16, double* @LocalTZA.tza
store i32 0, i32* @LocalTZA.once
br label %17
17: ; preds = %6, %0
%18 = load double, double* @LocalTZA.tza
ret double %18
}

LLVM IR (-O2):
@LocalTZA.once = internal unnamed_addr global i1 false
@LocalTZA.tza = internal unnamed_addr global double 0.000000e+00
define double @LocalTZA() {
%1 = alloca i32
%2 = load i1, i1* @LocalTZA.once
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = load double, double* @LocalTZA.tza
br label %15
5: ; preds = %0
%6 = bitcast i32* %1 to i8*
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %1
%8 = call i32 @gmtime(i32* %1)
%9 = call i32 @mktime(i32 %8)
%10 = call i32 @localtime(i32* %1)
%11 = call i32 @mktime(i32 %10)
%12 = sub nsw i32 %11, %9
%13 = mul nsw i32 %12, 1000
%14 = sitofp i32 %13 to double
store double %14, double* @LocalTZA.tza
store i1 true, i1* @LocalTZA.once
br label %15
15: ; preds = %3, %5
%16 = phi double [ %4, %3 ], [ %14, %5 ]
ret double %16
}