#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 nbjoursmois(int, int);
int /*<<< orphan*/ soustringcopy(char *, char *, int, int);
int strtoint(char *);
scalar_t__ verifstrformat(char *, char *);
int datevalide(char *chaine) {
  char strtmp[5];
  int jour;
  int mois;
  int annee;
  if (verifstrformat("##/##/####", chaine)) {
    soustringcopy(chaine, strtmp, 0, 2);
    jour = strtoint(strtmp);
    soustringcopy(chaine, strtmp, 3, 2);
    mois = strtoint(strtmp);
    soustringcopy(chaine, strtmp, 6, 4);
    annee = strtoint(strtmp);
    if ((annee > 0) && (mois > 0) && (mois <= 12) && (jour > 0) &&
        (jour <= nbjoursmois(mois, annee)))
      return 1;
    else
      return 0;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<datevalide>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea9(%rip),%rdi
call   1060 <verifstrformat@plt>
cmp    $0x0,%rax
je     122a <datevalide+0xea>
mov    -0x10(%rbp),%rdi
lea    -0x15(%rbp),%rsi
xor    %edx,%edx
mov    $0x2,%ecx
call   1040 <soustringcopy@plt>
lea    -0x15(%rbp),%rdi
call   1030 <strtoint@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x15(%rbp),%rsi
mov    $0x3,%edx
mov    $0x2,%ecx
call   1040 <soustringcopy@plt>
lea    -0x15(%rbp),%rdi
call   1030 <strtoint@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x15(%rbp),%rsi
mov    $0x6,%edx
mov    $0x4,%ecx
call   1040 <soustringcopy@plt>
lea    -0x15(%rbp),%rdi
call   1030 <strtoint@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    121e <datevalide+0xde>
cmpl   $0x0,-0x20(%rbp)
jle    121e <datevalide+0xde>
cmpl   $0xc,-0x20(%rbp)
jg     121e <datevalide+0xde>
cmpl   $0x0,-0x1c(%rbp)
jle    121e <datevalide+0xde>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1050 <nbjoursmois@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jg     121e <datevalide+0xde>
movl   $0x1,-0x4(%rbp)
jmp    1231 <datevalide+0xf1>
movl   $0x0,-0x4(%rbp)
jmp    1231 <datevalide+0xf1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<datevalide>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeaf(%rip),%rdi
mov    %rbx,%rsi
call   1060 <verifstrformat@plt>
test   %rax,%rax
je     11eb <datevalide+0xab>
lea    0x3(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %edx,%edx
mov    $0x2,%ecx
call   1040 <soustringcopy@plt>
mov    %rbp,%rdi
call   1030 <strtoint@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x3,%edx
mov    $0x2,%ecx
call   1040 <soustringcopy@plt>
mov    %rbp,%rdi
call   1030 <strtoint@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x6,%edx
mov    $0x4,%ecx
call   1040 <soustringcopy@plt>
mov    %rbp,%rdi
call   1030 <strtoint@plt>
test   %eax,%eax
jle    11eb <datevalide+0xab>
test   %r15d,%r15d
jle    11eb <datevalide+0xab>
cmp    $0xc,%r15d
jg     11eb <datevalide+0xab>
test   %r14d,%r14d
jle    11eb <datevalide+0xab>
mov    %r15d,%edi
mov    %eax,%esi
call   1050 <nbjoursmois@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%r14d
jle    11ed <datevalide+0xad>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"##/##/####\00"
define i32 @datevalide(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [5 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i64 @verifstrformat(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %46
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%14 = call i32 @soustringcopy(i8* %12, i8* %13, i32 0, i32 2)
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%16 = call i32 @strtoint(i8* %15)
store i32 %16, i32* %5
%17 = load i8*, i8** %3
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%19 = call i32 @soustringcopy(i8* %17, i8* %18, i32 3, i32 2)
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%21 = call i32 @strtoint(i8* %20)
store i32 %21, i32* %6
%22 = load i8*, i8** %3
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%24 = call i32 @soustringcopy(i8* %22, i8* %23, i32 6, i32 4)
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%26 = call i32 @strtoint(i8* %25)
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %45
29: ; preds = %11
%30 = load i32, i32* %6
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %45
32: ; preds = %29
%33 = load i32, i32* %6
%34 = icmp sle i32 %33, 12
br i1 %34, label %35, label %45
35: ; preds = %32
%36 = load i32, i32* %5
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = load i32, i32* %5
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = call i32 @nbjoursmois(i32 %40, i32 %41)
%43 = icmp sle i32 %39, %42
br i1 %43, label %44, label %45
44: ; preds = %38
store i32 1, i32* %2
br label %47
45: ; preds = %38, %35, %32, %29, %11
store i32 0, i32* %2
br label %47
46: ; preds = %1
store i32 0, i32* %2
br label %47
47: ; preds = %46, %45, %44
%48 = load i32, i32* %2
ret i32 %48
}

LLVM IR (-O2):
@.str = [11 x i8] c"##/##/####\00"
define i32 @datevalide(i8* %0) {
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @verifstrformat(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %24, label %6
6: ; preds = %1
%7 = call i32 @soustringcopy(i8* %0, i8* %3, i32 0, i32 2)
%8 = call i32 @strtoint(i8* %3)
%9 = call i32 @soustringcopy(i8* %0, i8* %3, i32 3, i32 2)
%10 = call i32 @strtoint(i8* %3)
%11 = call i32 @soustringcopy(i8* %0, i8* %3, i32 6, i32 4)
%12 = call i32 @strtoint(i8* %3)
%13 = icmp sgt i32 %12, 0
%14 = icmp sgt i32 %10, 0
%15 = select i1 %13, i1 %14, i1 false
%16 = icmp slt i32 %10, 13
%17 = select i1 %15, i1 %16, i1 false
%18 = icmp sgt i32 %8, 0
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %20, label %23
20: ; preds = %6
%21 = call i32 @nbjoursmois(i32 %10, i32 %12)
%22 = icmp sgt i32 %8, %21
br i1 %22, label %23, label %24
23: ; preds = %20, %6
br label %24
24: ; preds = %1, %20, %23
%25 = phi i32 [ 0, %23 ], [ 1, %20 ], [ 0, %1 ]
ret i32 %25
}