#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 */
struct tm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fatal(char *);
char *malloc(size_t const);
int /*<<< orphan*/ strftime(char *, size_t const, char *, struct tm const *);
char *format_build_date(const struct tm *time) {
  const size_t length = 24;
  char *buffer = malloc(length * sizeof(char));
  if (buffer == NULL) {
    fatal("Error allocating memory for formatted time string.");
  }
  strftime(buffer, length, "%Y-%m-%d %H:%M:%S UTC", time);
  return buffer;
}


x86 assembly (clang, -O0):
<format_build_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x18,-0x10(%rbp)
mov    $0x18,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1169 <format_build_date+0x39>
lea    0xe9c(%rip),%rdi
call   1050 <fatal@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x18,%esi
lea    0xeb6(%rip),%rdx
call   1040 <strftime@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_build_date>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x18,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1155 <format_build_date+0x25>
lea    0xeb0(%rip),%rdi
call   1050 <fatal@plt>
lea    0xed7(%rip),%rdx
mov    $0x18,%esi
mov    %rbx,%rdi
mov    %r14,%rcx
call   1040 <strftime@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [51 x i8] c"Error allocating memory for formatted time string.\00"
@.str.1 = [22 x i8] c"%Y-%m-%d %H:%M:%S UTC\00"
define i8* @format_build_date(%struct.tm* %0) {
%2 = alloca %struct.tm*
%3 = alloca i64
%4 = alloca i8*
store %struct.tm* %0, %struct.tm** %2
store i64 24, i64* %3
%5 = call i8* @malloc(i64 24)
store i8* %5, i8** %4
%6 = load i8*, i8** %4
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @fatal(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = load i8*, i8** %4
%12 = load %struct.tm*, %struct.tm** %2
%13 = call i32 @strftime(i8* %11, i64 24, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %12)
%14 = load i8*, i8** %4
ret i8* %14
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [51 x i8] c"Error allocating memory for formatted time string.\00"
@.str.1 = [22 x i8] c"%Y-%m-%d %H:%M:%S UTC\00"
define i8* @format_build_date(%struct.tm* %0) {
%2 = tail call dereferenceable_or_null(24) i8* @malloc(i64 24)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @fatal(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = tail call i32 @strftime(i8* %2, i64 24, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %0)
ret i8* %2
}