#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
struct tm *localtime(int /*<<< orphan*/ *);
int strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
void print_time(FILE *out) {
  char buf[1024];
  time_t t;
  struct tm *currentTime;
  t = time(0);
  currentTime = localtime(&t);
  if (currentTime) {
    int len;
    len = strftime(buf, 1024 - 1, "%d.%m.%Y %H:%M:%S", currentTime);
    if (len) {
      buf[((len) < (1024 - 1) ? (len) : (1024 - 1))] = '\0';
      fprintf(out, "%s", buf);
    }
  }
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,-0x414(%rbp)
lea    -0x414(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
je     120c <print_time+0xcc>
lea    -0x410(%rbp),%rdi
mov    -0x420(%rbp),%rcx
mov    $0x3ff,%esi
lea    0xe69(%rip),%rdx
call   1060 <strftime@plt>
mov    %eax,-0x424(%rbp)
cmpl   $0x0,-0x424(%rbp)
je     1207 <print_time+0xc7>
cmpl   $0x3ff,-0x424(%rbp)
jge    11d0 <print_time+0x90>
mov    -0x424(%rbp),%eax
mov    %eax,-0x428(%rbp)
jmp    11e0 <print_time+0xa0>
mov    $0x3ff,%eax
mov    %eax,-0x428(%rbp)
jmp    11e0 <print_time+0xa0>
mov    -0x428(%rbp),%eax
cltq
movb   $0x0,-0x410(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xe10(%rip),%rsi
call   1040 <fprintf@plt>
jmp    120c <print_time+0xcc>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %rbp
push   %rbx
sub    $0x418,%rsp
mov    %rdi,%rbx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     11a5 <print_time+0x65>
lea    0xe93(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x3ff,%ebp
mov    $0x3ff,%esi
mov    %rax,%rcx
call   1060 <strftime@plt>
test   %eax,%eax
je     11a5 <print_time+0x65>
cmp    $0x3ff,%eax
cmovl  %eax,%ebp
movslq %ebp,%rax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
add    $0x418,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%d.%m.%Y %H:%M:%S\00"
@.str.1 = [3 x i8] c"%s\00"
define void @print_time(i32* %0) {
%2 = alloca i32*
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = alloca %struct.tm*
%6 = alloca i32
store i32* %0, i32** %2
%7 = call i32 @time(i32 0)
store i32 %7, i32* %4
%8 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %8, %struct.tm** %5
%9 = load %struct.tm*, %struct.tm** %5
%10 = icmp ne %struct.tm* %9, null
br i1 %10, label %11, label %31
11: ; preds = %1
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = load %struct.tm*, %struct.tm** %5
%14 = call i32 @strftime(i8* %12, i32 1023, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %11
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 1023
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load i32, i32* %6
br label %23
22: ; preds = %17
br label %23
23: ; preds = %22, %20
%24 = phi i32 [ %21, %20 ], [ 1023, %22 ]
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %25
store i8 0, i8* %26
%27 = load i32*, i32** %2
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%29 = call i32 @fprintf(i32* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %23, %11
br label %31
31: ; preds = %30, %1
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%d.%m.%Y %H:%M:%S\00"
define void @print_time(i32* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
%6 = tail call i32 @time(i32 0)
store i32 %6, i32* %3
%7 = call %struct.tm* @localtime(i32* %3)
%8 = icmp eq %struct.tm* %7, null
br i1 %8, label %18, label %9
9: ; preds = %1
%10 = call i32 @strftime(i8* %4, i32 1023, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %7)
%11 = icmp eq i32 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = icmp slt i32 %10, 1023
%14 = select i1 %13, i32 %10, i32 1023
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %15
store i8 0, i8* %16
%17 = call i32 @fputs(i8* %4, i32* %0)
br label %18
18: ; preds = %9, %12, %1
ret void
}