#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, unsigned int, unsigned long, unsigned int,
                          unsigned int, unsigned int);
unsigned long getCnboxTime(char *nuvotonTimeString) {
  unsigned int mjd =
      ((nuvotonTimeString[0] & 0xFF) * 256) + (nuvotonTimeString[1] & 0xFF);
  unsigned long epoch = ((mjd - 40587) * 86400);
  unsigned int hour = nuvotonTimeString[2] & 0xFF;
  unsigned int min = nuvotonTimeString[3] & 0xFF;
  unsigned int sec = nuvotonTimeString[4] & 0xFF;
  epoch += (hour * 3600 + min * 60 + sec);
  printf("MJD = %d epoch = %ld, time = %02d:%02d:%02d\n", mjd, epoch, hour, min,
         sec);
  return epoch;
}


x86 assembly (clang, -O0):
<getCnboxTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
and    $0xff,%eax
shl    $0x8,%eax
mov    -0x8(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x9e8b,%eax
imul   $0x15180,%eax,%eax
mov    %eax,%eax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%eax
and    $0xff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%eax
and    $0xff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x4(%rax),%eax
and    $0xff,%eax
mov    %eax,-0x24(%rbp)
imul   $0xe10,-0x1c(%rbp),%eax
imul   $0x3c,-0x20(%rbp),%ecx
add    %ecx,%eax
add    -0x24(%rbp),%eax
mov    %eax,%eax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x24(%rbp),%r9d
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCnboxTime>:
push   %rbx
movzwl (%rdi),%esi
shl    $0x10,%esi
bswap  %esi
imul   $0x15180,%esi,%eax
add    $0x2efbbf80,%eax
movzbl 0x2(%rdi),%ecx
movzbl 0x3(%rdi),%r8d
movzbl 0x4(%rdi),%r9d
imul   $0xe10,%rcx,%rdx
imul   $0x3c,%r8,%rbx
add    %rdx,%rbx
add    %r9,%rbx
add    %rax,%rbx
lea    0xeb3(%rip),%rdi
mov    %rbx,%rdx
call   1030 <printf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [45 x i8] c"MJD = %d epoch = %ld, time = %02d:%02d:%02d\0A\00"
define i64 @getCnboxTime(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = and i32 %11, 255
%13 = mul nsw i32 %12, 256
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = and i32 %17, 255
%19 = add nsw i32 %13, %18
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = sub i32 %20, 40587
%22 = mul i32 %21, 86400
%23 = zext i32 %22 to i64
store i64 %23, i64* %4
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i64 2
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = and i32 %27, 255
store i32 %28, i32* %5
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i64 3
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = and i32 %32, 255
store i32 %33, i32* %6
%34 = load i8*, i8** %2
%35 = getelementptr inbounds i8, i8* %34, i64 4
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = and i32 %37, 255
store i32 %38, i32* %7
%39 = load i32, i32* %5
%40 = mul i32 %39, 3600
%41 = load i32, i32* %6
%42 = mul i32 %41, 60
%43 = add i32 %40, %42
%44 = load i32, i32* %7
%45 = add i32 %43, %44
%46 = zext i32 %45 to i64
%47 = load i64, i64* %4
%48 = add i64 %47, %46
store i64 %48, i64* %4
%49 = load i32, i32* %3
%50 = load i64, i64* %4
%51 = load i32, i32* %5
%52 = load i32, i32* %6
%53 = load i32, i32* %7
%54 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %49, i64 %50, i32 %51, i32 %52, i32 %53)
%55 = load i64, i64* %4
ret i64 %55
}

LLVM IR (-O2):
@.str = [45 x i8] c"MJD = %d epoch = %ld, time = %02d:%02d:%02d\0A\00"
define i64 @getCnboxTime(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = zext i8 %2 to i32
%4 = shl nuw nsw i32 %3, 8
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = or i32 %4, %7
%9 = mul i32 %8, 86400
%10 = add i32 %9, 788250496
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 2
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = getelementptr inbounds i8, i8* %0, i64 3
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = getelementptr inbounds i8, i8* %0, i64 4
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = mul nuw nsw i32 %14, 3600
%22 = mul nuw nsw i32 %17, 60
%23 = add nuw nsw i32 %22, %21
%24 = add nuw nsw i32 %23, %20
%25 = zext i32 %24 to i64
%26 = add nuw nsw i64 %25, %11
%27 = tail call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %8, i64 %26, i32 %14, i32 %17, i32 %20)
ret i64 %26
}