#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;
};

/* Variables and functions */
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
int mktime(struct tm *);
int /*<<< orphan*/ time(int *);
int dateDiff(int y2, int m2, int d2) {
  time_t st1;
  time(&st1);
  struct tm ptr2;
  memset(&ptr2, 0, sizeof(struct tm));
  ptr2.tm_sec = 10;
  ptr2.tm_min = 10;
  ptr2.tm_hour = 10;
  ptr2.tm_mday = d2;
  ptr2.tm_mon = m2 - 1;
  ptr2.tm_year = y2 - 1900;
  time_t st2 = mktime(&ptr2);
  int rtn = (int)((st2 - st1) / 3600 / 24);
  return rtn;
}


x86 assembly (clang, -O0):
<dateDiff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <time@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
movl   $0xa,-0x28(%rbp)
movl   $0xa,-0x24(%rbp)
movl   $0xa,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x14(%rbp)
lea    -0x28(%rbp),%rdi
call   1050 <mktime@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    $0x18,%ecx
cltd
idiv   %ecx
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dateDiff>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xc(%rsp),%rdi
call   1040 <time@plt>
lea    0x10(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
movabs $0xa0000000a,%rax
mov    %rax,0x10(%rsp)
movl   $0xa,0x18(%rsp)
mov    %r14d,0x1c(%rsp)
add    $0xffffffff,%ebp
mov    %ebp,0x20(%rsp)
add    $0xfffff894,%ebx
mov    %ebx,0x24(%rsp)
mov    %r15,%rdi
call   1050 <mktime@plt>
sub    0xc(%rsp),%eax
cltq
imul   $0xffffffffc22e4507,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x10,%eax
add    %ecx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define i32 @dateDiff(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.tm
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = call i32 @time(i32* %7)
%12 = call i32 @memset(%struct.tm* %8, i32 0, i32 24)
%13 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
store i32 10, i32* %13
%14 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 1
store i32 10, i32* %14
%15 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 2
store i32 10, i32* %15
%16 = load i32, i32* %6
%17 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 3
store i32 %16, i32* %17
%18 = load i32, i32* %5
%19 = sub nsw i32 %18, 1
%20 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 4
store i32 %19, i32* %20
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1900
%23 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 5
store i32 %22, i32* %23
%24 = call i32 @mktime(%struct.tm* %8)
store i32 %24, i32* %9
%25 = load i32, i32* %9
%26 = load i32, i32* %7
%27 = sub nsw i32 %25, %26
%28 = sdiv i32 %27, 3600
%29 = sdiv i32 %28, 24
store i32 %29, i32* %10
%30 = load i32, i32* %10
ret i32 %30
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define i32 @dateDiff(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.tm
%6 = bitcast i32* %4 to i8*
%7 = call i32 @time(i32* %4)
%8 = bitcast %struct.tm* %5 to i8*
%9 = call i32 @memset(%struct.tm* %5, i32 0, i32 24)
%10 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
store i32 10, i32* %10
%11 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
store i32 10, i32* %11
%12 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
store i32 10, i32* %12
%13 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
store i32 %2, i32* %13
%14 = add nsw i32 %1, -1
%15 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 4
store i32 %14, i32* %15
%16 = add nsw i32 %0, -1900
%17 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 5
store i32 %16, i32* %17
%18 = call i32 @mktime(%struct.tm* %5)
%19 = load i32, i32* %4
%20 = sub nsw i32 %18, %19
%21 = sdiv i32 %20, 86400
ret i32 %21
}