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

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ getchar();
struct tm *getdate(char const *);
int /*<<< orphan*/ mktime(struct tm *);
int /*<<< orphan*/ printf(char *, char const *, ...);
int main(void) {
  char const *time_str = "2011-07-20 17:30:18";
  struct tm *time_tm;
  time_tm = getdate(time_str);
  printf("%p\n", time_tm);
  getchar();
  time_t t = mktime(time_tm);
  printf("str: %s and time: %s", time_str, ctime(&t));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getdate@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x18(%rbp),%rdi
call   1070 <mktime@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <ctime@plt>
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%r14
mov    %r14,%rdi
call   1060 <getdate@plt>
mov    %rax,%rbx
lea    0xea7(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %rbx,%rdi
call   1070 <mktime@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <ctime@plt>
lea    0xe7d(%rip),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [20 x i8] c"2011-07-20 17:30:18\00"
@.str.1 = [4 x i8] c"%p\0A\00"
@.str.2 = [21 x i8] c"str: %s and time: %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca %struct.tm*
%4 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = load i8*, i8** %2
%6 = call %struct.tm* @getdate(i8* %5)
store %struct.tm* %6, %struct.tm** %3
%7 = load %struct.tm*, %struct.tm** %3
%8 = bitcast %struct.tm* %7 to i8*
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = call i32 (...) @getchar()
%11 = load %struct.tm*, %struct.tm** %3
%12 = call i32 @mktime(%struct.tm* %11)
store i32 %12, i32* %4
%13 = load i8*, i8** %2
%14 = call i8* @ctime(i32* %4)
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %13, i8* %14)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [20 x i8] c"2011-07-20 17:30:18\00"
@.str.1 = [4 x i8] c"%p\0A\00"
@.str.2 = [21 x i8] c"str: %s and time: %s\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call %struct.tm* @getdate(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%3 = bitcast %struct.tm* %2 to i8*
%4 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%5 = tail call i32 (...) @getchar()
%6 = bitcast i32* %1 to i8*
%7 = tail call i32 @mktime(%struct.tm* %2)
store i32 %7, i32* %1
%8 = call i8* @ctime(i32* %1)
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %8)
ret i32 0
}