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

/* Variables and functions */
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mktime(struct tm *);
time_t mz_zip_dos_to_time_t(int dos_time, int dos_date) {
  struct tm tm;
  memset(&tm, 0, sizeof(tm));
  tm.tm_isdst = -1;
  tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900;
  tm.tm_mon = ((dos_date >> 5) & 15) - 1;
  tm.tm_mday = dos_date & 31;
  tm.tm_hour = (dos_time >> 11) & 31;
  tm.tm_min = (dos_time >> 5) & 63;
  tm.tm_sec = (dos_time << 1) & 62;
  return mktime(&tm);
}


x86 assembly (clang, -O0):
<mz_zip_dos_to_time_t>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x1c,%edx
call   1030 <memset@plt>
movl   $0xffffffff,-0x28(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x9,%eax
and    $0x7f,%eax
add    $0x7bc,%eax
sub    $0x76c,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x5,%eax
and    $0xf,%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1f,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
sar    $0xb,%eax
and    $0x1f,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x5,%eax
and    $0x3f,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
and    $0x3e,%eax
mov    %eax,-0x10(%rbp)
lea    -0x28(%rbp),%rdi
call   1040 <mktime@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mz_zip_dos_to_time_t>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1c,%edx
call   1030 <memset@plt>
movl   $0xffffffff,(%rsp)
mov    %ebx,%eax
shr    $0x9,%eax
and    $0x7f,%eax
add    $0x50,%eax
mov    %eax,0x4(%rsp)
mov    %ebx,%eax
shr    $0x5,%eax
and    $0xf,%eax
add    $0xffffffff,%eax
mov    %eax,0x8(%rsp)
and    $0x1f,%ebx
mov    %ebx,0xc(%rsp)
mov    %ebp,%eax
shr    $0xb,%eax
and    $0x1f,%eax
mov    %eax,0x10(%rsp)
mov    %ebp,%eax
shr    $0x5,%eax
and    $0x3f,%eax
mov    %eax,0x14(%rsp)
add    %ebp,%ebp
and    $0x3e,%ebp
mov    %ebp,0x18(%rsp)
mov    %r14,%rdi
call   1040 <mktime@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
define i32 @mz_zip_dos_to_time_t(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.tm
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32 @memset(%struct.tm* %5, i32 0, i32 28)
%7 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 0
store i32 -1, i32* %7
%8 = load i32, i32* %4
%9 = ashr i32 %8, 9
%10 = and i32 %9, 127
%11 = add nsw i32 %10, 1980
%12 = sub nsw i32 %11, 1900
%13 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 1
store i32 %12, i32* %13
%14 = load i32, i32* %4
%15 = ashr i32 %14, 5
%16 = and i32 %15, 15
%17 = sub nsw i32 %16, 1
%18 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 2
store i32 %17, i32* %18
%19 = load i32, i32* %4
%20 = and i32 %19, 31
%21 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 3
store i32 %20, i32* %21
%22 = load i32, i32* %3
%23 = ashr i32 %22, 11
%24 = and i32 %23, 31
%25 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 4
store i32 %24, i32* %25
%26 = load i32, i32* %3
%27 = ashr i32 %26, 5
%28 = and i32 %27, 63
%29 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 5
store i32 %28, i32* %29
%30 = load i32, i32* %3
%31 = shl i32 %30, 1
%32 = and i32 %31, 62
%33 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 6
store i32 %32, i32* %33
%34 = call i32 @mktime(%struct.tm* %5)
ret i32 %34
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
define i32 @mz_zip_dos_to_time_t(i32 %0, i32 %1) {
%3 = alloca %struct.tm
%4 = bitcast %struct.tm* %3 to i8*
%5 = call i32 @memset(%struct.tm* %3, i32 0, i32 28)
%6 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
store i32 -1, i32* %6
%7 = lshr i32 %1, 9
%8 = and i32 %7, 127
%9 = add nuw nsw i32 %8, 80
%10 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
store i32 %9, i32* %10
%11 = lshr i32 %1, 5
%12 = and i32 %11, 15
%13 = add nsw i32 %12, -1
%14 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
store i32 %13, i32* %14
%15 = and i32 %1, 31
%16 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 3
store i32 %15, i32* %16
%17 = lshr i32 %0, 11
%18 = and i32 %17, 31
%19 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 4
store i32 %18, i32* %19
%20 = lshr i32 %0, 5
%21 = and i32 %20, 63
%22 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 5
store i32 %21, i32* %22
%23 = shl i32 %0, 1
%24 = and i32 %23, 62
%25 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 6
store i32 %24, i32* %25
%26 = call i32 @mktime(%struct.tm* %3)
ret i32 %26
}