#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;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
int /*<<< orphan*/ time(int /*<<< orphan*/);
extern char *str_date_yymmdd() {
  time_t t = time(0);
  struct tm *tp = localtime(&t);
  static char buf[10 + 1];
  sprintf(buf, "%04d-%02d-%02d", tp->tm_year + 1900, tp->tm_mon + 1,
          tp->tm_mday);
  return buf;
}


x86 assembly (clang, -O0):
<str_date_yymmdd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
add    $0x76c,%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8d
lea    0x2ec5(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1050 <sprintf@plt>
lea    0x2eb2(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_date_yymmdd>:
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    $0x76c,%edx
add    (%rax),%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
add    $0x1,%ecx
lea    0x2ed7(%rip),%rbx
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@str_date_yymmdd.buf = internal global [11 x i8] zeroinitializer
@.str = [15 x i8] c"%04d-%02d-%02d\00"
define i8* @str_date_yymmdd() {
%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 = add nsw i32 %6, 1900
%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 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str_date_yymmdd.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10, i32 %12)
ret i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str_date_yymmdd.buf, i64 0, i64 0)
}