#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 uint32_t;
typedef int /*<<< orphan*/ 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 */
struct tm *localtime(int /*<<< orphan*/ *);
uint32_t time_to_dos_file_time(time_t *t) {
  struct tm *tm = localtime(t);
  return (tm->tm_sec / 2) + ((tm->tm_min) << 5) + ((tm->tm_hour) << 11) +
         ((tm->tm_mday) << 16) + ((tm->tm_mon + 1) << 21) +
         ((tm->tm_year - 80) << 25);
}


x86 assembly (clang, -O0):
<time_to_dos_file_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%rcx
mov    0x4(%rcx),%ecx
shl    $0x5,%ecx
add    %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%ecx
shl    $0xb,%ecx
add    %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0xc(%rcx),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x10(%rcx),%ecx
add    $0x1,%ecx
shl    $0x15,%ecx
add    %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x14(%rcx),%ecx
sub    $0x50,%ecx
shl    $0x19,%ecx
add    %ecx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_to_dos_file_time>:
push   %rax
call   1030 <localtime@plt>
mov    (%rax),%ecx
mov    0x4(%rax),%edx
mov    %ecx,%esi
shr    $0x1f,%esi
add    %ecx,%esi
sar    %esi
shl    $0x5,%edx
add    %esi,%edx
mov    0x8(%rax),%ecx
shl    $0xb,%ecx
add    %edx,%ecx
mov    0xc(%rax),%edx
shl    $0x10,%edx
add    %ecx,%edx
mov    0x10(%rax),%ecx
shl    $0x15,%ecx
add    %edx,%ecx
mov    0x14(%rax),%eax
shl    $0x19,%eax
add    %ecx,%eax
add    $0x60200000,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define i32 @time_to_dos_file_time(i32* %0) {
%2 = tail call %struct.tm* @localtime(i32* %0)
%3 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
%4 = load i32, i32* %3
%5 = sdiv i32 %4, 2
%6 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 1
%7 = load i32, i32* %6
%8 = shl i32 %7, 5
%9 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 2
%10 = load i32, i32* %9
%11 = shl i32 %10, 11
%12 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 3
%13 = load i32, i32* %12
%14 = shl i32 %13, 16
%15 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 4
%16 = load i32, i32* %15
%17 = shl i32 %16, 21
%18 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 5
%19 = load i32, i32* %18
%20 = shl i32 %19, 25
%21 = add i32 %5, 1612709888
%22 = add i32 %21, %8
%23 = add i32 %22, %11
%24 = add i32 %23, %14
%25 = add i32 %24, %17
%26 = add i32 %25, %20
ret i32 %26
}