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

/* Variables and functions */
struct tm *get_date_time();
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
int /*<<< orphan*/ strcpy(char *, char *);
char *hora() {
  char *str, cur[15];
  str = malloc(sizeof(char) * 15);
  struct tm *dc = get_date_time();
  sprintf(cur, "%02d:%02d:%02d", dc->tm_hour, dc->tm_min, dc->tm_sec);
  strcpy(str, cur);
  return str;
}


x86 assembly (clang, -O0):
<hora>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0xf,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <get_date_time@plt>
mov    %rax,-0x20(%rbp)
lea    -0x17(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%r8d
lea    0xe7f(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x17(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hora>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0xf,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <get_date_time@plt>
mov    (%rax),%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
lea    0xe95(%rip),%rsi
lea    0x9(%rsp),%r14
mov    %r14,%rdi
call   1060 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@.str = [15 x i8] c"%02d:%02d:%02d\00"
define i8* @hora() {
%1 = alloca [15 x i8]
%2 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%3 = tail call dereferenceable_or_null(15) i8* @malloc(i32 15)
%4 = tail call %struct.tm* (...) @get_date_time()
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%6 = load i32, i32* %5
%7 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%10 = load i32, i32* %9
%11 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8, i32 %10)
%12 = call i32 @strcpy(i8* %3, i8* %2)
ret i8* %3
}