#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 tm_hour;
  int tm_min;
  int tm_sec;
  scalar_t__ tm_isdst;
};

/* Variables and functions */
struct tm *localtime(int *);
int /*<<< orphan*/ report(float, float, char *, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int time(int /*<<< orphan*/ *);
int guess_by_timezone_offset(void) {
  time_t time_utc;
  time_t time_local;
  time_t time_diff;
  struct tm *time_local_;
  float longitude;
  time_utc = time(NULL);
  time_local_ = localtime(&time_utc);
  time_local = time_local_->tm_hour;
  time_local = time_local * 60 + time_local_->tm_min;
  time_local = time_local * 60 + time_local_->tm_sec;
  if (time_local_->tm_isdst > 0)
    time_local -= 60 * 60;
  time_utc %= 24 * 60 * 60;
  time_diff = time_local - time_utc;
  time_diff = (time_diff + 30) / 60;
  time_diff = (time_diff + 15) / 30;
  longitude = (float)time_diff * 180.f / 12.f / 2.f;
  if (longitude > 180.f)
    longitude -= 360.f;
  if (longitude < -180.f)
    longitude += 360.f;
  report(0.f, longitude, "timezone offset", 0, 0);
  return 0;
}


x86 assembly (clang, -O0):
<guess_by_timezone_offset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
imul   $0x3c,-0x8(%rbp),%eax
mov    -0x18(%rbp),%rcx
add    0x4(%rcx),%eax
mov    %eax,-0x8(%rbp)
imul   $0x3c,-0x8(%rbp),%eax
mov    -0x18(%rbp),%rcx
add    0x8(%rcx),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x10(%rax)
jle    1190 <guess_by_timezone_offset+0x60>
mov    -0x8(%rbp),%eax
sub    $0xe10,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1e,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xf,%eax
mov    $0x1e,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  0xe2a(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe26(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe16(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  0xdfc(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1223 <guess_by_timezone_offset+0xf3>
movss  -0x1c(%rbp),%xmm0
movss  0xdf2(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xde5(%rip),%xmm0
ucomiss -0x1c(%rbp),%xmm0
jbe    1247 <guess_by_timezone_offset+0x117>
movss  0xdcf(%rip),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm1
xorps  %xmm0,%xmm0
lea    0xdbe(%rip),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <report@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<guess_by_timezone_offset>:
push   %rax
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
imul   $0x3c,(%rax),%ecx
add    0x4(%rax),%ecx
imul   $0x3c,%ecx,%ecx
mov    0x8(%rax),%edx
lea    (%rcx,%rdx,1),%esi
cmpq   $0x0,0x10(%rax)
lea    -0xe10(%rcx,%rdx,1),%ecx
cmovle %esi,%ecx
movslq 0x4(%rsp),%rax
imul   $0xffffffffc22e4507,%rax,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x10,%edx
add    %esi,%edx
imul   $0x15180,%edx,%edx
sub    %edx,%eax
sub    %eax,%ecx
mov    %ecx,%edx
add    $0x1e,%edx
movslq %edx,%rdx
imul   $0xffffffff88888889,%rdx,%rdx
shr    $0x20,%rdx
add    %edx,%ecx
add    $0x1e,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x5,%ecx
lea    (%rcx,%rdx,1),%esi
add    %edx,%ecx
add    $0xf,%ecx
movslq %ecx,%rcx
imul   $0xffffffff88888889,%rcx,%rcx
shr    $0x20,%rcx
add    %esi,%ecx
add    $0xf,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x4,%ecx
add    %edx,%ecx
cvtsi2ss %ecx,%xmm0
movss  0xe25(%rip),%xmm2
mulss  %xmm2,%xmm0
divss  0xe1d(%rip),%xmm0
mov    %eax,0x4(%rsp)
mulss  0xe15(%rip),%xmm0
movss  0xe11(%rip),%xmm1
addss  %xmm0,%xmm1
cmpltss %xmm0,%xmm2
andps  %xmm2,%xmm1
andnps %xmm0,%xmm2
orps   %xmm1,%xmm2
movss  0xdfb(%rip),%xmm0
movaps %xmm2,%xmm1
cmpltss 0xdf3(%rip),%xmm1
addss  %xmm2,%xmm0
andps  %xmm1,%xmm0
andnps %xmm2,%xmm1
orps   %xmm0,%xmm1
lea    0xde3(%rip),%rdi
xorps  %xmm0,%xmm0
xor    %esi,%esi
xor    %edx,%edx
call   1050 <report@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i64 }
@.str = [16 x i8] c"timezone offset\00"
define i32 @guess_by_timezone_offset() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca float
%6 = call i32 @time(i32* null)
store i32 %6, i32* %1
%7 = call %struct.tm* @localtime(i32* %1)
store %struct.tm* %7, %struct.tm** %4
%8 = load %struct.tm*, %struct.tm** %4
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%10 = load i32, i32* %9
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = mul nsw i32 %11, 60
%13 = load %struct.tm*, %struct.tm** %4
%14 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 1
%15 = load i32, i32* %14
%16 = add nsw i32 %12, %15
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = mul nsw i32 %17, 60
%19 = load %struct.tm*, %struct.tm** %4
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 2
%21 = load i32, i32* %20
%22 = add nsw i32 %18, %21
store i32 %22, i32* %2
%23 = load %struct.tm*, %struct.tm** %4
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 3
%25 = load i64, i64* %24
%26 = icmp sgt i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %0
%28 = load i32, i32* %2
%29 = sub nsw i32 %28, 3600
store i32 %29, i32* %2
br label %30
30: ; preds = %27, %0
%31 = load i32, i32* %1
%32 = srem i32 %31, 86400
store i32 %32, i32* %1
%33 = load i32, i32* %2
%34 = load i32, i32* %1
%35 = sub nsw i32 %33, %34
store i32 %35, i32* %3
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 30
%38 = sdiv i32 %37, 60
store i32 %38, i32* %3
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 15
%41 = sdiv i32 %40, 30
store i32 %41, i32* %3
%42 = load i32, i32* %3
%43 = sitofp i32 %42 to float
%44 = fmul float %43, 1.800000e+02
%45 = fdiv float %44, 1.200000e+01
%46 = fdiv float %45, 2.000000e+00
store float %46, float* %5
%47 = load float, float* %5
%48 = fcmp ogt float %47, 1.800000e+02
br i1 %48, label %49, label %52
49: ; preds = %30
%50 = load float, float* %5
%51 = fsub float %50, 3.600000e+02
store float %51, float* %5
br label %52
52: ; preds = %49, %30
%53 = load float, float* %5
%54 = fcmp olt float %53, -1.800000e+02
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = load float, float* %5
%57 = fadd float %56, 3.600000e+02
store float %57, float* %5
br label %58
58: ; preds = %55, %52
%59 = load float, float* %5
%60 = call i32 @report(float 0.000000e+00, float %59, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 0, i32 0)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i64 }
@.str = [16 x i8] c"timezone offset\00"
define i32 @guess_by_timezone_offset() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = call %struct.tm* @localtime(i32* %1)
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%6 = load i32, i32* %5
%7 = mul nsw i32 %6, 60
%8 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%9 = load i32, i32* %8
%10 = add nsw i32 %7, %9
%11 = mul nsw i32 %10, 60
%12 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%13 = load i32, i32* %12
%14 = add nsw i32 %11, %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%16 = load i64, i64* %15
%17 = icmp sgt i64 %16, 0
%18 = add nsw i32 %14, -3600
%19 = select i1 %17, i32 %18, i32 %14
%20 = load i32, i32* %1
%21 = srem i32 %20, 86400
store i32 %21, i32* %1
%22 = sub nsw i32 30, %21
%23 = add i32 %22, %19
%24 = sdiv i32 %23, 60
%25 = add nsw i32 %24, 15
%26 = sdiv i32 %25, 30
%27 = sitofp i32 %26 to float
%28 = fmul float %27, 1.800000e+02
%29 = fdiv float %28, 1.200000e+01
%30 = fmul float %29, 5.000000e-01
%31 = fcmp ogt float %30, 1.800000e+02
%32 = fadd float %30, -3.600000e+02
%33 = select i1 %31, float %32, float %30
%34 = fcmp olt float %33, -1.800000e+02
%35 = fadd float %33, 3.600000e+02
%36 = select i1 %34, float %35, float %33
%37 = call i32 @report(float 0.000000e+00, float %36, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 0, i32 0)
ret i32 0
}