#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 timeval {
  int /*<<< orphan*/ tv_usec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
scalar_t__ strlen(char *);
int getTime(char *buffer) {
  char tbuff[30];
  struct timeval tv;
  time_t curtime;
  gettimeofday(&tv, NULL);
  curtime = tv.tv_sec;
  strftime(tbuff, 30, "%m-%d-%Y %T.", localtime(&curtime));
  snprintf(buffer, 30, "%s%ld", tbuff, tv.tv_usec);
  return (int)strlen(buffer);
}


x86 assembly (clang, -O0):
<getTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x3c(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%ecx
mov    $0x1e,%esi
lea    0xe6e(%rip),%rdx
call   1070 <strftime@plt>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8d
mov    $0x1e,%esi
lea    0xe5e(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getTime>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    0xc(%rsp),%eax
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe81(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x1e,%esi
mov    %eax,%ecx
call   1070 <strftime@plt>
mov    0x8(%rsp),%r8d
lea    0xe6e(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1e,%esi
mov    %r14,%rcx
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [13 x i8] c"%m-%d-%Y %T.\00"
@.str.1 = [6 x i8] c"%s%ld\00"
define i32 @getTime(i8* %0) {
%2 = alloca [30 x i8]
%3 = alloca %struct.timeval
%4 = alloca i32
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%6 = bitcast %struct.timeval* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%10 = load i32, i32* %9
store i32 %10, i32* %4
%11 = call i32 @localtime(i32* %4)
%12 = call i32 @strftime(i8* %5, i32 30, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%14 = load i32, i32* %13
%15 = call i32 @snprintf(i8* %0, i32 30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 %14)
%16 = call i64 @strlen(i8* dereferenceable(1) %0)
%17 = trunc i64 %16 to i32
ret i32 %17
}