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

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int, int, int, int, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  time_t now;
  struct tm *tm_now;
  time(&now);
  tm_now = localtime(&now);
  printf("now datetime: 20%d-%d-%d %d:%d:%d\n", tm_now->tm_year - 100,
         tm_now->tm_mon + 1, tm_now->tm_mday, tm_now->tm_hour, tm_now->tm_min,
         tm_now->tm_sec);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1050 <time@plt>
lea    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
sub    $0x64,%esi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xe73(%rip),%rdi
mov    %eax,(%rsp)
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    (%rax),%esi
mov    0x4(%rax),%edx
add    $0xffffff9c,%esi
add    $0x1,%edx
mov    0x8(%rax),%ecx
mov    0xc(%rax),%r8d
mov    0x10(%rax),%r9d
mov    0x14(%rax),%eax
mov    %eax,(%rsp)
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [35 x i8] c"now datetime: 20%d-%d-%d %d:%d:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.tm*
store i32 0, i32* %1
%4 = call i32 @time(i32* %2)
%5 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %5, %struct.tm** %3
%6 = load %struct.tm*, %struct.tm** %3
%7 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 0
%8 = load i32, i32* %7
%9 = sub nsw i32 %8, 100
%10 = load %struct.tm*, %struct.tm** %3
%11 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 1
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1
%14 = load %struct.tm*, %struct.tm** %3
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 2
%16 = load i32, i32* %15
%17 = load %struct.tm*, %struct.tm** %3
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 3
%19 = load i32, i32* %18
%20 = load %struct.tm*, %struct.tm** %3
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 4
%22 = load i32, i32* %21
%23 = load %struct.tm*, %struct.tm** %3
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 5
%25 = load i32, i32* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %13, i32 %16, i32 %19, i32 %22, i32 %25)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [35 x i8] c"now datetime: 20%d-%d-%d %d:%d:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @time(i32* %1)
%4 = call %struct.tm* @localtime(i32* %1)
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%6 = load i32, i32* %5
%7 = add nsw i32 %6, -100
%8 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%9 = load i32, i32* %8
%10 = add nsw i32 %9, 1
%11 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10, i32 %12, i32 %14, i32 %16, i32 %18)
ret i32 0
}