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

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
double modJulianDate(struct tm *);
int /*<<< orphan*/ printf(char *, int, int, int, int, int, int);
void setCnboxTime(time_t theTime, char *destString) {
  struct tm *now_tm;
  now_tm = gmtime(&theTime);
  printf("Set Time (UTC): %02d:%02d:%02d %02d-%02d-%04d\n", now_tm->tm_hour,
         now_tm->tm_min, now_tm->tm_sec, now_tm->tm_mday, now_tm->tm_mon + 1,
         now_tm->tm_year + 1900);
  double mjd = modJulianDate(now_tm);
  int mjd_int = mjd;
  destString[0] = (mjd_int >> 8);
  destString[1] = (mjd_int & 0xff);
  destString[2] = now_tm->tm_hour;
  destString[3] = now_tm->tm_min;
  destString[4] = now_tm->tm_sec;
}


x86 assembly (clang, -O0):
<setCnboxTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x4(%rbp),%rdi
call   1050 <gmtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%r8d
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%r9d
add    $0x1,%r9d
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%eax
add    $0x76c,%eax
lea    0xe79(%rip),%rdi
mov    %eax,(%rsp)
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <modJulianDate@plt>
movsd  %xmm0,-0x20(%rbp)
cvttsd2si -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x24(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setCnboxTime>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %edi,0x14(%rsp)
lea    0x14(%rsp),%rdi
call   1050 <gmtime@plt>
mov    %rax,%rbx
mov    (%rax),%esi
mov    0x4(%rax),%edx
mov    0x8(%rax),%ecx
mov    0xc(%rax),%r8d
mov    0x10(%rax),%r9d
add    $0x1,%r9d
mov    $0x76c,%eax
add    0x14(%rbx),%eax
mov    %eax,(%rsp)
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <modJulianDate@plt>
cvttsd2si %xmm0,%eax
rol    $0x8,%ax
mov    %ax,(%r14)
mov    (%rbx),%al
mov    %al,0x2(%r14)
mov    0x4(%rbx),%al
mov    %al,0x3(%r14)
mov    0x8(%rbx),%al
mov    %al,0x4(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [47 x i8] c"Set Time (UTC): %02d:%02d:%02d %02d-%02d-%04d\0A\00"
define void @setCnboxTime(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.tm*
%6 = alloca double
%7 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%8 = call %struct.tm* @gmtime(i32* %3)
store %struct.tm* %8, %struct.tm** %5
%9 = load %struct.tm*, %struct.tm** %5
%10 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = load %struct.tm*, %struct.tm** %5
%13 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 1
%14 = load i32, i32* %13
%15 = load %struct.tm*, %struct.tm** %5
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 2
%17 = load i32, i32* %16
%18 = load %struct.tm*, %struct.tm** %5
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 3
%20 = load i32, i32* %19
%21 = load %struct.tm*, %struct.tm** %5
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 4
%23 = load i32, i32* %22
%24 = add nsw i32 %23, 1
%25 = load %struct.tm*, %struct.tm** %5
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 5
%27 = load i32, i32* %26
%28 = add nsw i32 %27, 1900
%29 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %14, i32 %17, i32 %20, i32 %24, i32 %28)
%30 = load %struct.tm*, %struct.tm** %5
%31 = call double @modJulianDate(%struct.tm* %30)
store double %31, double* %6
%32 = load double, double* %6
%33 = fptosi double %32 to i32
store i32 %33, i32* %7
%34 = load i32, i32* %7
%35 = ashr i32 %34, 8
%36 = trunc i32 %35 to i8
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 0
store i8 %36, i8* %38
%39 = load i32, i32* %7
%40 = and i32 %39, 255
%41 = trunc i32 %40 to i8
%42 = load i8*, i8** %4
%43 = getelementptr inbounds i8, i8* %42, i64 1
store i8 %41, i8* %43
%44 = load %struct.tm*, %struct.tm** %5
%45 = getelementptr inbounds %struct.tm, %struct.tm* %44, i32 0, i32 0
%46 = load i32, i32* %45
%47 = trunc i32 %46 to i8
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i64 2
store i8 %47, i8* %49
%50 = load %struct.tm*, %struct.tm** %5
%51 = getelementptr inbounds %struct.tm, %struct.tm* %50, i32 0, i32 1
%52 = load i32, i32* %51
%53 = trunc i32 %52 to i8
%54 = load i8*, i8** %4
%55 = getelementptr inbounds i8, i8* %54, i64 3
store i8 %53, i8* %55
%56 = load %struct.tm*, %struct.tm** %5
%57 = getelementptr inbounds %struct.tm, %struct.tm* %56, i32 0, i32 2
%58 = load i32, i32* %57
%59 = trunc i32 %58 to i8
%60 = load i8*, i8** %4
%61 = getelementptr inbounds i8, i8* %60, i64 4
store i8 %59, i8* %61
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [47 x i8] c"Set Time (UTC): %02d:%02d:%02d %02d-%02d-%04d\0A\00"
define void @setCnboxTime(i32 %0, i8* nocapture writeonly %1) {
%3 = alloca i32
store i32 %0, i32* %3
%4 = call %struct.tm* @gmtime(i32* %3)
%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 i32, i32* %11
%13 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1
%16 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1900
%19 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8, i32 %10, i32 %12, i32 %15, i32 %18)
%20 = call double @modJulianDate(%struct.tm* %4)
%21 = fptosi double %20 to i32
%22 = lshr i32 %21, 8
%23 = trunc i32 %22 to i8
store i8 %23, i8* %1
%24 = trunc i32 %21 to i8
%25 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %24, i8* %25
%26 = load i32, i32* %5
%27 = trunc i32 %26 to i8
%28 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %27, i8* %28
%29 = load i32, i32* %7
%30 = trunc i32 %29 to i8
%31 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %30, i8* %31
%32 = load i32, i32* %9
%33 = trunc i32 %32 to i8
%34 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %33, i8* %34
ret void
}