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

/* Variables and functions */
scalar_t__ isLeapYear(int);
time_t mktime(struct tm *theDate) {
  time_t retVal = 0;
  const time_t secsPerMin = 60;
  const time_t secsPerHour = secsPerMin * 60;
  const time_t secsPerDay = secsPerHour * 24;
  const time_t secsPerYear = secsPerDay * 365;
  const time_t secsPerLeapYear = secsPerDay * 366;
  int currYear;
  int currMonth;
  int i;
  currYear = 1900 + theDate->tm_year;
  for (i = 1970; i < currYear; i++) {
    if (isLeapYear(i)) {
      retVal += secsPerLeapYear;
    } else {
      retVal += secsPerYear;
    }
  }
  currMonth = 1 + theDate->tm_mon;
  for (i = 1; i < currMonth; i++) {
    switch (i) {
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
      retVal += secsPerDay * 31;
      break;
    case 4:
    case 6:
    case 9:
    case 11:
      retVal += secsPerDay * 30;
      break;
    case 2:
      if (isLeapYear(currYear)) {
        retVal += secsPerDay * 29;
      } else {
        retVal += secsPerDay * 28;
      }
      break;
    }
  }
  retVal += (theDate->tm_mday - 1) * secsPerDay;
  retVal += (theDate->tm_hour) * secsPerHour;
  retVal += (theDate->tm_min) * secsPerMin;
  retVal += theDate->tm_sec;
  return retVal;
}


x86 assembly (clang, -O0):
<mktime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x3c,-0x10(%rbp)
movl   $0xe10,-0x14(%rbp)
movl   $0x15180,-0x18(%rbp)
movl   $0x1e13380,-0x1c(%rbp)
movl   $0x1e28500,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0x76c,%eax
mov    %eax,-0x24(%rbp)
movl   $0x7b2,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11a7 <mktime+0x97>
mov    -0x2c(%rbp),%edi
call   1030 <isLeapYear@plt>
cmp    $0x0,%rax
je     1189 <mktime+0x79>
mov    -0xc(%rbp),%eax
add    $0x1e28500,%eax
mov    %eax,-0xc(%rbp)
jmp    1194 <mktime+0x84>
mov    -0xc(%rbp),%eax
add    $0x1e13380,%eax
mov    %eax,-0xc(%rbp)
jmp    1199 <mktime+0x89>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115b <mktime+0x4b>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12ed <mktime+0x1dd>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x1,%eax
je     1288 <mktime+0x178>
jmp    11db <mktime+0xcb>
mov    -0x30(%rbp),%eax
sub    $0x2,%eax
je     12a8 <mktime+0x198>
jmp    11ec <mktime+0xdc>
mov    -0x30(%rbp),%eax
sub    $0x3,%eax
je     1288 <mktime+0x178>
jmp    11fd <mktime+0xed>
mov    -0x30(%rbp),%eax
sub    $0x4,%eax
je     1298 <mktime+0x188>
jmp    120e <mktime+0xfe>
mov    -0x30(%rbp),%eax
sub    $0x5,%eax
je     1288 <mktime+0x178>
jmp    121f <mktime+0x10f>
mov    -0x30(%rbp),%eax
sub    $0x6,%eax
je     1298 <mktime+0x188>
jmp    1230 <mktime+0x120>
mov    -0x30(%rbp),%eax
add    $0xfffffff9,%eax
sub    $0x2,%eax
jb     1288 <mktime+0x178>
jmp    1244 <mktime+0x134>
mov    -0x30(%rbp),%eax
sub    $0x9,%eax
je     1298 <mktime+0x188>
jmp    1255 <mktime+0x145>
mov    -0x30(%rbp),%eax
sub    $0xa,%eax
je     1288 <mktime+0x178>
jmp    1266 <mktime+0x156>
mov    -0x30(%rbp),%eax
sub    $0xb,%eax
je     1298 <mktime+0x188>
jmp    1277 <mktime+0x167>
mov    -0x30(%rbp),%eax
sub    $0xc,%eax
jne    12da <mktime+0x1ca>
jmp    1288 <mktime+0x178>
mov    -0xc(%rbp),%eax
add    $0x28de80,%eax
mov    %eax,-0xc(%rbp)
jmp    12da <mktime+0x1ca>
mov    -0xc(%rbp),%eax
add    $0x278d00,%eax
mov    %eax,-0xc(%rbp)
jmp    12da <mktime+0x1ca>
mov    -0x24(%rbp),%edi
call   1030 <isLeapYear@plt>
cmp    $0x0,%rax
je     12ca <mktime+0x1ba>
mov    -0xc(%rbp),%eax
add    $0x263b80,%eax
mov    %eax,-0xc(%rbp)
jmp    12d5 <mktime+0x1c5>
mov    -0xc(%rbp),%eax
add    $0x24ea00,%eax
mov    %eax,-0xc(%rbp)
jmp    12da <mktime+0x1ca>
jmp    12df <mktime+0x1cf>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11bb <mktime+0xab>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
sub    $0x1,%eax
imul   $0x15180,%eax,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
imul   $0xe10,0xc(%rax),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
imul   $0x3c,0x10(%rax),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mktime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    (%rdi),%eax
lea    0x76c(%rax),%ecx
mov    %ecx,0x4(%rsp)
xor    %ebx,%ebx
cmp    $0x47,%eax
jl     1171 <mktime+0x61>
mov    0x4(%rsp),%eax
cmp    $0x7b4,%eax
mov    $0x7b3,%r14d
cmovge %eax,%r14d
xor    %ebx,%ebx
mov    $0x7b2,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <isLeapYear@plt>
lea    0x1e28500(%rbx),%ecx
add    $0x1e13380,%ebx
test   %rax,%rax
cmovne %ecx,%ebx
add    $0x1,%ebp
cmp    %ebp,%r14d
jne    1150 <mktime+0x40>
mov    0x4(%r15),%r12d
test   %r12d,%r12d
jle    11e5 <mktime+0xd5>
neg    %r12d
mov    $0x1,%ebp
mov    $0x15aa,%r13d
mov    $0xa50,%r14d
jmp    11a9 <mktime+0x99>
add    $0x28de80,%ebx
lea    (%r12,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
je     11e5 <mktime+0xd5>
cmp    $0xc,%ebp
ja     1196 <mktime+0x86>
bt     %ebp,%r13d
jb     1190 <mktime+0x80>
bt     %ebp,%r14d
jae    11c2 <mktime+0xb2>
add    $0x278d00,%ebx
jmp    1196 <mktime+0x86>
cmp    $0x2,%ebp
jne    1196 <mktime+0x86>
mov    0x4(%rsp),%edi
call   1030 <isLeapYear@plt>
test   %rax,%rax
je     11dd <mktime+0xcd>
add    $0x263b80,%ebx
jmp    1196 <mktime+0x86>
add    $0x24ea00,%ebx
jmp    1196 <mktime+0x86>
imul   $0x15180,0x8(%r15),%eax
add    %ebx,%eax
imul   $0xe10,0xc(%r15),%ecx
imul   $0x3c,0x10(%r15),%edx
add    %eax,%ecx
add    %ecx,%edx
mov    0x18(%r15),%eax
add    %edx,%eax
add    $0xfffeae80,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i64 }
define i32 @mktime(%struct.tm* %0) {
%2 = alloca %struct.tm*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store %struct.tm* %0, %struct.tm** %2
store i32 0, i32* %3
store i32 60, i32* %4
store i32 3600, i32* %5
store i32 86400, i32* %6
store i32 31536000, i32* %7
store i32 31622400, i32* %8
%12 = load %struct.tm*, %struct.tm** %2
%13 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = add nsw i32 1900, %14
store i32 %15, i32* %9
store i32 1970, i32* %11
br label %16
16: ; preds = %31, %1
%17 = load i32, i32* %11
%18 = load i32, i32* %9
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %34
20: ; preds = %16
%21 = load i32, i32* %11
%22 = call i64 @isLeapYear(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 31622400
store i32 %26, i32* %3
br label %30
27: ; preds = %20
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 31536000
store i32 %29, i32* %3
br label %30
30: ; preds = %27, %24
br label %31
31: ; preds = %30
%32 = load i32, i32* %11
%33 = add nsw i32 %32, 1
store i32 %33, i32* %11
br label %16
34: ; preds = %16
%35 = load %struct.tm*, %struct.tm** %2
%36 = getelementptr inbounds %struct.tm, %struct.tm* %35, i32 0, i32 1
%37 = load i32, i32* %36
%38 = add nsw i32 1, %37
store i32 %38, i32* %10
store i32 1, i32* %11
br label %39
39: ; preds = %63, %34
%40 = load i32, i32* %11
%41 = load i32, i32* %10
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %66
43: ; preds = %39
%44 = load i32, i32* %11
switch i32 %44, label %62 [
i32 1, label %45
i32 3, label %45
i32 5, label %45
i32 7, label %45
i32 8, label %45
i32 10, label %45
i32 12, label %45
i32 4, label %48
i32 6, label %48
i32 9, label %48
i32 11, label %48
i32 2, label %51
]
45: ; preds = %43, %43, %43, %43, %43, %43, %43
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 2678400
store i32 %47, i32* %3
br label %62
48: ; preds = %43, %43, %43, %43
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 2592000
store i32 %50, i32* %3
br label %62
51: ; preds = %43
%52 = load i32, i32* %9
%53 = call i64 @isLeapYear(i32 %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = load i32, i32* %3
%57 = add nsw i32 %56, 2505600
store i32 %57, i32* %3
br label %61
58: ; preds = %51
%59 = load i32, i32* %3
%60 = add nsw i32 %59, 2419200
store i32 %60, i32* %3
br label %61
61: ; preds = %58, %55
br label %62
62: ; preds = %43, %61, %48, %45
br label %63
63: ; preds = %62
%64 = load i32, i32* %11
%65 = add nsw i32 %64, 1
store i32 %65, i32* %11
br label %39
66: ; preds = %39
%67 = load %struct.tm*, %struct.tm** %2
%68 = getelementptr inbounds %struct.tm, %struct.tm* %67, i32 0, i32 2
%69 = load i32, i32* %68
%70 = sub nsw i32 %69, 1
%71 = mul nsw i32 %70, 86400
%72 = load i32, i32* %3
%73 = add nsw i32 %72, %71
store i32 %73, i32* %3
%74 = load %struct.tm*, %struct.tm** %2
%75 = getelementptr inbounds %struct.tm, %struct.tm* %74, i32 0, i32 3
%76 = load i32, i32* %75
%77 = mul nsw i32 %76, 3600
%78 = load i32, i32* %3
%79 = add nsw i32 %78, %77
store i32 %79, i32* %3
%80 = load %struct.tm*, %struct.tm** %2
%81 = getelementptr inbounds %struct.tm, %struct.tm* %80, i32 0, i32 4
%82 = load i32, i32* %81
%83 = mul nsw i32 %82, 60
%84 = load i32, i32* %3
%85 = add nsw i32 %84, %83
store i32 %85, i32* %3
%86 = load %struct.tm*, %struct.tm** %2
%87 = getelementptr inbounds %struct.tm, %struct.tm* %86, i32 0, i32 5
%88 = load i64, i64* %87
%89 = load i32, i32* %3
%90 = sext i32 %89 to i64
%91 = add nsw i64 %90, %88
%92 = trunc i64 %91 to i32
store i32 %92, i32* %3
%93 = load i32, i32* %3
ret i32 %93
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i64 }
define i32 @mktime(%struct.tm* nocapture %0) {
%2 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = add i32 %3, 1900
%5 = icmp sgt i32 %3, 70
br i1 %5, label %6, label %17
6: ; preds = %1
%7 = call i32 @llvm.smax.i32(i32 %4, i32 1971)
br label %8
8: ; preds = %6, %8
%9 = phi i32 [ %15, %8 ], [ 1970, %6 ]
%10 = phi i32 [ %14, %8 ], [ 0, %6 ]
%11 = tail call i64 @isLeapYear(i32 %9)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i32 31536000, i32 31622400
%14 = add nuw nsw i32 %13, %10
%15 = add nuw nsw i32 %9, 1
%16 = icmp eq i32 %15, %7
br i1 %16, label %17, label %8
17: ; preds = %8, %1
%18 = phi i32 [ 0, %1 ], [ %14, %8 ]
%19 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 1
%20 = load i32, i32* %19
%21 = icmp slt i32 %20, 1
br i1 %21, label %40, label %22
22: ; preds = %17, %36
%23 = phi i32 [ %38, %36 ], [ 1, %17 ]
%24 = phi i32 [ %37, %36 ], [ %18, %17 ]
switch i32 %23, label %36 [
i32 1, label %25
i32 3, label %25
i32 5, label %25
i32 7, label %25
i32 8, label %25
i32 10, label %25
i32 12, label %25
i32 4, label %27
i32 6, label %27
i32 9, label %27
i32 11, label %27
i32 2, label %29
]
25: ; preds = %22, %22, %22, %22, %22, %22, %22
%26 = add nsw i32 %24, 2678400
br label %36
27: ; preds = %22, %22, %22, %22
%28 = add nsw i32 %24, 2592000
br label %36
29: ; preds = %22
%30 = tail call i64 @isLeapYear(i32 %4)
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = add nsw i32 %24, 2505600
br label %36
34: ; preds = %29
%35 = add nsw i32 %24, 2419200
br label %36
36: ; preds = %25, %27, %22, %34, %32
%37 = phi i32 [ %24, %22 ], [ %33, %32 ], [ %35, %34 ], [ %28, %27 ], [ %26, %25 ]
%38 = add nuw i32 %23, 1
%39 = icmp eq i32 %23, %20
br i1 %39, label %40, label %22
40: ; preds = %36, %17
%41 = phi i32 [ %18, %17 ], [ %37, %36 ]
%42 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 2
%43 = load i32, i32* %42
%44 = mul i32 %43, 86400
%45 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 3
%46 = load i32, i32* %45
%47 = mul nsw i32 %46, 3600
%48 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 4
%49 = load i32, i32* %48
%50 = mul nsw i32 %49, 60
%51 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 5
%52 = load i64, i64* %51
%53 = trunc i64 %52 to i32
%54 = add i32 %41, -86400
%55 = add i32 %54, %44
%56 = add i32 %55, %47
%57 = add i32 %56, %50
%58 = add i32 %57, %53
ret i32 %58
}