#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_mon;
  int tm_year;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int, int, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ tzset();
char *diagtime() {
  struct tm *tm;
  time_t clock;
  static char buf[1028];
  tzset();
  clock = time(NULL);
  tm = localtime(&clock);
  tm->tm_mon++;
  tm->tm_year -= 100;
  snprintf(buf, sizeof(buf), "%.2d.%.2d.%.2d %.2d:%.2d:%.2d", tm->tm_mday,
           tm->tm_mon, tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec);
  return buf;
}


x86 assembly (clang, -O0):
<diagtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1050 <tzset@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%ecx
sub    $0x64,%ecx
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%r8d
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%r9d
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%r11d
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%eax
lea    0x2e9c(%rip),%rdi
mov    $0x404,%esi
lea    0xe40(%rip),%rdx
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <snprintf@plt>
lea    0x2e77(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diagtime>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <tzset@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%r8d
mov    0x4(%rax),%r9d
add    $0x1,%r8d
mov    %r8d,(%rax)
add    $0xffffff9c,%r9d
mov    %r9d,0x4(%rax)
mov    0x8(%rax),%ecx
mov    0xc(%rax),%r10d
mov    0x10(%rax),%ebx
mov    0x14(%rax),%eax
sub    $0x8,%rsp
lea    0x2ec2(%rip),%r14
lea    0xe6b(%rip),%rdx
mov    %r14,%rdi
mov    $0x404,%esi
push   %rax
push   %rbx
push   %r10
call   1040 <snprintf@plt>
add    $0x20,%rsp
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@diagtime.buf = internal global [1028 x i8] zeroinitializer
@.str = [30 x i8] c"%.2d.%.2d.%.2d %.2d:%.2d:%.2d\00"
define i8* @diagtime() {
%1 = alloca %struct.tm*
%2 = alloca i32
%3 = call i32 (...) @tzset()
%4 = call i32 @time(i32* null)
store i32 %4, i32* %2
%5 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %5, %struct.tm** %1
%6 = load %struct.tm*, %struct.tm** %1
%7 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 0
%8 = load i32, i32* %7
%9 = add nsw i32 %8, 1
store i32 %9, i32* %7
%10 = load %struct.tm*, %struct.tm** %1
%11 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 1
%12 = load i32, i32* %11
%13 = sub nsw i32 %12, 100
store i32 %13, i32* %11
%14 = load %struct.tm*, %struct.tm** %1
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 2
%16 = load i32, i32* %15
%17 = load %struct.tm*, %struct.tm** %1
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = load %struct.tm*, %struct.tm** %1
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = load %struct.tm*, %struct.tm** %1
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 3
%25 = load i32, i32* %24
%26 = load %struct.tm*, %struct.tm** %1
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 4
%28 = load i32, i32* %27
%29 = load %struct.tm*, %struct.tm** %1
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 5
%31 = load i32, i32* %30
%32 = call i32 @snprintf(i8* getelementptr inbounds ([1028 x i8], [1028 x i8]* @diagtime.buf, i64 0, i64 0), i32 1028, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %19, i32 %22, i32 %25, i32 %28, i32 %31)
ret i8* getelementptr inbounds ([1028 x i8], [1028 x i8]* @diagtime.buf, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@diagtime.buf = internal global [1028 x i8] zeroinitializer
@.str = [30 x i8] c"%.2d.%.2d.%.2d %.2d:%.2d:%.2d\00"
define i8* @diagtime() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @tzset()
%4 = tail call i32 @time(i32* null)
store i32 %4, i32* %1
%5 = call %struct.tm* @localtime(i32* %1)
%6 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%7 = load i32, i32* %6
%8 = add nsw i32 %7, 1
store i32 %8, i32* %6
%9 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%10 = load i32, i32* %9
%11 = add nsw i32 %10, -100
store i32 %11, i32* %9
%12 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 4
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 5
%19 = load i32, i32* %18
%20 = call i32 @snprintf(i8* getelementptr inbounds ([1028 x i8], [1028 x i8]* @diagtime.buf, i64 0, i64 0), i32 1028, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %8, i32 %11, i32 %15, i32 %17, i32 %19)
ret i8* getelementptr inbounds ([1028 x i8], [1028 x i8]* @diagtime.buf, i64 0, i64 0)
}