#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 uint32_t;
typedef scalar_t__ time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
char *asctime(struct tm *);
struct tm *gmtime(scalar_t__ *);
struct tm *localtime(scalar_t__ *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strtoul(char *, char **, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  time_t rawtime;
  char *tail;
  struct tm *timeinfo;
  if (argc != 2) {
    printf("usage: %s <time>\n", argv[0]);
    printf("\tWhere <time> is a ZCL UTCTime value in hex (0x prefix)\n");
    printf("\tor decimal (no prefix).\n");
    return 0;
  }
  rawtime = (time_t)strtoul(argv[1], &tail, 0);
  if (!tail) {
    printf("Error trying to convert '%s'.\n", argv[1]);
    return -1;
  }
  rawtime += (((uint32_t)30 * 365 + 7) * 24 * 60 * 60);
  timeinfo = gmtime(&rawtime);
  printf("  ZCL = '%s'\n  UTC = %s", argv[1], asctime(timeinfo));
  timeinfo = localtime(&rawtime);
  printf("local = %s", asctime(timeinfo));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ad <main+0x5d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1264 <main+0x114>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1070 <strtoul@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11f1 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1264 <main+0x114>
mov    -0x18(%rbp),%rax
add    $0x386d4380,%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <asctime@plt>
mov    -0x30(%rbp),%rsi
mov    %rax,%rdx
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <asctime@plt>
mov    %rax,%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11e6 <main+0x86>
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
xor    %ebp,%ebp
xor    %edx,%edx
call   1080 <strtoul@plt>
cmpq   $0x0,(%rsp)
je     1213 <main+0xb3>
add    $0x386d4380,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   1070 <gmtime@plt>
mov    0x8(%rbx),%rbx
mov    %rax,%rdi
call   1050 <asctime@plt>
lea    0xe7b(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1030 <localtime@plt>
mov    %rax,%rdi
call   1050 <asctime@plt>
lea    0xe6f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    122a <main+0xca>
mov    (%rbx),%rsi
lea    0xe10(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe54(%rip),%rdi
call   1040 <puts@plt>
lea    0xe80(%rip),%rdi
call   1040 <puts@plt>
jmp    122a <main+0xca>
mov    0x8(%rbx),%rsi
lea    0xdf4(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"usage: %s <time>\0A\00"
@.str.1 = [57 x i8] c"\09Where <time> is a ZCL UTCTime value in hex (0x prefix)\0A\00"
@.str.2 = [26 x i8] c"\09or decimal (no prefix).\0A\00"
@.str.3 = [31 x i8] c"Error trying to convert '%s'.\0A\00"
@.str.4 = [24 x i8] c" ZCL = '%s'\0A UTC = %s\00"
@.str.5 = [11 x i8] c"local = %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca %struct.tm*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %44
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strtoul(i8* %21, i8** %7, i32 0)
store i64 %22, i64* %6
%23 = load i8*, i8** %7
%24 = icmp ne i8* %23, null
br i1 %24, label %30, label %25
25: ; preds = %18
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %28)
store i32 -1, i32* %3
br label %44
30: ; preds = %18
%31 = load i64, i64* %6
%32 = add nsw i64 %31, 946684800
store i64 %32, i64* %6
%33 = call %struct.tm* @gmtime(i64* %6)
store %struct.tm* %33, %struct.tm** %8
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = load %struct.tm*, %struct.tm** %8
%38 = call i8* @asctime(%struct.tm* %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %36, i8* %38)
%40 = call %struct.tm* @localtime(i64* %6)
store %struct.tm* %40, %struct.tm** %8
%41 = load %struct.tm*, %struct.tm** %8
%42 = call i8* @asctime(%struct.tm* %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %42)
store i32 0, i32* %3
br label %44
44: ; preds = %30, %25, %11
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"usage: %s <time>\0A\00"
@.str.3 = [31 x i8] c"Error trying to convert '%s'.\0A\00"
@.str.4 = [24 x i8] c" ZCL = '%s'\0A UTC = %s\00"
@.str.5 = [11 x i8] c"local = %s\00"
@str = [56 x i8] c"\09Where <time> is a ZCL UTCTime value in hex (0x prefix)\00"
@str.6 = [25 x i8] c"\09or decimal (no prefix).\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = bitcast i64* %3 to i8*
%6 = bitcast i8** %4 to i8*
%7 = icmp eq i32 %0, 2
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
br label %31
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strtoul(i8* %15, i8** %4, i32 0)
%17 = load i8*, i8** %4
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i8*, i8** %14
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %20)
br label %31
22: ; preds = %13
%23 = add nsw i64 %16, 946684800
store i64 %23, i64* %3
%24 = call %struct.tm* @gmtime(i64* %3)
%25 = load i8*, i8** %14
%26 = call i8* @asctime(%struct.tm* %24)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %25, i8* %26)
%28 = call %struct.tm* @localtime(i64* %3)
%29 = call i8* @asctime(%struct.tm* %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %22, %19, %8
%32 = phi i32 [ 0, %8 ], [ 0, %22 ], [ -1, %19 ]
ret i32 %32
}