#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 */
int iTestIfValidDate8(unsigned char *);
scalar_t__ iTestStrDecimal(unsigned char *, int);
scalar_t__ memcmp(unsigned char *, char *, int);
int /*<<< orphan*/ strcat(unsigned char *, unsigned char *);
int /*<<< orphan*/ strcpy(unsigned char *, char *);
int strlen(unsigned char *);
int iTestIfValidDate6(unsigned char *pszDate) {
  unsigned char szDate[9];
  if (strlen(pszDate) != 6)
    return (1);
  if (iTestStrDecimal(pszDate, 6) != 0)
    return (1);
  if (memcmp(pszDate, "49", 2) > 0)
    strcpy(szDate, "19");
  else
    strcpy(szDate, "20");
  strcat(szDate, pszDate);
  return (iTestIfValidDate8(szDate));
}


x86 assembly (clang, -O0):
<iTestIfValidDate6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x6,%eax
je     118a <iTestIfValidDate6+0x2a>
movl   $0x1,-0x4(%rbp)
jmp    120b <iTestIfValidDate6+0xab>
mov    -0x10(%rbp),%rdi
mov    $0x6,%esi
call   1070 <iTestStrDecimal@plt>
cmp    $0x0,%rax
je     11ae <iTestIfValidDate6+0x4e>
movl   $0x1,-0x4(%rbp)
jmp    120b <iTestIfValidDate6+0xab>
mov    -0x10(%rbp),%rdi
lea    0xe47(%rip),%rsi
mov    $0x2,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
jle    11e2 <iTestIfValidDate6+0x82>
lea    -0x19(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1040 <strcpy@plt>
jmp    11f2 <iTestIfValidDate6+0x92>
lea    -0x19(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x19(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x19(%rbp),%rdi
call   1030 <iTestIfValidDate8@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iTestIfValidDate6>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    $0x1,%ebp
cmp    $0x6,%eax
jne    11d5 <iTestIfValidDate6+0x75>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1070 <iTestStrDecimal@plt>
test   %rax,%rax
jne    11d5 <iTestIfValidDate6+0x75>
lea    0xe6f(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
lea    0xe5b(%rip),%rax
lea    0xe57(%rip),%rsi
cmovg  %rax,%rsi
lea    0xf(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
mov    %rbp,%rdi
call   1030 <iTestIfValidDate8@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"49\00"
@.str.1 = [3 x i8] c"19\00"
@.str.2 = [3 x i8] c"20\00"
define i32 @iTestIfValidDate6(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [9 x i8]
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
%7 = icmp ne i32 %6, 6
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 1, i32* %2
br label %30
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i64 @iTestStrDecimal(i8* %10, i32 6)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 1, i32* %2
br label %30
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = call i64 @memcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%17 = icmp sgt i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %24
21: ; preds = %14
%22 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %21, %18
%25 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%26 = load i8*, i8** %3
%27 = call i32 @strcat(i8* %25, i8* %26)
%28 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%29 = call i32 @iTestIfValidDate8(i8* %28)
store i32 %29, i32* %2
br label %30
30: ; preds = %24, %13, %8
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [3 x i8] c"49\00"
@.str.1 = [3 x i8] c"19\00"
@.str.2 = [3 x i8] c"20\00"
define i32 @iTestIfValidDate6(i8* %0) {
%2 = alloca [9 x i8]
%3 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 6
br i1 %5, label %6, label %16
6: ; preds = %1
%7 = tail call i64 @iTestStrDecimal(i8* %0, i32 6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%11 = icmp sgt i64 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%13 = call i32 @strcpy(i8* %3, i8* %12)
%14 = call i32 @strcat(i8* %3, i8* %0)
%15 = call i32 @iTestIfValidDate8(i8* %3)
br label %16
16: ; preds = %6, %1, %9
%17 = phi i32 [ %15, %9 ], [ 1, %1 ], [ 1, %6 ]
ret i32 %17
}