#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 time_t;
struct tm {
  int tm_isdst;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int mktime(struct tm *);
int strlen(char *);
int /*<<< orphan*/ *strptime(char *, char *, struct tm *);
int check_date(char *str_date, time_t *t) {
  struct tm tm = {0};
  if (strlen(str_date) != 14)
    return 0;
  if (strptime(str_date, "%Y%m%d %H:%M", &tm) == NULL)
    return 0;
  tm.tm_isdst = -1;
  *t = mktime(&tm);
  if (*t == -1)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<check_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xe,%eax
je     117e <check_date+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    11e0 <check_date+0xa0>
mov    -0x10(%rbp),%rdi
lea    0xe77(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1060 <strptime@plt>
cmp    $0x0,%rax
jne    11a8 <check_date+0x68>
movl   $0x0,-0x4(%rbp)
jmp    11e0 <check_date+0xa0>
movl   $0xffffffff,-0x20(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <mktime@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    11d9 <check_date+0x99>
movl   $0x0,-0x4(%rbp)
jmp    11e0 <check_date+0xa0>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_date>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
call   1030 <strlen@plt>
xor    %ebp,%ebp
cmp    $0xe,%eax
jne    118a <check_date+0x5a>
lea    0xea6(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <strptime@plt>
test   %rax,%rax
je     118a <check_date+0x5a>
movl   $0xffffffff,0x8(%rsp)
ff
lea    0x8(%rsp),%rdi
call   1040 <mktime@plt>
mov    %eax,(%r14)
xor    %ebp,%ebp
cmp    $0xffffffff,%eax
setne  %bpl
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32 }
@.str = [13 x i8] c"%Y%m%d %H:%M\00"
define i32 @check_date(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca %struct.tm
store i8* %0, i8** %4
store i32* %1, i32** %5
%7 = bitcast %struct.tm* %6 to i8*
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = icmp ne i32 %9, 14
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %26
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32* @strptime(i8* %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %struct.tm* %6)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 0, i32* %3
br label %26
17: ; preds = %12
%18 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 0
store i32 -1, i32* %18
%19 = call i32 @mktime(%struct.tm* %6)
%20 = load i32*, i32** %5
store i32 %19, i32* %20
%21 = load i32*, i32** %5
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %25
24: ; preds = %17
store i32 0, i32* %3
br label %26
25: ; preds = %17
store i32 1, i32* %3
br label %26
26: ; preds = %25, %24, %16, %11
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
%struct.tm = type { i32, i32 }
@.str = [13 x i8] c"%Y%m%d %H:%M\00"
define i32 @check_date(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to %struct.tm*
%5 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp eq i32 %6, 14
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = call i32* @strptime(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
%10 = icmp eq i32* %9, null
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = bitcast i64* %3 to i32*
store i32 -1, i32* %12
%13 = call i32 @mktime(%struct.tm* %4)
store i32 %13, i32* %1
%14 = icmp ne i32 %13, -1
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %11, %8, %2
%17 = phi i32 [ 0, %2 ], [ 0, %8 ], [ %15, %11 ]
ret i32 %17
}