#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;
struct tm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ localtime_r(int *, struct tm *);
int tm_to_time_t(struct tm *);
int local_tzoffset(unsigned long time) {
  time_t t, t_local;
  struct tm tm;
  int offset, eastwest;
  t = time;
  localtime_r(&t, &tm);
  t_local = tm_to_time_t(&tm);
  if (t_local < t) {
    eastwest = -1;
    offset = t - t_local;
  } else {
    eastwest = 1;
    offset = t_local - t;
  }
  offset /= 60;
  offset = (offset % 60) + ((offset / 60) * 100);
  return offset * eastwest;
}


x86 assembly (clang, -O0):
<local_tzoffset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <localtime_r@plt>
lea    -0x18(%rbp),%rdi
call   1040 <tm_to_time_t@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116d <local_tzoffset+0x4d>
movl   $0xffffffff,-0x20(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    117d <local_tzoffset+0x5d>
movl   $0x1,-0x20(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    -0x24(%rbp),%edx
imul   $0x64,%eax,%eax
add    %eax,%edx
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<local_tzoffset>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,0x4(%rsp)
lea    0x4(%rsp),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <localtime_r@plt>
mov    %rbx,%rdi
call   1040 <tm_to_time_t@plt>
mov    0x4(%rsp),%edx
mov    %eax,%ecx
sub    %edx,%ecx
neg    %ecx
mov    %eax,%esi
sub    %edx,%esi
cmovl  %ecx,%esi
movslq %esi,%rcx
imul   $0xffffffff88888889,%rcx,%rsi
shr    $0x20,%rsi
add    %ecx,%esi
mov    %esi,%edi
shr    $0x1f,%edi
sar    $0x5,%esi
add    %edi,%esi
movslq %esi,%rsi
imul   $0xffffffff88888889,%rsi,%rdi
shr    $0x20,%rdi
add    %esi,%edi
mov    %edi,%ebx
shr    $0x1f,%ebx
sar    $0x5,%edi
add    %ebx,%edi
imul   $0x3c,%edi,%edi
sub    %edi,%esi
imul   $0xffffffff91a2b3c5,%rcx,%rdi
shr    $0x20,%rdi
add    %ecx,%edi
mov    %edi,%ecx
shr    $0x1f,%ecx
sar    $0xb,%edi
add    %ecx,%edi
imul   $0x64,%edi,%edi
add    %esi,%edi
mov    %edi,%ecx
neg    %ecx
cmp    %edx,%eax
cmovge %edi,%ecx
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
define i32 @local_tzoffset(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.tm
%6 = alloca i32
%7 = alloca i32
store i64 %0, i64* %2
%8 = load i64, i64* %2
%9 = trunc i64 %8 to i32
store i32 %9, i32* %3
%10 = call i32 @localtime_r(i32* %3, %struct.tm* %5)
%11 = call i32 @tm_to_time_t(%struct.tm* %5)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %19
15: ; preds = %1
store i32 -1, i32* %7
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = sub nsw i32 %16, %17
store i32 %18, i32* %6
br label %23
19: ; preds = %1
store i32 1, i32* %7
%20 = load i32, i32* %4
%21 = load i32, i32* %3
%22 = sub nsw i32 %20, %21
store i32 %22, i32* %6
br label %23
23: ; preds = %19, %15
%24 = load i32, i32* %6
%25 = sdiv i32 %24, 60
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = srem i32 %26, 60
%28 = load i32, i32* %6
%29 = sdiv i32 %28, 60
%30 = mul nsw i32 %29, 100
%31 = add nsw i32 %27, %30
store i32 %31, i32* %6
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = mul nsw i32 %32, %33
ret i32 %34
}

LLVM IR (-O2):
%struct.tm = type { i32 }
define i32 @local_tzoffset(i64 %0) {
%2 = alloca i32
%3 = alloca %struct.tm
%4 = bitcast i32* %2 to i8*
%5 = bitcast %struct.tm* %3 to i8*
%6 = trunc i64 %0 to i32
store i32 %6, i32* %2
%7 = call i32 @localtime_r(i32* %2, %struct.tm* %3)
%8 = call i32 @tm_to_time_t(%struct.tm* %3)
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
%11 = sub nsw i32 %9, %8
%12 = sub nsw i32 %8, %9
%13 = select i1 %10, i32 %11, i32 %12
%14 = sdiv i32 %13, 60
%15 = srem i32 %14, 60
%16 = sdiv i32 %13, 3600
%17 = mul nsw i32 %16, 100
%18 = add nsw i32 %15, %17
%19 = sub nsw i32 0, %18
%20 = select i1 %10, i32 %19, i32 %18
ret i32 %20
}