#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 *convert(char *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int validate(char *);
int main() {
  int rt;
  char *in, *ch;
  in = malloc(10 * sizeof(char) + 1);
  scanf("%s", in);
  if ((rt = validate(in)) != 0) {
    printf("Invalid date, error %d\n", rt);
    return rt;
  }
  ch = convert(in);
  printf("%.8s\n", ch);
  free(in);
  free(ch);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xb,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe78(%rip),%rdi
call   1080 <scanf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <validate@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     11be <main+0x5e>
mov    -0x8(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f6 <main+0x96>
mov    -0x10(%rbp),%rdi
call   1040 <convert@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0xb,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe88(%rip),%rdi
mov    %rax,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1070 <validate@plt>
mov    %eax,%ebp
test   %eax,%eax
je     11a0 <main+0x40>
lea    0xe6e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11cc <main+0x6c>
mov    %rbx,%rdi
call   1040 <convert@plt>
mov    %rax,%r14
lea    0xe69(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [24 x i8] c"Invalid date, error %d\0A\00"
@.str.2 = [6 x i8] c"%.8s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i8* @malloc(i32 11)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %3
%9 = call i32 @validate(i8* %8)
store i32 %9, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %2
store i32 %14, i32* %1
br label %24
15: ; preds = %0
%16 = load i8*, i8** %3
%17 = call i8* @convert(i8* %16)
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %3
%21 = call i32 @free(i8* %20)
%22 = load i8*, i8** %4
%23 = call i32 @free(i8* %22)
store i32 0, i32* %1
br label %24
24: ; preds = %15, %11
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [24 x i8] c"Invalid date, error %d\0A\00"
@.str.2 = [6 x i8] c"%.8s\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
%2 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%3 = tail call i32 @validate(i8* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %3)
br label %12
7: ; preds = %0
%8 = tail call i8* @convert(i8* %1)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = tail call i32 @free(i8* %1)
%11 = tail call i32 @free(i8* %8)
br label %12
12: ; preds = %7, %5
ret i32 %3
}