#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 scalar_t__ time_t;
struct tm {
  scalar_t__ tm_sec;
  scalar_t__ tm_min;
  scalar_t__ tm_hour;
};

/* Variables and functions */
struct tm *localtime(scalar_t__ *);
long timer_to_time(time_t time_secs) {
  struct tm *time_struct;
  if (time_secs == 0)
    return (0);
  else {
    time_struct = localtime(&time_secs);
    if (time_struct)
      return ((long)(time_struct->tm_hour) * 1000000L +
              (long)(time_struct->tm_min) * 10000L +
              (long)(time_struct->tm_sec) * 100 + (0));
    else
      return (0);
  }
}


x86 assembly (clang, -O0):
<timer_to_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1134 <timer_to_time+0x24>
movq   $0x0,-0x8(%rbp)
jmp    1187 <timer_to_time+0x77>
lea    -0x10(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117f <timer_to_time+0x6f>
mov    -0x18(%rbp),%rax
imul   $0xf4240,0x10(%rax),%rax
mov    -0x18(%rbp),%rcx
imul   $0x2710,0x8(%rcx),%rcx
add    %rcx,%rax
mov    -0x18(%rbp),%rcx
imul   $0x64,(%rcx),%rcx
add    %rcx,%rax
add    $0x0,%rax
mov    %rax,-0x8(%rbp)
jmp    1187 <timer_to_time+0x77>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timer_to_time>:
push   %rax
mov    %rdi,(%rsp)
test   %rdi,%rdi
je     1143 <timer_to_time+0x33>
mov    %rsp,%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     1143 <timer_to_time+0x33>
imul   $0xf4240,0x10(%rax),%rcx
imul   $0x2710,0x8(%rax),%rdx
add    %rcx,%rdx
imul   $0x64,(%rax),%rax
add    %rdx,%rax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.tm = type { i64, i64, i64 }
define i64 @timer_to_time(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca %struct.tm*
store i64 %0, i64* %3
%5 = load i64, i64* %3
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i64 0, i64* %2
br label %29
8: ; preds = %1
%9 = call %struct.tm* @localtime(i64* %3)
store %struct.tm* %9, %struct.tm** %4
%10 = load %struct.tm*, %struct.tm** %4
%11 = icmp ne %struct.tm* %10, null
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load %struct.tm*, %struct.tm** %4
%14 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 2
%15 = load i64, i64* %14
%16 = mul nsw i64 %15, 1000000
%17 = load %struct.tm*, %struct.tm** %4
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 1
%19 = load i64, i64* %18
%20 = mul nsw i64 %19, 10000
%21 = add nsw i64 %16, %20
%22 = load %struct.tm*, %struct.tm** %4
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 0
%24 = load i64, i64* %23
%25 = mul nsw i64 %24, 100
%26 = add nsw i64 %21, %25
%27 = add nsw i64 %26, 0
store i64 %27, i64* %2
br label %29
28: ; preds = %8
store i64 0, i64* %2
br label %29
29: ; preds = %28, %12, %7
%30 = load i64, i64* %2
ret i64 %30
}

LLVM IR (-O2):
%struct.tm = type { i64, i64, i64 }
define i64 @timer_to_time(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = icmp eq i64 %0, 0
br i1 %3, label %19, label %4
4: ; preds = %1
%5 = call %struct.tm* @localtime(i64* %2)
%6 = icmp eq %struct.tm* %5, null
br i1 %6, label %19, label %7
7: ; preds = %4
%8 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%9 = load i64, i64* %8
%10 = mul nsw i64 %9, 1000000
%11 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%12 = load i64, i64* %11
%13 = mul nsw i64 %12, 10000
%14 = add nsw i64 %13, %10
%15 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%16 = load i64, i64* %15
%17 = mul nsw i64 %16, 100
%18 = add nsw i64 %14, %17
br label %19
19: ; preds = %4, %1, %7
%20 = phi i64 [ %18, %7 ], [ 0, %1 ], [ 0, %4 ]
ret i64 %20
}