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

/* Variables and functions */
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mktime(struct tm *);
char *strptime(char const *, char const *, struct tm *);
int a2time(time_t *t, const char *fmt, const char *p) {
  struct tm tm;
  char *pp;
  memset(&tm, 0, sizeof(struct tm));
  pp = NULL;
  pp = strptime(p, fmt, &tm);
  if (NULL != pp && '\0' == *pp) {
    *t = mktime(&tm);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<a2time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strptime@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmp    -0x30(%rbp),%rax
je     11ab <a2time+0x7b>
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    11ab <a2time+0x7b>
lea    -0x28(%rbp),%rdi
call   1040 <mktime@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11b2 <a2time+0x82>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<a2time>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,%r14
lea    0x8(%rsp),%r12
xor    %r15d,%r15d
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
call   1050 <strptime@plt>
test   %rax,%rax
je     1187 <a2time+0x57>
cmpb   $0x0,(%rax)
jne    1187 <a2time+0x57>
lea    0x8(%rsp),%rdi
call   1040 <mktime@plt>
mov    %eax,(%r14)
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
define i32 @a2time(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.tm
%9 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = call i32 @memset(%struct.tm* %8, i32 0, i32 4)
store i8* null, i8** %9
%11 = load i8*, i8** %7
%12 = load i8*, i8** %6
%13 = call i8* @strptime(i8* %11, i8* %12, %struct.tm* %8)
store i8* %13, i8** %9
%14 = load i8*, i8** %9
%15 = icmp ne i8* null, %14
br i1 %15, label %16, label %24
16: ; preds = %3
%17 = load i8*, i8** %9
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 0, %19
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = call i32 @mktime(%struct.tm* %8)
%23 = load i32*, i32** %5
store i32 %22, i32* %23
store i32 1, i32* %4
br label %25
24: ; preds = %16, %3
store i32 0, i32* %4
br label %25
25: ; preds = %24, %21
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
%struct.tm = type { i32 }
define i32 @a2time(i32* nocapture writeonly %0, i8* %1, i8* %2) {
%4 = alloca %struct.tm
%5 = bitcast %struct.tm* %4 to i8*
%6 = call i32 @memset(%struct.tm* %4, i32 0, i32 4)
%7 = call i8* @strptime(i8* %2, i8* %1, %struct.tm* %4)
%8 = icmp eq i8* %7, null
br i1 %8, label %14, label %9
9: ; preds = %3
%10 = load i8, i8* %7
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @mktime(%struct.tm* %4)
store i32 %13, i32* %0
br label %14
14: ; preds = %3, %9, %12
%15 = phi i32 [ 1, %12 ], [ 0, %9 ], [ 0, %3 ]
ret i32 %15
}