#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_mday;
  int tm_mon;
  int tm_year;
  int tm_sec;
  int tm_min;
  int tm_hour;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void FAT_date_time(unsigned short *Date, unsigned short *Time) {
  time_t t = time(NULL);
  struct tm *time_local = localtime(&t);
  *Date = (time_local->tm_mday | ((time_local->tm_mon + 1) << 5) |
           ((time_local->tm_year - 80) << 9));
  *Time = (time_local->tm_sec / 2 | (time_local->tm_min << 5) |
           (time_local->tm_hour << 11));
}


x86 assembly (clang, -O0):
<FAT_date_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0x20(%rbp),%rcx
mov    0x4(%rcx),%ecx
add    $0x1,%ecx
shl    $0x5,%ecx
or     %ecx,%eax
mov    -0x20(%rbp),%rcx
mov    0x8(%rcx),%ecx
sub    $0x50,%ecx
shl    $0x9,%ecx
or     %ecx,%eax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%rcx
mov    0x10(%rcx),%ecx
shl    $0x5,%ecx
or     %ecx,%eax
mov    -0x20(%rbp),%rcx
mov    0x14(%rcx),%ecx
shl    $0xb,%ecx
or     %ecx,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FAT_date_time>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    0x4(%rax),%ecx
shl    $0x5,%ecx
add    $0x20,%ecx
or     (%rax),%ecx
mov    0x8(%rax),%edx
shl    $0x9,%edx
add    $0x6000,%edx
or     %ecx,%edx
mov    %dx,(%rbx)
mov    0xc(%rax),%ecx
mov    0x10(%rax),%edx
mov    %ecx,%esi
shr    $0x1f,%esi
add    %ecx,%esi
shr    %esi
shl    $0x5,%edx
mov    0x14(%rax),%eax
shl    $0xb,%eax
or     %edx,%eax
or     %esi,%eax
mov    %ax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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