#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 tm_hour;
  int tm_min;
  int /*<<< orphan*/ tm_sec;
};
struct timezone {
  int dummy;
};
struct timeval {
  int /*<<< orphan*/ tv_usec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
struct tm *localtime(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int /*<<< orphan*/,
                           int /*<<< orphan*/);
char *get_utime(void) {
  struct timeval tv;
  struct timezone tz;
  struct tm *tm;
  char *utime = (char *)malloc(16);
  gettimeofday(&tv, &tz);
  tm = localtime(&tv.tv_sec);
  sprintf(utime, " %d%02d%02d%lu", tm->tm_hour, tm->tm_min, tm->tm_sec,
          tv.tv_usec);
  return utime;
}


x86 assembly (clang, -O0):
<get_utime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <gettimeofday@plt>
lea    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x8(%rbp),%r9d
lea    0xe68(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_utime>:
push   %rbx
sub    $0x10,%rsp
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1040 <gettimeofday@plt>
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
mov    (%rsp),%r9d
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1060 <sprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

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

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