#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;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char **, int /*<<< orphan*/, int);
int /*<<< orphan*/ strftime(char *, int, char const *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
char *elm_io_get_time(void) {
  static const char *fmt = "%Y-%m-%d %I:%M:%S %p";
  time_t now = time(0);
  struct tm *tstruct = localtime(&now);
  static char buf[128];
  memset(&buf, 0, sizeof(buf));
  strftime(buf, sizeof(buf), fmt, tstruct);
  return buf;
}


x86 assembly (clang, -O0):
<elm_io_get_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    0x2efa(%rip),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
mov    0x2ec7(%rip),%rdx
mov    -0x10(%rbp),%rcx
lea    0x2edc(%rip),%rdi
mov    $0x80,%esi
call   1060 <strftime@plt>
lea    0x2ecb(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<elm_io_get_time>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
lea    0x2eed(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
lea    0xe87(%rip),%rdx
mov    %r14,%rdi
mov    $0x80,%esi
mov    %rbx,%rcx
call   1060 <strftime@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@elm_io_get_time.fmt = internal global i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i32 0, i32 0)
@.str = [21 x i8] c"%Y-%m-%d %I:%M:%S %p\00"
@elm_io_get_time.buf = internal global [128 x i8] zeroinitializer
define i8* @elm_io_get_time() {
%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 = call i32 @memset(i8** bitcast ([128 x i8]* @elm_io_get_time.buf to i8**), i32 0, i32 128)
%6 = load i8*, i8** @elm_io_get_time.fmt
%7 = load %struct.tm*, %struct.tm** %2
%8 = call i32 @strftime(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @elm_io_get_time.buf, i64 0, i64 0), i32 128, i8* %6, %struct.tm* %7)
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @elm_io_get_time.buf, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [21 x i8] c"%Y-%m-%d %I:%M:%S %p\00"
@elm_io_get_time.buf = internal global [128 x i8] zeroinitializer
define i8* @elm_io_get_time() {
%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 = call i32 @memset(i8** bitcast ([128 x i8]* @elm_io_get_time.buf to i8**), i32 0, i32 128)
%6 = call i32 @strftime(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @elm_io_get_time.buf, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @elm_io_get_time.buf, i64 0, i64 0)
}