#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 */
scalar_t__ calloc(int, int);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char const *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *get_tm_format(const char *tm_format) {
  time_t clocker;
  struct tm *tm;
  char buf[20], bufs[20], *p;
  time(&clocker);
  tm = localtime(&clocker);
  strftime(buf, sizeof(buf), tm_format, tm);
  sprintf(bufs, "%s", buf);
  p = (char *)calloc(sizeof(char), 20);
  strcpy(p, bufs);
  return p;
}


x86 assembly (clang, -O0):
<get_tm_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1060 <time@plt>
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x14,%esi
call   1070 <strftime@plt>
lea    -0x50(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xe59(%rip),%rsi
call   1080 <sprintf@plt>
mov    $0x1,%edi
mov    $0x14,%esi
call   1050 <calloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x58(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tm_format>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%r14
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   1070 <strftime@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    $0x1,%edi
mov    $0x14,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [3 x i8] c"%s\00"
define i8* @get_tm_format(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca [20 x i8]
%6 = alloca [20 x i8]
%7 = alloca i8*
store i8* %0, i8** %2
%8 = call i32 @time(i32* %3)
%9 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %9, %struct.tm** %4
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%11 = load i8*, i8** %2
%12 = load %struct.tm*, %struct.tm** %4
%13 = call i32 @strftime(i8* %10, i32 20, i8* %11, %struct.tm* %12)
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i64 @calloc(i32 1, i32 20)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %7
%19 = load i8*, i8** %7
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%21 = call i32 @strcpy(i8* %19, i8* %20)
%22 = load i8*, i8** %7
ret i8* %22
}

LLVM IR (-O2):
%struct.tm = type { i32 }
define i8* @get_tm_format(i8* %0) {
%2 = alloca i32
%3 = alloca [20 x i8]
%4 = alloca [20 x i8]
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%8 = call i32 @time(i32* %2)
%9 = call %struct.tm* @localtime(i32* %2)
%10 = call i32 @strftime(i8* %6, i32 20, i8* %0, %struct.tm* %9)
%11 = call i8* bitcast (i32 (i8*, i8*)* @strcpy to i8* (i8*, i8*)*)(i8* %7, i8* %6)
%12 = call i64 @calloc(i32 1, i32 20)
%13 = inttoptr i64 %12 to i8*
%14 = call i32 @strcpy(i8* %13, i8* %7)
ret i8* %13
}