#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 *calloc(int, int);
int /*<<< orphan*/ free(char *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ strftime(char *, int, char const *, struct tm *);
int strlen(char *);
char *Show_Time_CharFormat(time_t time, const char *format) {
  char *date = calloc(100, sizeof(char));
  struct tm *times;
  times = localtime(&time);
  strftime(date, 100, format, times);
  int len = strlen(date) + 1;
  char *date_s = calloc(len, sizeof(char));
  memmove(date_s, date, len);
  free(date);
  return date_s;
}


x86 assembly (clang, -O0):
<Show_Time_CharFormat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x64,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
lea    -0x4(%rbp),%rdi
call   1040 <localtime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x64,%esi
call   1070 <strftime@plt>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1080 <memmove@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Show_Time_CharFormat>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,0xc(%rsp)
mov    $0x64,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%rdi
call   1040 <localtime@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   1070 <strftime@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%ebp
mov    %ebp,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1080 <memmove@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
define i8* @Show_Time_CharFormat(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.tm*
%7 = alloca i32
%8 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%9 = call i8* @calloc(i32 100, i32 1)
store i8* %9, i8** %5
%10 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %10, %struct.tm** %6
%11 = load i8*, i8** %5
%12 = load i8*, i8** %4
%13 = load %struct.tm*, %struct.tm** %6
%14 = call i32 @strftime(i8* %11, i32 100, i8* %12, %struct.tm* %13)
%15 = load i8*, i8** %5
%16 = call i32 @strlen(i8* %15)
%17 = add nsw i32 %16, 1
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = call i8* @calloc(i32 %18, i32 1)
store i8* %19, i8** %8
%20 = load i8*, i8** %8
%21 = load i8*, i8** %5
%22 = load i32, i32* %7
%23 = call i32 @memmove(i8* %20, i8* %21, i32 %22)
%24 = load i8*, i8** %5
%25 = call i32 @free(i8* %24)
%26 = load i8*, i8** %8
ret i8* %26
}

LLVM IR (-O2):
%struct.tm = type { i32 }
define i8* @Show_Time_CharFormat(i32 %0, i8* %1) {
%3 = alloca i32
store i32 %0, i32* %3
%4 = tail call dereferenceable_or_null(100) i8* @calloc(i32 100, i32 1)
%5 = call %struct.tm* @localtime(i32* %3)
%6 = call i32 @strftime(i8* %4, i32 100, i8* %1, %struct.tm* %5)
%7 = call i32 @strlen(i8* %4)
%8 = add nsw i32 %7, 1
%9 = call i8* @calloc(i32 %8, i32 1)
%10 = call i32 @memmove(i8* %9, i8* %4, i32 %8)
%11 = call i32 @free(i8* %4)
ret i8* %9
}