#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 */
struct tm {
  scalar_t__ tm_year;
  scalar_t__ tm_mday;
};

/* Variables and functions */
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
char *strptime(char const *, char const *, struct tm *);
int _date_do(char const *date, char const *format, struct tm *tm) {
  char const *p;
  memset(tm, 0, sizeof(*tm));
  if ((p = strptime(date, format, tm)) != NULL && *p == '\0')
    return 0;
  if (p != NULL && tm->tm_year != 0 && tm->tm_mday != 0)
    return 0;
  return -1;
}


x86 assembly (clang, -O0):
<_date_do>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <strptime@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     117f <_date_do+0x5f>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    117f <_date_do+0x5f>
movl   $0x0,-0x4(%rbp)
jmp    11ba <_date_do+0x9a>
cmpq   $0x0,-0x28(%rbp)
je     11b3 <_date_do+0x93>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11b3 <_date_do+0x93>
mov    -0x20(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11b3 <_date_do+0x93>
movl   $0x0,-0x4(%rbp)
jmp    11ba <_date_do+0x9a>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_date_do>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%rbp
xor    %r14d,%r14d
mov    %rdx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <strptime@plt>
test   %rax,%rax
je     1167 <_date_do+0x47>
cmpb   $0x0,(%rax)
je     116d <_date_do+0x4d>
cmpq   $0x0,(%rbx)
je     1167 <_date_do+0x47>
cmpq   $0x0,0x8(%rbx)
jne    116d <_date_do+0x4d>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.tm = type { i64, i64 }
define i32 @_date_do(i8* %0, i8* %1, %struct.tm* %2) {
%4 = tail call i32 @memset(%struct.tm* %2, i32 0, i32 16)
%5 = tail call i8* @strptime(i8* %0, i8* %1, %struct.tm* %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %18, label %7
7: ; preds = %3
%8 = load i8, i8* %5
%9 = icmp eq i8 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
%12 = load i64, i64* %11
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 1
%16 = load i64, i64* %15
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %3, %14, %10
br label %19
19: ; preds = %14, %7, %18
%20 = phi i32 [ -1, %18 ], [ 0, %7 ], [ 0, %14 ]
ret i32 %20
}