#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*/ atoi(char const *);
char *calloc(int, int);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
const char *timestampToLocalTime(const char *timestamp) {
  time_t time;
  char *buffer;
  struct tm *loctime;
  if (!timestamp || !(buffer = calloc(256, sizeof(char))))
    return (NULL);
  time = atoi(timestamp);
  loctime = localtime(&time);
  strftime(buffer, 256, "%D %R", loctime);
  return (buffer);
}


x86 assembly (clang, -O0):
<timestampToLocalTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1174 <timestampToLocalTime+0x34>
mov    $0x100,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1181 <timestampToLocalTime+0x41>
movq   $0x0,-0x8(%rbp)
jmp    11bb <timestampToLocalTime+0x7b>
mov    -0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x100,%esi
lea    0xe52(%rip),%rdx
call   1050 <strftime@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timestampToLocalTime>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1192 <timestampToLocalTime+0x52>
mov    %rdi,%rbx
mov    $0x100,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     1192 <timestampToLocalTime+0x52>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe80(%rip),%rdx
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
jmp    1195 <timestampToLocalTime+0x55>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [6 x i8] c"%D %R\00"
define i8* @timestampToLocalTime(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.tm*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = call i8* @calloc(i32 256, i32 1)
store i8* %10, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %9, %1
store i8* null, i8** %2
br label %21
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %4
%16 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %16, %struct.tm** %6
%17 = load i8*, i8** %5
%18 = load %struct.tm*, %struct.tm** %6
%19 = call i32 @strftime(i8* %17, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.tm* %18)
%20 = load i8*, i8** %5
store i8* %20, i8** %2
br label %21
21: ; preds = %13, %12
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [6 x i8] c"%D %R\00"
define i8* @timestampToLocalTime(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = icmp eq i8* %0, null
br i1 %4, label %12, label %5
5: ; preds = %1
%6 = tail call dereferenceable_or_null(256) i8* @calloc(i32 256, i32 1)
%7 = icmp eq i8* %6, null
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call i32 @atoi(i8* %0)
store i32 %9, i32* %2
%10 = call %struct.tm* @localtime(i32* %2)
%11 = call i32 @strftime(i8* %6, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.tm* %10)
br label %12
12: ; preds = %1, %5, %8
%13 = phi i8* [ %6, %8 ], [ null, %5 ], [ null, %1 ]
ret i8* %13
}