#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;
};
struct timeval {
  long tv_usec;
};

/* Variables and functions */
char *calloc(int, int);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, long);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *generateId() {
  char *obuf = calloc(81, sizeof(char));
  char tbuf[80] = {0};
  time_t timer;
  struct tm *tm_info;
  time(&timer);
  tm_info = localtime(&timer);
  strftime(tbuf, 80, "%Y%m%d%H%M%S", tm_info);
  struct timeval tv;
  gettimeofday(&tv, NULL);
  long t = tv.tv_usec;
  snprintf(obuf, 80, "%s%ld", tbuf, t);
  return obuf;
}


x86 assembly (clang, -O0):
<generateId>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    $0x51,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x8(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1060 <memset@plt>
lea    -0x64(%rbp),%rdi
call   1080 <time@plt>
lea    -0x64(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x70(%rbp),%rcx
mov    $0x50,%esi
lea    0xe38(%rip),%rdx
call   1090 <strftime@plt>
lea    -0x78(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x78(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rcx
mov    -0x80(%rbp),%r8
mov    $0x50,%esi
lea    0xe13(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generateId>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    $0x51,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xe4f(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x50,%esi
mov    %rax,%rcx
call   1080 <strftime@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    (%rsp),%r8
lea    0xe32(%rip),%rdx
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rbx,%rcx
call   1040 <snprintf@plt>
mov    %r14,%rax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
%struct.timeval = type { i64 }
@.str = [13 x i8] c"%Y%m%d%H%M%S\00"
@.str.1 = [6 x i8] c"%s%ld\00"
define i8* @generateId() {
%1 = alloca i8*
%2 = alloca [80 x i8]
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca %struct.timeval
%6 = alloca i64
%7 = call i8* @calloc(i32 81, i32 1)
store i8* %7, i8** %1
%8 = bitcast [80 x i8]* %2 to i8*
%9 = call i32 @time(i32* %3)
%10 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %10, %struct.tm** %4
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%12 = load %struct.tm*, %struct.tm** %4
%13 = call i32 @strftime(i8* %11, i32 80, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %struct.tm* %12)
%14 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%16 = load i64, i64* %15
store i64 %16, i64* %6
%17 = load i8*, i8** %1
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%19 = load i64, i64* %6
%20 = call i32 @snprintf(i8* %17, i32 80, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %18, i64 %19)
%21 = load i8*, i8** %1
ret i8* %21
}

LLVM IR (-O2):
%struct.timeval = type { i64 }
%struct.tm = type { i32 }
@.str = [13 x i8] c"%Y%m%d%H%M%S\00"
@.str.1 = [6 x i8] c"%s%ld\00"
define i8* @generateId() {
%1 = alloca [80 x i8]
%2 = alloca i32
%3 = alloca %struct.timeval
%4 = tail call dereferenceable_or_null(81) i8* @calloc(i32 81, i32 1)
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%6 = bitcast i32* %2 to i8*
%7 = call i32 @time(i32* %2)
%8 = call %struct.tm* @localtime(i32* %2)
%9 = call i32 @strftime(i8* %5, i32 80, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %struct.tm* %8)
%10 = bitcast %struct.timeval* %3 to i8*
%11 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%13 = load i64, i64* %12
%14 = call i32 @snprintf(i8* %4, i32 80, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i64 %13)
ret i8* %4
}