#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 scalar_t__ time_t;
struct tm {
  int tm_sec;
  int tm_min;
  int tm_hour;
  int tm_mday;
  int tm_mon;
  int tm_year;
  scalar_t__ tm_isdst;
};

/* Variables and functions */
struct tm *gmtime(scalar_t__ *);
scalar_t__ mktime(struct tm *);
double get_unixtime(int year, int month, int day, int hour, int minute,
                    int second, int *err_code) {
  struct tm t, *gmt_tm;
  time_t local_t, gmt_t;
  *err_code = 0;
  t.tm_sec = second;
  t.tm_min = minute;
  t.tm_hour = hour;
  t.tm_mday = day;
  t.tm_mon = month - 1;
  t.tm_year = year - 1900;
  t.tm_isdst = 0;
  if (sizeof(time_t) <= 4 && (year > 2037 || year < 1902)) {
    *err_code = 1;
    return 0;
  }
  local_t = mktime(&t);
  if (year < 1970 && local_t >= 0) {
    *err_code = 2;
    return 0;
  }
  if (year > 1970 && local_t <= 0) {
    *err_code = 3;
    return 0;
  }
  gmt_tm = gmtime(&local_t);
  gmt_t = mktime(gmt_tm);
  return ((double)(local_t + (local_t - gmt_t)));
}


x86 assembly (clang, -O0):
<get_unixtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x2c(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <mktime@plt>
mov    %rax,-0x50(%rbp)
cmpl   $0x7b2,-0xc(%rbp)
jge    11ba <get_unixtime+0x9a>
cmpq   $0x0,-0x50(%rbp)
jl     11ba <get_unixtime+0x9a>
mov    0x10(%rbp),%rax
movl   $0x2,(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121c <get_unixtime+0xfc>
cmpl   $0x7b2,-0xc(%rbp)
jle    11e9 <get_unixtime+0xc9>
cmpq   $0x0,-0x50(%rbp)
jg     11e9 <get_unixtime+0xc9>
mov    0x10(%rbp),%rax
movl   $0x3,(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121c <get_unixtime+0xfc>
lea    -0x50(%rbp),%rdi
call   1040 <gmtime@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1030 <mktime@plt>
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    -0x58(%rbp),%rcx
add    %rcx,%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_unixtime>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebx
mov    0x40(%rsp),%r14
movl   $0x0,(%r14)
mov    %r9d,0x8(%rsp)
mov    %r8d,0xc(%rsp)
mov    %ecx,0x10(%rsp)
mov    %edx,0x14(%rsp)
add    $0xffffffff,%esi
mov    %esi,0x18(%rsp)
lea    -0x76c(%rbx),%eax
mov    %eax,0x1c(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <mktime@plt>
mov    %rax,(%rsp)
cmp    $0x7b1,%ebx
jg     1189 <get_unixtime+0x69>
test   %rax,%rax
js     1189 <get_unixtime+0x69>
movl   $0x2,(%r14)
xorpd  %xmm0,%xmm0
jmp    11c2 <get_unixtime+0xa2>
cmp    $0x7b3,%ebx
jl     11a3 <get_unixtime+0x83>
test   %rax,%rax
jg     11a3 <get_unixtime+0x83>
movl   $0x3,(%r14)
xorpd  %xmm0,%xmm0
jmp    11c2 <get_unixtime+0xa2>
mov    %rsp,%rdi
call   1040 <gmtime@plt>
mov    %rax,%rdi
call   1030 <mktime@plt>
mov    (%rsp),%rcx
add    %rcx,%rcx
sub    %rax,%rcx
cvtsi2sd %rcx,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i64 }
define double @get_unixtime(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32* %6) {
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca %struct.tm
%17 = alloca %struct.tm*
%18 = alloca i64
%19 = alloca i64
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32* %6, i32** %15
%20 = load i32*, i32** %15
store i32 0, i32* %20
%21 = load i32, i32* %14
%22 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 0
store i32 %21, i32* %22
%23 = load i32, i32* %13
%24 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 1
store i32 %23, i32* %24
%25 = load i32, i32* %12
%26 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 2
store i32 %25, i32* %26
%27 = load i32, i32* %11
%28 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 3
store i32 %27, i32* %28
%29 = load i32, i32* %10
%30 = sub nsw i32 %29, 1
%31 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 4
store i32 %30, i32* %31
%32 = load i32, i32* %9
%33 = sub nsw i32 %32, 1900
%34 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 5
store i32 %33, i32* %34
%35 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 6
store i64 0, i64* %35
%36 = call i64 @mktime(%struct.tm* %16)
store i64 %36, i64* %18
%37 = load i32, i32* %9
%38 = icmp slt i32 %37, 1970
br i1 %38, label %39, label %44
39: ; preds = %7
%40 = load i64, i64* %18
%41 = icmp sge i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = load i32*, i32** %15
store i32 2, i32* %43
store double 0.000000e+00, double* %8
br label %62
44: ; preds = %39, %7
%45 = load i32, i32* %9
%46 = icmp sgt i32 %45, 1970
br i1 %46, label %47, label %52
47: ; preds = %44
%48 = load i64, i64* %18
%49 = icmp sle i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = load i32*, i32** %15
store i32 3, i32* %51
store double 0.000000e+00, double* %8
br label %62
52: ; preds = %47, %44
%53 = call %struct.tm* @gmtime(i64* %18)
store %struct.tm* %53, %struct.tm** %17
%54 = load %struct.tm*, %struct.tm** %17
%55 = call i64 @mktime(%struct.tm* %54)
store i64 %55, i64* %19
%56 = load i64, i64* %18
%57 = load i64, i64* %18
%58 = load i64, i64* %19
%59 = sub nsw i64 %57, %58
%60 = add nsw i64 %56, %59
%61 = sitofp i64 %60 to double
store double %61, double* %8
br label %62
62: ; preds = %52, %50, %42
%63 = load double, double* %8
ret double %63
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i64 }
define double @get_unixtime(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32* nocapture writeonly %6) {
%8 = alloca %struct.tm
%9 = alloca i64
%10 = bitcast %struct.tm* %8 to i8*
%11 = bitcast i64* %9 to i8*
store i32 0, i32* %6
%12 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 0
store i32 %5, i32* %12
%13 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 1
store i32 %4, i32* %13
%14 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 2
store i32 %3, i32* %14
%15 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 3
store i32 %2, i32* %15
%16 = add nsw i32 %1, -1
%17 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 4
store i32 %16, i32* %17
%18 = add nsw i32 %0, -1900
%19 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 5
store i32 %18, i32* %19
%20 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 6
store i64 0, i64* %20
%21 = call i64 @mktime(%struct.tm* %8)
store i64 %21, i64* %9
%22 = icmp slt i32 %0, 1970
%23 = icmp sgt i64 %21, -1
%24 = and i1 %22, %23
br i1 %24, label %25, label %26
25: ; preds = %7
store i32 2, i32* %6
br label %38
26: ; preds = %7
%27 = icmp sgt i32 %0, 1970
%28 = icmp slt i64 %21, 1
%29 = and i1 %27, %28
br i1 %29, label %30, label %31
30: ; preds = %26
store i32 3, i32* %6
br label %38
31: ; preds = %26
%32 = call %struct.tm* @gmtime(i64* %9)
%33 = call i64 @mktime(%struct.tm* %32)
%34 = load i64, i64* %9
%35 = shl i64 %34, 1
%36 = sub i64 %35, %33
%37 = sitofp i64 %36 to double
br label %38
38: ; preds = %31, %30, %25
%39 = phi double [ 0.000000e+00, %25 ], [ 0.000000e+00, %30 ], [ %37, %31 ]
ret double %39
}