#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_sec;
  int tm_min;
  int tm_hour;
  int tm_year;
  int /*<<< orphan*/ tm_mon;
  int /*<<< orphan*/ tm_mday;
};

/* Variables and functions */
int /*<<< orphan*/ julian2mmdd(int, int, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int /*<<< orphan*/ mktime(struct tm *);
int v5dDaysToYYDDD(int);
time_t vis5d_time2ctime(int daystamp, int timestamp) {
  struct tm ctm;
  int yyddd, jday;
  ctm.tm_sec = timestamp % 60;
  ctm.tm_min = (timestamp / 60) % 60;
  ctm.tm_hour = timestamp / 3600;
  yyddd = v5dDaysToYYDDD(daystamp);
  ctm.tm_year = yyddd / 1000 - 1900;
  jday = yyddd - 1000 * (yyddd / 1000);
  julian2mmdd(ctm.tm_year, jday, &ctm.tm_mon, &ctm.tm_mday);
  ctm.tm_mon--;
  return mktime(&ctm);
}


x86 assembly (clang, -O0):
<vis5d_time2ctime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <v5dDaysToYYDDD@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
sub    $0x76c,%eax
mov    %eax,-0x14(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%esi
lea    -0x20(%rbp),%rdx
add    $0x10,%rdx
lea    -0x20(%rbp),%rcx
add    $0x14,%rcx
call   1040 <julian2mmdd@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <mktime@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vis5d_time2ctime>:
sub    $0x18,%rsp
movslq %esi,%rcx
imul   $0xffffffff88888889,%rcx,%rax
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x5,%eax
add    %edx,%eax
imul   $0x3c,%eax,%edx
imul   $0xffffffff91a2b3c5,%rcx,%rsi
shr    $0x20,%rsi
add    %ecx,%esi
sub    %edx,%ecx
mov    %ecx,(%rsp)
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x3c,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x4(%rsp)
mov    %esi,%eax
shr    $0x1f,%eax
sar    $0xb,%esi
add    %eax,%esi
mov    %esi,0x8(%rsp)
call   1030 <v5dDaysToYYDDD@plt>
movslq %eax,%rsi
imul   $0x10624dd3,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
lea    (%rax,%rcx,1),%edx
lea    (%rax,%rcx,1),%edi
add    $0xfffff894,%edi
mov    %edi,0xc(%rsp)
imul   $0xfffffc18,%edx,%eax
add    %eax,%esi
lea    0x10(%rsp),%rdx
lea    0x14(%rsp),%rcx
call   1040 <julian2mmdd@plt>
addl   $0xffffffff,0x10(%rsp)
mov    %rsp,%rdi
call   1050 <mktime@plt>
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define i32 @vis5d_time2ctime(i32 %0, i32 %1) {
%3 = alloca %struct.tm
%4 = bitcast %struct.tm* %3 to i8*
%5 = srem i32 %1, 60
%6 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
store i32 %5, i32* %6
%7 = sdiv i32 %1, 60
%8 = srem i32 %7, 60
%9 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
store i32 %8, i32* %9
%10 = sdiv i32 %1, 3600
%11 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
store i32 %10, i32* %11
%12 = tail call i32 @v5dDaysToYYDDD(i32 %0)
%13 = sdiv i32 %12, 1000
%14 = add nsw i32 %13, -1900
%15 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 3
store i32 %14, i32* %15
%16 = mul nsw i32 %13, -1000
%17 = add i32 %16, %12
%18 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 4
%19 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 5
%20 = call i32 @julian2mmdd(i32 %14, i32 %17, i32* %18, i32* %19)
%21 = load i32, i32* %18
%22 = add nsw i32 %21, -1
store i32 %22, i32* %18
%23 = call i32 @mktime(%struct.tm* %3)
ret i32 %23
}