#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 scalar_t__ uint16_t;
typedef int /*<<< orphan*/ time_t;
struct tm {
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
uint16_t fat_from_unix_time(time_t seconds) {
  struct tm *time_str;
  uint16_t fattime;
  time_str = gmtime(&seconds);
  fattime = 0;
  fattime += time_str->tm_hour << 11;
  fattime += time_str->tm_min << 5;
  fattime += time_str->tm_sec >> 1;
  return fattime;
}


x86 assembly (clang, -O0):
<fat_from_unix_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <gmtime@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
shl    $0xb,%eax
cltq
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
shl    $0x5,%eax
cltq
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
sar    $0x1,%eax
cltq
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fat_from_unix_time>:
push   %rax
mov    %edi,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <gmtime@plt>
mov    (%rax),%ecx
mov    0x4(%rax),%edx
shl    $0xb,%ecx
movslq %ecx,%rcx
shl    $0x5,%edx
movslq %edx,%rdx
add    %rcx,%rdx
mov    0x8(%rax),%eax
sar    %eax
cltq
add    %rdx,%rax
pop    %rcx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
define i64 @fat_from_unix_time(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca i64
store i32 %0, i32* %2
%5 = call %struct.tm* @gmtime(i32* %2)
store %struct.tm* %5, %struct.tm** %3
store i64 0, i64* %4
%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 = shl i32 %8, 11
%10 = sext i32 %9 to i64
%11 = load i64, i64* %4
%12 = add nsw i64 %11, %10
store i64 %12, i64* %4
%13 = load %struct.tm*, %struct.tm** %3
%14 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 1
%15 = load i32, i32* %14
%16 = shl i32 %15, 5
%17 = sext i32 %16 to i64
%18 = load i64, i64* %4
%19 = add nsw i64 %18, %17
store i64 %19, i64* %4
%20 = load %struct.tm*, %struct.tm** %3
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 2
%22 = load i32, i32* %21
%23 = ashr i32 %22, 1
%24 = sext i32 %23 to i64
%25 = load i64, i64* %4
%26 = add nsw i64 %25, %24
store i64 %26, i64* %4
%27 = load i64, i64* %4
ret i64 %27
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
define i64 @fat_from_unix_time(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call %struct.tm* @gmtime(i32* %2)
%4 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
%5 = load i32, i32* %4
%6 = shl i32 %5, 11
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
%9 = load i32, i32* %8
%10 = shl i32 %9, 5
%11 = sext i32 %10 to i64
%12 = add nsw i64 %11, %7
%13 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
%14 = load i32, i32* %13
%15 = ashr i32 %14, 1
%16 = sext i32 %15 to i64
%17 = add nsw i64 %12, %16
ret i64 %17
}