#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 */
int /*<<< orphan*/ get_localtime(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ log_err(int /*<<< orphan*/, char *);
char *malloc(int const);
int /*<<< orphan*/ out_of_memory();
scalar_t__ strftime(char *, int const, char *, struct tm *);
char *create_short_time_string(time_t t) {
  char *p;
  struct tm tm;
  const int len = 12;
  if (!(p = malloc(len))) {
    out_of_memory();
  }
  get_localtime(&t, &tm);
  if (strftime(p, len, "%m-%d %H:%M", &tm) == 0) {
    log_err(0, "strftime() failed");
  }
  return (p);
}


x86 assembly (clang, -O0):
<create_short_time_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xc,-0x1c(%rbp)
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1181 <create_short_time_string+0x31>
mov    $0x0,%al
call   1030 <out_of_memory@plt>
lea    -0x4(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <get_localtime@plt>
mov    -0x10(%rbp),%rdi
mov    $0xc,%esi
lea    0xe62(%rip),%rdx
lea    -0x18(%rbp),%rcx
call   1050 <strftime@plt>
cmp    $0x0,%rax
jne    11bf <create_short_time_string+0x6f>
xor    %edi,%edi
lea    0xe52(%rip),%rsi
call   1070 <log_err@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_short_time_string>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,0xc(%rsp)
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1174 <create_short_time_string+0x24>
xor    %eax,%eax
call   1030 <out_of_memory@plt>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%r14
mov    %r14,%rsi
call   1060 <get_localtime@plt>
lea    0xe73(%rip),%rdx
mov    %rbx,%rdi
mov    $0xc,%esi
mov    %r14,%rcx
call   1050 <strftime@plt>
test   %rax,%rax
jne    11b0 <create_short_time_string+0x60>
lea    0xe63(%rip),%rsi
xor    %edi,%edi
call   1070 <log_err@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [12 x i8] c"%m-%d %H:%M\00"
@.str.1 = [18 x i8] c"strftime() failed\00"
define i8* @create_short_time_string(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.tm
%5 = alloca i32
store i32 %0, i32* %2
store i32 12, i32* %5
%6 = call i8* @malloc(i32 12)
store i8* %6, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 (...) @out_of_memory()
br label %10
10: ; preds = %8, %1
%11 = call i32 @get_localtime(i32* %2, %struct.tm* %4)
%12 = load i8*, i8** %3
%13 = call i64 @strftime(i8* %12, i32 12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 @log_err(i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %10
%18 = load i8*, i8** %3
ret i8* %18
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [12 x i8] c"%m-%d %H:%M\00"
@.str.1 = [18 x i8] c"strftime() failed\00"
define i8* @create_short_time_string(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.tm
store i32 %0, i32* %2
%4 = bitcast %struct.tm* %3 to i8*
%5 = tail call dereferenceable_or_null(12) i8* @malloc(i32 12)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 (...) @out_of_memory()
br label %9
9: ; preds = %7, %1
%10 = call i32 @get_localtime(i32* %2, %struct.tm* %3)
%11 = call i64 @strftime(i8* %5, i32 12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.tm* %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @log_err(i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
ret i8* %5
}