#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 tm_mon;
  int tm_mday;
  int tm_year;
  int tm_hour;
  int tm_min;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int);
char *timestamp(time_t clock) {
  char *b = (char *)malloc(16);
  struct tm *t = localtime(&clock);
  sprintf(b, "%02d/%02d/%02d %02d:%02d", t->tm_mon + 1, t->tm_mday,
          t->tm_year % 100, t->tm_hour, t->tm_min);
  return b;
}


x86 assembly (clang, -O0):
<timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x10,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0x64,%esi
cltd
idiv   %esi
mov    %edx,%r8d
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%eax
lea    0xe68(%rip),%rsi
mov    %eax,(%rsp)
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timestamp>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,0xc(%rsp)
mov    $0x10,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%edx
mov    0x4(%rax),%ecx
add    $0x1,%edx
movslq 0x8(%rax),%r8
imul   $0x51eb851f,%r8,%rsi
mov    %rsi,%rdi
shr    $0x3f,%rdi
sar    $0x25,%rsi
add    %edi,%esi
imul   $0x64,%esi,%esi
sub    %esi,%r8d
mov    0xc(%rax),%r9d
mov    0x10(%rax),%eax
mov    %eax,(%rsp)
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32 }
@.str = [25 x i8] c"%02d/%02d/%02d %02d:%02d\00"
define i8* @timestamp(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.tm*
store i32 %0, i32* %2
%5 = call i64 @malloc(i32 16)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %3
%7 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %7, %struct.tm** %4
%8 = load i8*, i8** %3
%9 = load %struct.tm*, %struct.tm** %4
%10 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = add nsw i32 %11, 1
%13 = load %struct.tm*, %struct.tm** %4
%14 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 1
%15 = load i32, i32* %14
%16 = load %struct.tm*, %struct.tm** %4
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 2
%18 = load i32, i32* %17
%19 = srem i32 %18, 100
%20 = load %struct.tm*, %struct.tm** %4
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 3
%22 = load i32, i32* %21
%23 = load %struct.tm*, %struct.tm** %4
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 4
%25 = load i32, i32* %24
%26 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %15, i32 %19, i32 %22, i32 %25)
%27 = load i8*, i8** %3
ret i8* %27
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32 }
@.str = [25 x i8] c"%02d/%02d/%02d %02d:%02d\00"
define i8* @timestamp(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = tail call i64 @malloc(i32 16)
%4 = inttoptr i64 %3 to i8*
%5 = call %struct.tm* @localtime(i32* %2)
%6 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%7 = load i32, i32* %6
%8 = add nsw i32 %7, 1
%9 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%12 = load i32, i32* %11
%13 = srem i32 %12, 100
%14 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 4
%17 = load i32, i32* %16
%18 = call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %10, i32 %13, i32 %15, i32 %17)
ret i8* %4
}