#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_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void UTL_GetDicomTime(char *timestr) {
  struct tm *tf;
  time_t loctime;
  loctime = time((time_t *)NULL);
  tf = localtime(&loctime);
  sprintf(timestr, "%02d%02d%02d.%06d", (tf->tm_hour), (tf->tm_min),
          (tf->tm_sec), 0);
  return;
}


x86 assembly (clang, -O0):
<UTL_GetDicomTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8d
lea    0xe8b(%rip),%rsi
xor    %r9d,%r9d
call   1050 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UTL_GetDicomTime>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
xor    %r9d,%r9d
call   1050 <sprintf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@.str = [18 x i8] c"%02d%02d%02d.%06d\00"
define void @UTL_GetDicomTime(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.tm*
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 @time(i32* null)
store i32 %5, i32* %4
%6 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %6, %struct.tm** %3
%7 = load i8*, i8** %2
%8 = load %struct.tm*, %struct.tm** %3
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = load %struct.tm*, %struct.tm** %3
%12 = getelementptr inbounds %struct.tm, %struct.tm* %11, i32 0, i32 1
%13 = load i32, i32* %12
%14 = load %struct.tm*, %struct.tm** %3
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 2
%16 = load i32, i32* %15
%17 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %13, i32 %16, i32 0)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@.str = [18 x i8] c"%02d%02d%02d.%06d\00"
define void @UTL_GetDicomTime(i8* nocapture writeonly %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @time(i32* null)
store i32 %4, i32* %2
%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 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%11 = load i32, i32* %10
%12 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9, i32 %11, i32 0)
ret void
}