#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 dummy;
};
typedef int /*<<< orphan*/ part;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char const *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void print_time(const char *format) {
  static char part[512];
  time_t current_time = time(NULL);
  struct tm *current_tm = localtime(&current_time);
  (void)strftime(part, sizeof(part), format, current_tm);
  printf("%s", part);
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0x2edc(%rip),%rdi
mov    $0x200,%esi
call   1060 <strftime@plt>
lea    0xe7b(%rip),%rdi
lea    0x2ec4(%rip),%rsi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
lea    0x2eed(%rip),%r14
mov    %r14,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1060 <strftime@plt>
lea    0xe83(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@print_time.part = internal global [512 x i8] zeroinitializer
@.str = [3 x i8] c"%s\00"
define void @print_time(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.tm*
store i8* %0, i8** %2
%5 = call i32 @time(i32* null)
store i32 %5, i32* %3
%6 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %6, %struct.tm** %4
%7 = load i8*, i8** %2
%8 = load %struct.tm*, %struct.tm** %4
%9 = call i32 @strftime(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @print_time.part, i64 0, i64 0), i32 512, i8* %7, %struct.tm* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([512 x i8], [512 x i8]* @print_time.part, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@print_time.part = internal global [512 x i8] zeroinitializer
@.str = [3 x i8] c"%s\00"
define void @print_time(i8* %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 = call i32 @strftime(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @print_time.part, i64 0, i64 0), i32 512, i8* %0, %struct.tm* %5)
%7 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([512 x i8], [512 x i8]* @print_time.part, i64 0, i64 0))
ret void
}