#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_mday;
  int tm_year;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
scalar_t__ wMalloc(int);
int /*<<< orphan*/ wPushString(char *);
void wBasDate() {
  time_t t;
  struct tm *tmp;
  char *buffer = (char *)wMalloc(11);
  t = time(NULL);
  tmp = localtime(&t);
  sprintf(buffer, "%02d-%02d-%04d", tmp->tm_mon + 1, tmp->tm_mday,
          tmp->tm_year + 1900);
  wPushString(buffer);
}


x86 assembly (clang, -O0):
<wBasDate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0xb,%edi
call   1050 <wMalloc@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8d
add    $0x76c,%r8d
lea    0xe57(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <wPushString@plt>
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@.str = [15 x i8] c"%02d-%02d-%04d\00"
define void @wBasDate() {
%1 = alloca i32
%2 = alloca %struct.tm*
%3 = alloca i8*
%4 = call i64 @wMalloc(i32 11)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %3
%6 = call i32 @time(i32* null)
store i32 %6, i32* %1
%7 = call %struct.tm* @localtime(i32* %1)
store %struct.tm* %7, %struct.tm** %2
%8 = load i8*, i8** %3
%9 = load %struct.tm*, %struct.tm** %2
%10 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 0
%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 1
%15 = load i32, i32* %14
%16 = load %struct.tm*, %struct.tm** %2
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 2
%18 = load i32, i32* %17
%19 = add nsw i32 %18, 1900
%20 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %15, i32 %19)
%21 = load i8*, i8** %3
%22 = call i32 @wPushString(i8* %21)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@.str = [15 x i8] c"%02d-%02d-%04d\00"
define void @wBasDate() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i64 @wMalloc(i32 11)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @time(i32* null)
store i32 %5, i32* %1
%6 = call %struct.tm* @localtime(i32* %1)
%7 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 0
%8 = load i32, i32* %7
%9 = add nsw i32 %8, 1
%10 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 2
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1900
%15 = call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11, i32 %14)
%16 = call i32 @wPushString(i8* %4)
ret void
}