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

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int, int);
int /*<<< orphan*/ time(int /*<<< orphan*/);
char *yap_stamp(void) {
  static char timestring[28];
  struct tm *tmp;
  time_t currt = time(0);
  tmp = localtime(&currt);
  sprintf(timestring, "[%02d/%02d/%4d:%02d:%02d:%02d] ", tmp->tm_mday,
          tmp->tm_mon, 1900 + tmp->tm_year, tmp->tm_hour, tmp->tm_min,
          tmp->tm_sec);
  return timestring;
}


x86 assembly (clang, -O0):
<yap_stamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%r8d
add    $0x76c,%r8d
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%eax
lea    0x2ec7(%rip),%rdi
lea    0xe70(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1050 <sprintf@plt>
lea    0x2eac(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yap_stamp>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%edx
mov    $0x76c,%r8d
add    0x8(%rax),%r8d
mov    0x4(%rax),%ecx
mov    0xc(%rax),%r9d
mov    0x10(%rax),%ebx
mov    0x14(%rax),%eax
lea    0x2ee7(%rip),%r14
lea    0xe90(%rip),%rsi
mov    %r14,%rdi
push   %rax
push   %rbx
call   1050 <sprintf@plt>
add    $0x10,%rsp
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@yap_stamp.timestring = internal global [28 x i8] zeroinitializer
@.str = [32 x i8] c"[%02d/%02d/%4d:%02d:%02d:%02d] \00"
define i8* @yap_stamp() {
%1 = alloca %struct.tm*
%2 = alloca i32
%3 = call i32 @time(i32 0)
store i32 %3, i32* %2
%4 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %4, %struct.tm** %1
%5 = load %struct.tm*, %struct.tm** %1
%6 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 0
%7 = load i32, i32* %6
%8 = load %struct.tm*, %struct.tm** %1
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 1
%10 = load i32, i32* %9
%11 = load %struct.tm*, %struct.tm** %1
%12 = getelementptr inbounds %struct.tm, %struct.tm* %11, i32 0, i32 2
%13 = load i32, i32* %12
%14 = add nsw i32 1900, %13
%15 = load %struct.tm*, %struct.tm** %1
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 3
%17 = load i32, i32* %16
%18 = load %struct.tm*, %struct.tm** %1
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 4
%20 = load i32, i32* %19
%21 = load %struct.tm*, %struct.tm** %1
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 5
%23 = load i32, i32* %22
%24 = call i32 @sprintf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @yap_stamp.timestring, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10, i32 %14, i32 %17, i32 %20, i32 %23)
ret i8* getelementptr inbounds ([28 x i8], [28 x i8]* @yap_stamp.timestring, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@yap_stamp.timestring = internal global [28 x i8] zeroinitializer
@.str = [32 x i8] c"[%02d/%02d/%4d:%02d:%02d:%02d] \00"
define i8* @yap_stamp() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32 0)
store i32 %3, 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 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1900
%12 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%17 = load i32, i32* %16
%18 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @yap_stamp.timestring, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8, i32 %11, i32 %13, i32 %15, i32 %17)
ret i8* getelementptr inbounds ([28 x i8], [28 x i8]* @yap_stamp.timestring, i64 0, i64 0)
}