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

/* Variables and functions */
char *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *clean_date_format(char *date) {
  char *result;
  if (date == NULL) {
    return NULL;
  }
  result = malloc(sizeof(char) * (strlen(date) + 1));
  if (result == NULL) {
    return NULL;
  }
  strcpy(result, date);
  if (strlen(result) >= 11) {
    result[10] = ' ';
  }
  if (strlen(result) >= 20) {
    result[19] = '\0';
  }
  return result;
}


x86 assembly (clang, -O0):
<clean_date_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1154 <clean_date_format+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11d2 <clean_date_format+0xa2>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1189 <clean_date_format+0x59>
movq   $0x0,-0x8(%rbp)
jmp    11d2 <clean_date_format+0xa2>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xb,%eax
jl     11b0 <clean_date_format+0x80>
mov    -0x18(%rbp),%rax
movb   $0x20,0xa(%rax)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x14,%eax
jl     11ca <clean_date_format+0x9a>
mov    -0x18(%rbp),%rax
movb   $0x0,0x13(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clean_date_format>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1180 <clean_date_format+0x50>
mov    %rdi,%r14
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1180 <clean_date_format+0x50>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0xb,%eax
jl     116d <clean_date_format+0x3d>
movb   $0x20,0xa(%rbx)
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x14,%eax
jl     1182 <clean_date_format+0x52>
movb   $0x0,0x13(%rbx)
jmp    1182 <clean_date_format+0x52>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @clean_date_format(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* null, i8** %2
br label %38
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = mul i64 1, %12
%14 = trunc i64 %13 to i32
%15 = call i8* @malloc(i32 %14)
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %8
store i8* null, i8** %2
br label %38
19: ; preds = %8
%20 = load i8*, i8** %4
%21 = load i8*, i8** %3
%22 = call i32 @strcpy(i8* %20, i8* %21)
%23 = load i8*, i8** %4
%24 = call i32 @strlen(i8* %23)
%25 = icmp sge i32 %24, 11
br i1 %25, label %26, label %29
26: ; preds = %19
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 10
store i8 32, i8* %28
br label %29
29: ; preds = %26, %19
%30 = load i8*, i8** %4
%31 = call i32 @strlen(i8* %30)
%32 = icmp sge i32 %31, 20
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 19
store i8 0, i8* %35
br label %36
36: ; preds = %33, %29
%37 = load i8*, i8** %4
store i8* %37, i8** %2
br label %38
38: ; preds = %36, %18, %7
%39 = load i8*, i8** %2
ret i8* %39
}

LLVM IR (-O2):
define i8* @clean_date_format(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = add nsw i32 %4, 1
%6 = tail call i8* @malloc(i32 %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %19, label %8
8: ; preds = %3
%9 = tail call i32 @strcpy(i8* %6, i8* %0)
%10 = tail call i32 @strlen(i8* %6)
%11 = icmp sgt i32 %10, 10
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %6, i64 10
store i8 32, i8* %13
br label %14
14: ; preds = %12, %8
%15 = tail call i32 @strlen(i8* %6)
%16 = icmp sgt i32 %15, 19
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = getelementptr inbounds i8, i8* %6, i64 19
store i8 0, i8* %18
br label %19
19: ; preds = %14, %17, %3, %1
%20 = phi i8* [ null, %1 ], [ null, %3 ], [ %6, %17 ], [ %6, %14 ]
ret i8* %20
}