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

/* Variables and functions */
int /*<<< orphan*/ ctime_r(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
void pathf90_date(char *buf, int len) {
  char inp[80], outp[9 + 1];
  time_t t = time(0);
  ctime_r(&t, inp);
  char *year = inp + strlen(inp) - 3;
  inp[4 + 3] = 0;
  inp[8 + 2] = 0;
  sprintf(outp, "%s-%s-%s", inp + 8, inp + 4, year);
  memset(buf, ' ', len);
  memcpy(buf, outp, (len < 9) ? len : 9);
}


x86 assembly (clang, -O0):
<pathf90_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,-0x70(%rbp)
lea    -0x60(%rbp),%rsi
lea    -0x70(%rbp),%rdi
call   1070 <ctime_r@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x90(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xfffffffffffffffd,%rax
mov    %rax,-0x78(%rbp)
movb   $0x0,-0x59(%rbp)
movb   $0x0,-0x56(%rbp)
lea    -0x6a(%rbp),%rdi
lea    -0x60(%rbp),%rdx
add    $0x8,%rdx
lea    -0x60(%rbp),%rcx
add    $0x4,%rcx
mov    -0x78(%rbp),%r8
lea    0xe25(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    $0x20,%esi
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x6a(%rbp),%rax
mov    %rax,-0x80(%rbp)
cmpl   $0x9,-0xc(%rbp)
jge    121c <pathf90_date+0xbc>
mov    -0xc(%rbp),%eax
mov    %eax,-0x94(%rbp)
jmp    122c <pathf90_date+0xcc>
mov    $0x9,%eax
mov    %eax,-0x94(%rbp)
jmp    122c <pathf90_date+0xcc>
mov    -0x80(%rbp),%rsi
mov    -0x88(%rbp),%rdi
mov    -0x94(%rbp),%edx
call   1050 <memcpy@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pathf90_date>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,(%rsp)
mov    %rsp,%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <ctime_r@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%r8
add    $0xd,%r8
movb   $0x0,0x17(%rsp)
movb   $0x0,0x1a(%rsp)
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0xe4c(%rip),%rsi
lea    0x6(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    $0x20,%esi
mov    %ebp,%edx
call   1040 <memset@plt>
cmp    $0x9,%ebp
mov    $0x9,%edx
cmovl  %ebp,%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <memcpy@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%s-%s-%s\00"
define void @pathf90_date(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [80 x i8]
%6 = alloca [10 x i8]
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = call i32 @time(i32 0)
store i32 %9, i32* %7
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%11 = call i32 @ctime_r(i32* %7, i8* %10)
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 -3
store i8* %17, i8** %8
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 7
store i8 0, i8* %18
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 10
store i8 0, i8* %19
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%22 = getelementptr inbounds i8, i8* %21, i64 8
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%24 = getelementptr inbounds i8, i8* %23, i64 4
%25 = load i8*, i8** %8
%26 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %22, i8* %24, i8* %25)
%27 = load i8*, i8** %3
%28 = load i32, i32* %4
%29 = call i32 @memset(i8* %27, i8 signext 32, i32 %28)
%30 = load i8*, i8** %3
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%32 = load i32, i32* %4
%33 = icmp slt i32 %32, 9
br i1 %33, label %34, label %36
34: ; preds = %2
%35 = load i32, i32* %4
br label %37
36: ; preds = %2
br label %37
37: ; preds = %36, %34
%38 = phi i32 [ %35, %34 ], [ 9, %36 ]
%39 = call i32 @memcpy(i8* %30, i8* %31, i32 %38)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s-%s-%s\00"
define void @pathf90_date(i8* %0, i32 %1) {
%3 = alloca [80 x i8]
%4 = alloca [10 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
%9 = tail call i32 @time(i32 0)
store i32 %9, i32* %5
%10 = call i32 @ctime_r(i32* %5, i8* %6)
%11 = call i32 @strlen(i8* %6)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %12
%14 = getelementptr inbounds i8, i8* %13, i64 -3
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 7
store i8 0, i8* %15
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 10
store i8 0, i8* %16
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 8
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 4
%19 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18, i8* %14)
%20 = call i32 @memset(i8* %0, i8 signext 32, i32 %1)
%21 = icmp slt i32 %1, 9
%22 = select i1 %21, i32 %1, i32 9
%23 = call i32 @memcpy(i8* %0, i8* %7, i32 %22)
ret void
}