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

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
uint32_t date_format() {
  time_t t = time(NULL);
  struct tm *tptr = localtime(&t);
  uint32_t time_stamp;
  time_stamp = ((tptr->tm_year - 80) << 25) + ((tptr->tm_mon + 1) << 21) +
               ((tptr->tm_mday) << 16) + (tptr->tm_hour << 11) +
               (tptr->tm_min << 5) + ((tptr->tm_sec) % 60) / 2;
  return time_stamp;
}


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

x86 assembly (clang, -O2):
<date_format>:
push   %rax
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
movdqu (%rax),%xmm1
movdqa 0xebe(%rip),%xmm0
pmuludq %xmm1,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pshufd $0xf5,%xmm1,%xmm1
pmuludq 0xeb8(%rip),%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm0
mov    0x10(%rax),%ecx
shl    $0x5,%ecx
movslq 0x14(%rax),%rax
imul   $0xffffffff88888889,%rax,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%esi
shr    $0x1f,%esi
shr    $0x5,%edx
add    %esi,%edx
imul   $0x3c,%edx,%edx
sub    %edx,%eax
mov    %eax,%edx
shr    $0x7,%dl
add    %al,%dl
sar    %dl
movsbl %dl,%eax
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%edx
add    %ecx,%edx
add    %edx,%eax
add    $0x60200000,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define i32 @date_format() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = call %struct.tm* @localtime(i32* %1)
%5 = bitcast %struct.tm* %4 to <4 x i32>*
%6 = load <4 x i32>, <4 x i32>* %5
%7 = shl <4 x i32> %6, <i32 25, i32 21, i32 16, i32 11>
%8 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%9 = load i32, i32* %8
%10 = shl i32 %9, 5
%11 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%12 = load i32, i32* %11
%13 = srem i32 %12, 60
%14 = trunc i32 %13 to i8
%15 = sdiv i8 %14, 2
%16 = sext i8 %15 to i32
%17 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %7)
%18 = add i32 %17, %10
%19 = add i32 %18, 1612709888
%20 = add i32 %19, %16
ret i32 %20
}