#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*/ time(int /*<<< orphan*/ *);
char *format_time() {
  static char myTime[50];
  time_t rawtime;
  struct tm *timeinfo;
  time(&rawtime);
  timeinfo = localtime(&rawtime);
  sprintf(myTime, "%d:%d:%d", timeinfo->tm_hour, timeinfo->tm_min,
          timeinfo->tm_sec);
  return myTime;
}


x86 assembly (clang, -O0):
<format_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x4(%rbp),%rdi
call   1040 <time@plt>
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8d
lea    0x2ee6(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1050 <sprintf@plt>
lea    0x2ed3(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@format_time.myTime = internal global [50 x i8] zeroinitializer
@.str = [9 x i8] c"%d:%d:%d\00"
define i8* @format_time() {
%1 = alloca i32
%2 = alloca %struct.tm*
%3 = call i32 @time(i32* %1)
%4 = call %struct.tm* @localtime(i32* %1)
store %struct.tm* %4, %struct.tm** %2
%5 = load %struct.tm*, %struct.tm** %2
%6 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 0
%7 = load i32, i32* %6
%8 = load %struct.tm*, %struct.tm** %2
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 1
%10 = load i32, i32* %9
%11 = load %struct.tm*, %struct.tm** %2
%12 = getelementptr inbounds %struct.tm, %struct.tm* %11, i32 0, i32 2
%13 = load i32, i32* %12
%14 = call i32 @sprintf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @format_time.myTime, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10, i32 %13)
ret i8* getelementptr inbounds ([50 x i8], [50 x i8]* @format_time.myTime, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@format_time.myTime = internal global [50 x i8] zeroinitializer
@.str = [9 x i8] c"%d:%d:%d\00"
define i8* @format_time() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @time(i32* %1)
%4 = call %struct.tm* @localtime(i32* %1)
%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* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @format_time.myTime, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8, i32 %10)
ret i8* getelementptr inbounds ([50 x i8], [50 x i8]* @format_time.myTime, i64 0, i64 0)
}