#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_sec;
  int tm_min;
  int tm_hour;
  int tm_mday;
  int tm_mon;
  int tm_year;
  int tm_isdst;
};

/* Variables and functions */
int mktime(struct tm *);
time_t date_to_timer(long date, long time) {
  struct tm time_struct;
  time_t timer;
  time_struct.tm_sec = (int)(((time) % 10000L) / 100);
  time_struct.tm_min = (int)(((time) % 1000000L) / 10000L);
  time_struct.tm_hour = (int)((time) / 1000000L);
  time_struct.tm_mday = (int)((date) % 100);
  time_struct.tm_mon = (int)(((date) % 10000L) / 100) - 1;
  time_struct.tm_year = (int)((date) / 10000L) - 1900;
  time_struct.tm_isdst = -1;
  timer = mktime(&time_struct);
  if (timer == -1)
    return (0);
  else
    return (timer);
}


x86 assembly (clang, -O0):
<date_to_timer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x2710,%ecx
cqto
idiv   %rcx
mov    %rdx,%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
mov    %rdx,%rax
mov    $0x2710,%ecx
cqto
idiv   %rcx
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x2710,%ecx
cqto
idiv   %rcx
mov    %rdx,%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x2710,%ecx
cqto
idiv   %rcx
sub    $0x76c,%eax
mov    %eax,-0x24(%rbp)
movl   $0xffffffff,-0x20(%rbp)
lea    -0x38(%rbp),%rdi
call   1030 <mktime@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    11e0 <date_to_timer+0xd0>
movl   $0x0,-0x4(%rbp)
jmp    11e6 <date_to_timer+0xd6>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<date_to_timer>:
sub    $0x28,%rsp
movabs $0x346dc5d63886594b,%r8
c5 6d 34
mov    %rsi,%rax
imul   %r8
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0xb,%edx
add    %eax,%edx
imul   $0x2710,%edx,%eax
mov    %esi,%edx
sub    %eax,%edx
movswl %dx,%eax
imul   $0x147b,%eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x13,%ecx
add    %eax,%ecx
movabs $0x431bde82d7b634db,%rdx
de 1b 43
mov    %rsi,%rax
imul   %rdx
movswl %cx,%eax
mov    %eax,0x8(%rsp)
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x12,%rdx
add    %eax,%edx
imul   $0xf4240,%edx,%eax
sub    %eax,%esi
movslq %esi,%rax
imul   $0x68db8bad,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
mov    %eax,0xc(%rsp)
mov    %edx,0x10(%rsp)
movabs $0xa3d70a3d70a3d70b,%rcx
0a d7 a3
mov    %rdi,%rax
imul   %rcx
add    %rdi,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x6,%rdx
add    %eax,%edx
imul   $0x64,%edx,%eax
mov    %edi,%ecx
sub    %eax,%ecx
mov    %rdi,%rax
imul   %r8
mov    %ecx,0x14(%rsp)
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0xb,%rdx
lea    (%rdx,%rax,1),%ecx
imul   $0x2710,%ecx,%ecx
sub    %ecx,%edi
movswl %di,%ecx
imul   $0x147b,%ecx,%ecx
mov    %ecx,%esi
sar    $0x13,%esi
shr    $0x1f,%ecx
add    %esi,%ecx
add    $0xffffffff,%ecx
movswl %cx,%ecx
mov    %ecx,0x18(%rsp)
lea    -0x76c(%rdx,%rax,1),%eax
mov    %eax,0x1c(%rsp)
movl   $0xffffffff,0x20(%rsp)
ff
lea    0x8(%rsp),%rdi
call   1030 <mktime@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
cmove  %ecx,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
define i32 @date_to_timer(i64 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca %struct.tm
%7 = alloca i32
store i64 %0, i64* %4
store i64 %1, i64* %5
%8 = load i64, i64* %5
%9 = srem i64 %8, 10000
%10 = sdiv i64 %9, 100
%11 = trunc i64 %10 to i32
%12 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 0
store i32 %11, i32* %12
%13 = load i64, i64* %5
%14 = srem i64 %13, 1000000
%15 = sdiv i64 %14, 10000
%16 = trunc i64 %15 to i32
%17 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 1
store i32 %16, i32* %17
%18 = load i64, i64* %5
%19 = sdiv i64 %18, 1000000
%20 = trunc i64 %19 to i32
%21 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 2
store i32 %20, i32* %21
%22 = load i64, i64* %4
%23 = srem i64 %22, 100
%24 = trunc i64 %23 to i32
%25 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 3
store i32 %24, i32* %25
%26 = load i64, i64* %4
%27 = srem i64 %26, 10000
%28 = sdiv i64 %27, 100
%29 = trunc i64 %28 to i32
%30 = sub nsw i32 %29, 1
%31 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 4
store i32 %30, i32* %31
%32 = load i64, i64* %4
%33 = sdiv i64 %32, 10000
%34 = trunc i64 %33 to i32
%35 = sub nsw i32 %34, 1900
%36 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 5
store i32 %35, i32* %36
%37 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 6
store i32 -1, i32* %37
%38 = call i32 @mktime(%struct.tm* %6)
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %42
41: ; preds = %2
store i32 0, i32* %3
br label %44
42: ; preds = %2
%43 = load i32, i32* %7
store i32 %43, i32* %3
br label %44
44: ; preds = %42, %41
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
define i32 @date_to_timer(i64 %0, i64 %1) {
%3 = alloca %struct.tm
%4 = bitcast %struct.tm* %3 to i8*
%5 = srem i64 %1, 10000
%6 = trunc i64 %5 to i16
%7 = sdiv i16 %6, 100
%8 = sext i16 %7 to i32
%9 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
store i32 %8, i32* %9
%10 = srem i64 %1, 1000000
%11 = trunc i64 %10 to i32
%12 = sdiv i32 %11, 10000
%13 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
store i32 %12, i32* %13
%14 = sdiv i64 %1, 1000000
%15 = trunc i64 %14 to i32
%16 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
store i32 %15, i32* %16
%17 = srem i64 %0, 100
%18 = trunc i64 %17 to i32
%19 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 3
store i32 %18, i32* %19
%20 = srem i64 %0, 10000
%21 = trunc i64 %20 to i16
%22 = sdiv i16 %21, 100
%23 = add nsw i16 %22, -1
%24 = sext i16 %23 to i32
%25 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 4
store i32 %24, i32* %25
%26 = sdiv i64 %0, 10000
%27 = trunc i64 %26 to i32
%28 = add nsw i32 %27, -1900
%29 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 5
store i32 %28, i32* %29
%30 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 6
store i32 -1, i32* %30
%31 = call i32 @mktime(%struct.tm* %3)
%32 = icmp eq i32 %31, -1
%33 = select i1 %32, i32 0, i32 %31
ret i32 %33
}