#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 dummy;
};
struct timespec {
  int /*<<< orphan*/ tv_sec;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
void time_show() {
  struct timespec ts;
  clock_gettime(CLOCK_REALTIME, &ts);
  struct tm *value = localtime(&ts.tv_sec);
  char buf[64];
  strftime(buf, sizeof(buf), "%r", value);
  printf("time %s\n", buf);
}


x86 assembly (clang, -O0):
<time_show>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
call   1040 <clock_gettime@plt>
lea    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x40,%esi
lea    0xe85(%rip),%rdx
call   1060 <strftime@plt>
lea    -0x50(%rbp),%rsi
lea    0xe78(%rip),%rdi
call   1050 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_show>:
push   %rbx
sub    $0x50,%rsp
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
call   1040 <clock_gettime@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xe96(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x40,%esi
mov    %rax,%rcx
call   1060 <strftime@plt>
lea    0xe7d(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i32 }
%struct.tm = type { i32 }
@CLOCK_REALTIME = global i32 0
@.str = [3 x i8] c"%r\00"
@.str.1 = [9 x i8] c"time %s\0A\00"
define void @time_show() {
%1 = alloca %struct.timespec
%2 = alloca %struct.tm*
%3 = alloca [64 x i8]
%4 = load i32, i32* @CLOCK_REALTIME
%5 = call i32 @clock_gettime(i32 %4, %struct.timespec* %1)
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%7 = call %struct.tm* @localtime(i32* %6)
store %struct.tm* %7, %struct.tm** %2
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%9 = load %struct.tm*, %struct.tm** %2
%10 = call i32 @strftime(i8* %8, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %9)
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%12 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %11)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
%struct.tm = type { i32 }
@CLOCK_REALTIME = global i32 0
@.str = [3 x i8] c"%r\00"
@.str.1 = [9 x i8] c"time %s\0A\00"
define void @time_show() {
%1 = alloca %struct.timespec
%2 = alloca [64 x i8]
%3 = bitcast %struct.timespec* %1 to i8*
%4 = load i32, i32* @CLOCK_REALTIME
%5 = call i32 @clock_gettime(i32 %4, %struct.timespec* %1)
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%7 = call %struct.tm* @localtime(i32* %6)
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%9 = call i32 @strftime(i8* %8, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %7)
%10 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %8)
ret void
}