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

/* Variables and functions */
int /*<<< orphan*/ localtime_r(int /*<<< orphan*/ *, struct tm *);
void convert_time_to_msdos_time_and_date(time_t time,
                                         unsigned short *msdos_time,
                                         unsigned short *msdos_date) {
  struct tm tm;
  localtime_r(&time, &tm);
  *msdos_time = (tm.tm_hour << 11) | (tm.tm_min << 5) | ((tm.tm_sec + 1) >> 1);
  *msdos_date = ((tm.tm_year - 80) << 9) | ((tm.tm_mon + 1) << 5) | tm.tm_mday;
}


x86 assembly (clang, -O0):
<convert_time_to_msdos_time_and_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x4(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <localtime_r@plt>
mov    -0x30(%rbp),%eax
shl    $0xb,%eax
mov    -0x2c(%rbp),%ecx
shl    $0x5,%ecx
or     %ecx,%eax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
sar    $0x1,%ecx
or     %ecx,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
mov    -0x24(%rbp),%eax
sub    $0x50,%eax
shl    $0x9,%eax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
shl    $0x5,%ecx
or     %ecx,%eax
or     -0x1c(%rbp),%eax
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_time_to_msdos_time_and_date>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,0xc(%rsp)
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1030 <localtime_r@plt>
mov    0x10(%rsp),%eax
mov    0x14(%rsp),%ecx
shl    $0xb,%eax
shl    $0x5,%ecx
or     %eax,%ecx
mov    0x18(%rsp),%eax
add    $0x1,%eax
shr    %eax
or     %ecx,%eax
mov    %ax,(%rbx)
mov    0x1c(%rsp),%eax
mov    0x20(%rsp),%ecx
shl    $0x9,%eax
add    $0x6000,%eax
shl    $0x5,%ecx
add    $0x20,%ecx
or     0x24(%rsp),%eax
or     %ecx,%eax
mov    %ax,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define void @convert_time_to_msdos_time_and_date(i32 %0, i16* nocapture writeonly %1, i16* nocapture writeonly %2) {
%4 = alloca i32
%5 = alloca %struct.tm
store i32 %0, i32* %4
%6 = bitcast %struct.tm* %5 to i8*
%7 = call i32 @localtime_r(i32* %4, %struct.tm* %5)
%8 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%9 = load i32, i32* %8
%10 = shl i32 %9, 11
%11 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%12 = load i32, i32* %11
%13 = shl i32 %12, 5
%14 = or i32 %13, %10
%15 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 1
%18 = lshr i32 %17, 1
%19 = or i32 %14, %18
%20 = trunc i32 %19 to i16
store i16 %20, i16* %1
%21 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
%22 = load i32, i32* %21
%23 = shl i32 %22, 9
%24 = add i32 %23, 24576
%25 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 4
%26 = load i32, i32* %25
%27 = shl i32 %26, 5
%28 = add i32 %27, 32
%29 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 5
%30 = load i32, i32* %29
%31 = or i32 %30, %24
%32 = or i32 %31, %28
%33 = trunc i32 %32 to i16
store i16 %33, i16* %2
ret void
}