#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 */
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *basic_date() {
  static char datime[128];
  time_t clock;
  char *ptr;
  int i;
  clock = time((time_t *)0);
  ptr = ctime(&clock);
  i = 1;
  while (*ptr && (i < 128)) {
    datime[i - 1] = *ptr;
    i++;
    ptr++;
  }
  datime[i - 1] = *ptr;
  if (datime[i - 2] == '\n')
    datime[i - 2] = 0;
  return (datime);
}


x86 assembly (clang, -O0):
<basic_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x15(%rbp)
je     116a <basic_date+0x4a>
cmpl   $0x80,-0x14(%rbp)
setl   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    117a <basic_date+0x5a>
jmp    11ad <basic_date+0x8d>
mov    -0x10(%rbp),%rax
mov    (%rax),%dl
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2eb0(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1148 <basic_date+0x28>
mov    -0x10(%rbp),%rax
mov    (%rax),%dl
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2e7d(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
movslq %eax,%rcx
lea    0x2e6a(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11f7 <basic_date+0xd7>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
movslq %eax,%rcx
lea    0x2e4d(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e42(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<basic_date>:
push   %rax
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <ctime@plt>
mov    (%rax),%cl
test   %cl,%cl
je     116b <basic_date+0x4b>
mov    $0x1,%edi
lea    0x2ef8(%rip),%rsi
nopl   0x0(%rax,%rax,1)
mov    %cl,-0x1(%rdi,%rsi,1)
lea    0x1(%rdi),%rdx
movzbl (%rax,%rdi,1),%ecx
test   %cl,%cl
je     1172 <basic_date+0x52>
cmp    $0x7f,%rdi
mov    %rdx,%rdi
jb     1150 <basic_date+0x30>
jmp    1172 <basic_date+0x52>
mov    $0x1,%edx
xor    %ecx,%ecx
lea    -0x1(%rdx),%esi
lea    0x2ec4(%rip),%rax
mov    %cl,(%rsi,%rax,1)
movslq %edx,%rcx
cmpb   $0xa,-0x2(%rcx,%rax,1)
jne    118e <basic_date+0x6e>
movb   $0x0,-0x2(%rcx,%rax,1)
lea    0x2eab(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@basic_date.datime = internal global [128 x i8] zeroinitializer
define i8* @basic_date() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = call i32 @time(i32* null)
store i32 %4, i32* %1
%5 = call i8* @ctime(i32* %1)
store i8* %5, i8** %2
store i32 1, i32* %3
br label %6
6: ; preds = %16, %0
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 128
br label %14
14: ; preds = %11, %6
%15 = phi i1 [ false, %6 ], [ %13, %11 ]
br i1 %15, label %16, label %27
16: ; preds = %14
%17 = load i8*, i8** %2
%18 = load i8, i8* %17
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [128 x i8], [128 x i8]* @basic_date.datime, i64 0, i64 %21
store i8 %18, i8* %22
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %2
br label %6
27: ; preds = %14
%28 = load i8*, i8** %2
%29 = load i8, i8* %28
%30 = load i32, i32* %3
%31 = sub nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [128 x i8], [128 x i8]* @basic_date.datime, i64 0, i64 %32
store i8 %29, i8* %33
%34 = load i32, i32* %3
%35 = sub nsw i32 %34, 2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [128 x i8], [128 x i8]* @basic_date.datime, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 10
br i1 %40, label %41, label %46
41: ; preds = %27
%42 = load i32, i32* %3
%43 = sub nsw i32 %42, 2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [128 x i8], [128 x i8]* @basic_date.datime, i64 0, i64 %44
store i8 0, i8* %45
br label %46
46: ; preds = %41, %27
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @basic_date.datime, i64 0, i64 0)
}

LLVM IR (-O2):
@basic_date.datime = internal global [128 x i8] zeroinitializer
define i8* @basic_date() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = call i8* @ctime(i32* %1)
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %0, %7
%8 = phi i64 [ %13, %7 ], [ 1, %0 ]
%9 = phi i8 [ %15, %7 ], [ %5, %0 ]
%10 = phi i8* [ %14, %7 ], [ %4, %0 ]
%11 = add nsw i64 %8, -1
%12 = getelementptr inbounds [128 x i8], [128 x i8]* @basic_date.datime, i64 0, i64 %11
store i8 %9, i8* %12
%13 = add nuw nsw i64 %8, 1
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
%17 = icmp ult i64 %8, 127
%18 = select i1 %16, i1 %17, i1 false
br i1 %18, label %7, label %19
19: ; preds = %7
%20 = trunc i64 %13 to i32
br label %21
21: ; preds = %19, %0
%22 = phi i32 [ 1, %0 ], [ %20, %19 ]
%23 = phi i8 [ 0, %0 ], [ %15, %19 ]
%24 = add nsw i32 %22, -1
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds [128 x i8], [128 x i8]* @basic_date.datime, i64 0, i64 %25
store i8 %23, i8* %26
%27 = add nsw i32 %22, -2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [128 x i8], [128 x i8]* @basic_date.datime, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 10
br i1 %31, label %32, label %33
32: ; preds = %21
store i8 0, i8* %29
br label %33
33: ; preds = %32, %21
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @basic_date.datime, i64 0, i64 0)
}