#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*/ uint32_t;
typedef int /*<<< orphan*/ t;
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
scalar_t__ timegm(struct tm *);
uint32_t OS_conv_datenum(int32_t datenum, int32_t hour, int32_t minute,
                         int32_t second) {
  struct tm t;
  memset(&t, 0, sizeof(t));
  t.tm_year = (datenum / 10000) - 1900, t.tm_mon = ((datenum / 100) % 100) - 1,
  t.tm_mday = (datenum % 100);
  t.tm_hour = hour, t.tm_min = minute, t.tm_sec = second;
  return ((uint32_t)timegm(&t));
}


x86 assembly (clang, -O0):
<OS_conv_datenum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
mov    -0x4(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
sub    $0x76c,%eax
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    $0x64,%ecx
cltd
idiv   %ecx
sub    $0x1,%edx
mov    %edx,-0x24(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    -0x28(%rbp),%rdi
call   1040 <timegm@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OS_conv_datenum>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%ebx
mov    %edi,%ebp
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
movslq %ebp,%rax
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
sar    $0x2c,%rdx
shr    $0x3f,%rcx
add    %edx,%ecx
add    $0xfffff894,%ecx
mov    %ecx,0x8(%rsp)
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
movslq %ecx,%rcx
imul   $0x51eb851f,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x25,%rdx
add    %esi,%edx
imul   $0x64,%edx,%edx
not    %edx
add    %ecx,%edx
mov    %edx,0xc(%rsp)
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp)
mov    %ebx,0x14(%rsp)
mov    %r12d,0x18(%rsp)
mov    %r15d,0x1c(%rsp)
mov    %r14,%rdi
call   1040 <timegm@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define i32 @OS_conv_datenum(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.tm
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = call i32 @memset(%struct.tm* %9, i32 0, i32 24)
%11 = load i32, i32* %5
%12 = sdiv i32 %11, 10000
%13 = sub nsw i32 %12, 1900
%14 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 0
store i32 %13, i32* %14
%15 = load i32, i32* %5
%16 = sdiv i32 %15, 100
%17 = srem i32 %16, 100
%18 = sub nsw i32 %17, 1
%19 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 1
store i32 %18, i32* %19
%20 = load i32, i32* %5
%21 = srem i32 %20, 100
%22 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 2
store i32 %21, i32* %22
%23 = load i32, i32* %6
%24 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 3
store i32 %23, i32* %24
%25 = load i32, i32* %7
%26 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 4
store i32 %25, i32* %26
%27 = load i32, i32* %8
%28 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 5
store i32 %27, i32* %28
%29 = call i64 @timegm(%struct.tm* %9)
%30 = trunc i64 %29 to i32
ret i32 %30
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define i32 @OS_conv_datenum(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.tm
%6 = bitcast %struct.tm* %5 to i8*
%7 = call i32 @memset(%struct.tm* %5, i32 0, i32 24)
%8 = sdiv i32 %0, 10000
%9 = add nsw i32 %8, -1900
%10 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
store i32 %9, i32* %10
%11 = sdiv i32 %0, 100
%12 = srem i32 %11, 100
%13 = add nsw i32 %12, -1
%14 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
store i32 %13, i32* %14
%15 = srem i32 %0, 100
%16 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
store i32 %15, i32* %16
%17 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
store i32 %1, i32* %17
%18 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 4
store i32 %2, i32* %18
%19 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 5
store i32 %3, i32* %19
%20 = call i64 @timegm(%struct.tm* %5)
%21 = trunc i64 %20 to i32
ret i32 %21
}