#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_year;
  size_t tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
scalar_t__ is_leap(int);
time_t tm_to_time(struct tm *tmP) {
  time_t t;
  static int monthtab[12] = {0,   31,  59,  90,  120, 151,
                             181, 212, 243, 273, 304, 334};
  t = (tmP->tm_year - 70) * 365;
  t += (tmP->tm_year - 69) / 4;
  t += monthtab[tmP->tm_mon];
  if (tmP->tm_mon >= 2 && is_leap(tmP->tm_year + 1900)) {
    ++t;
  }
  t += tmP->tm_mday - 1;
  t = t * 24 + tmP->tm_hour;
  t = t * 60 + tmP->tm_min;
  t = t * 60 + tmP->tm_sec;
  return t;
}


x86 assembly (clang, -O0):
<tm_to_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
sub    $0x46,%eax
imul   $0x16d,%eax,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
sub    $0x45,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0x2edc(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x2,0x8(%rax)
jb     1190 <tm_to_time+0x80>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
add    $0x76c,%edi
call   1030 <is_leap@plt>
cmp    $0x0,%rax
je     1190 <tm_to_time+0x80>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%eax
sub    $0x1,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
imul   $0x18,-0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
add    0x14(%rcx),%eax
mov    %eax,-0xc(%rbp)
imul   $0x3c,-0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
add    0x18(%rcx),%eax
mov    %eax,-0xc(%rbp)
imul   $0x3c,-0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
add    0x1c(%rcx),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tm_to_time>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%edi
imul   $0x16d,%edi,%eax
lea    -0x45(%rdi),%ecx
lea    -0x42(%rdi),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
sar    $0x2,%edx
add    %eax,%edx
mov    0x8(%r14),%rax
lea    0xec6(%rip),%rcx
mov    (%rcx,%rax,4),%ecx
lea    (%rcx,%rdx,1),%ebx
add    $0xffff9c32,%ebx
cmp    $0x2,%rax
jb     115e <tm_to_time+0x4e>
add    $0x76c,%edi
call   1030 <is_leap@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebx
add    0x10(%r14),%ebx
lea    (%rbx,%rbx,2),%eax
shl    $0x3,%eax
add    0x14(%r14),%eax
imul   $0x3c,%eax,%eax
add    0x18(%r14),%eax
imul   $0x3c,%eax,%eax
mov    0x1c(%r14),%ecx
add    %ecx,%eax
add    $0xfffeae80,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i64, i32, i32, i32, i32 }
@tm_to_time.monthtab = internal global [12 x i32] [i32 0, i32 31, i32 59, i32 90, i32 120, i32 151, i32 181, i32 212, i32 243, i32 273, i32 304, i32 334]
define i32 @tm_to_time(%struct.tm* %0) {
%2 = alloca %struct.tm*
%3 = alloca i32
store %struct.tm* %0, %struct.tm** %2
%4 = load %struct.tm*, %struct.tm** %2
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
%6 = load i32, i32* %5
%7 = sub nsw i32 %6, 70
%8 = mul nsw i32 %7, 365
store i32 %8, i32* %3
%9 = load %struct.tm*, %struct.tm** %2
%10 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = sub nsw i32 %11, 69
%13 = sdiv i32 %12, 4
%14 = load i32, i32* %3
%15 = add nsw i32 %14, %13
store i32 %15, i32* %3
%16 = load %struct.tm*, %struct.tm** %2
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 1
%18 = load i64, i64* %17
%19 = getelementptr inbounds [12 x i32], [12 x i32]* @tm_to_time.monthtab, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, %20
store i32 %22, i32* %3
%23 = load %struct.tm*, %struct.tm** %2
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 1
%25 = load i64, i64* %24
%26 = icmp uge i64 %25, 2
br i1 %26, label %27, label %37
27: ; preds = %1
%28 = load %struct.tm*, %struct.tm** %2
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 0
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1900
%32 = call i64 @is_leap(i32 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %27
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %37
37: ; preds = %34, %27, %1
%38 = load %struct.tm*, %struct.tm** %2
%39 = getelementptr inbounds %struct.tm, %struct.tm* %38, i32 0, i32 2
%40 = load i32, i32* %39
%41 = sub nsw i32 %40, 1
%42 = load i32, i32* %3
%43 = add nsw i32 %42, %41
store i32 %43, i32* %3
%44 = load i32, i32* %3
%45 = mul nsw i32 %44, 24
%46 = load %struct.tm*, %struct.tm** %2
%47 = getelementptr inbounds %struct.tm, %struct.tm* %46, i32 0, i32 3
%48 = load i32, i32* %47
%49 = add nsw i32 %45, %48
store i32 %49, i32* %3
%50 = load i32, i32* %3
%51 = mul nsw i32 %50, 60
%52 = load %struct.tm*, %struct.tm** %2
%53 = getelementptr inbounds %struct.tm, %struct.tm* %52, i32 0, i32 4
%54 = load i32, i32* %53
%55 = add nsw i32 %51, %54
store i32 %55, i32* %3
%56 = load i32, i32* %3
%57 = mul nsw i32 %56, 60
%58 = load %struct.tm*, %struct.tm** %2
%59 = getelementptr inbounds %struct.tm, %struct.tm* %58, i32 0, i32 5
%60 = load i32, i32* %59
%61 = add nsw i32 %57, %60
store i32 %61, i32* %3
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
%struct.tm = type { i32, i64, i32, i32, i32, i32 }
@tm_to_time.monthtab = internal unnamed_addr constant [12 x i32] [i32 0, i32 31, i32 59, i32 90, i32 120, i32 151, i32 181, i32 212, i32 243, i32 273, i32 304, i32 334]
define i32 @tm_to_time(%struct.tm* nocapture %0) {
%2 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = mul i32 %3, 365
%5 = add i32 %4, -25550
%6 = add nsw i32 %3, -69
%7 = sdiv i32 %6, 4
%8 = add nsw i32 %5, %7
%9 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 1
%10 = load i64, i64* %9
%11 = getelementptr inbounds [12 x i32], [12 x i32]* @tm_to_time.monthtab, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = add nsw i32 %8, %12
%14 = icmp ugt i64 %10, 1
br i1 %14, label %15, label %21
15: ; preds = %1
%16 = add nsw i32 %3, 1900
%17 = tail call i64 @is_leap(i32 %16)
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
%20 = add nsw i32 %13, %19
br label %21
21: ; preds = %15, %1
%22 = phi i32 [ %13, %1 ], [ %20, %15 ]
%23 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 2
%24 = load i32, i32* %23
%25 = add i32 %22, -1
%26 = add i32 %25, %24
%27 = mul nsw i32 %26, 24
%28 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 3
%29 = load i32, i32* %28
%30 = add nsw i32 %27, %29
%31 = mul nsw i32 %30, 60
%32 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 4
%33 = load i32, i32* %32
%34 = add nsw i32 %31, %33
%35 = mul nsw i32 %34, 60
%36 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 5
%37 = load i32, i32* %36
%38 = add nsw i32 %35, %37
ret i32 %38
}