#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_mon;
  int tm_sec;
  int tm_hour;
  scalar_t__ tm_year;
  scalar_t__ tm_min;
  scalar_t__ tm_mday;
};

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int get_serial_id(void) {
  unsigned short lo, hi, mid;
  time_t now = time(NULL);
  struct tm tm = gmtime(&now)[0];
  lo = (unsigned short)(tm.tm_mday + ((tm.tm_mon + 1) << 8) + (tm.tm_sec << 8));
  hi = (unsigned short)(tm.tm_min + (tm.tm_hour << 8) + (tm.tm_year + 1900));
  return lo + (hi << 16);
}


x86 assembly (clang, -O0):
<get_serial_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1050 <gmtime@plt>
mov    %rax,%rsi
lea    -0x38(%rbp),%rdi
mov    $0x28,%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
shl    $0x8,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    -0x34(%rbp),%ecx
shl    $0x8,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %ax,-0x2(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%ecx
shl    $0x8,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%rcx
add    $0x76c,%rcx
add    %rcx,%rax
mov    %ax,-0x4(%rbp)
movzwl -0x2(%rbp),%eax
movzwl -0x4(%rbp),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_serial_id>:
push   %rax
xor    %edi,%edi
call   1030 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <gmtime@plt>
mov    0x4(%rax),%ecx
mov    0x8(%rax),%edx
mov    0x20(%rax),%esi
add    (%rax),%ecx
shl    $0x8,%ecx
shl    $0x8,%edx
add    0x10(%rax),%edx
add    0x18(%rax),%edx
lea    (%rcx,%rsi,1),%eax
add    $0x100,%eax
shl    $0x10,%edx
movzwl %ax,%eax
add    %edx,%eax
add    $0x76c0000,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i64, i64, i64 }
define i32 @get_serial_id() {
%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* @gmtime(i32* %1)
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%6 = load i32, i32* %5
%7 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%12 = load i64, i64* %11
%13 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%14 = load i64, i64* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%16 = load i64, i64* %15
%17 = trunc i64 %16 to i32
%18 = add i32 %8, %6
%19 = shl i32 %18, 8
%20 = add i32 %19, 256
%21 = add i32 %20, %17
%22 = shl i32 %10, 8
%23 = zext i32 %22 to i64
%24 = add i64 %12, 1900
%25 = add i64 %24, %23
%26 = add i64 %25, %14
%27 = trunc i64 %26 to i32
%28 = and i32 %21, 65535
%29 = shl i32 %27, 16
%30 = or i32 %28, %29
ret i32 %30
}