#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 {
  int dummy;
};
typedef int /*<<< orphan*/ X509;
typedef int /*<<< orphan*/ ASN1_TIME;

/* Variables and functions */
scalar_t__ X509_cmp_current_time(int /*<<< orphan*/ *);
int /*<<< orphan*/ *X509_get_notAfter(int /*<<< orphan*/ *);
int /*<<< orphan*/ *X509_get_notBefore(int /*<<< orphan*/ *);
int _convert_time(struct tm *, int /*<<< orphan*/ *);
int /*<<< orphan*/ assert(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
int abac_check_validity(X509 *cert, struct tm *not_before,
                        struct tm *not_after) {
  assert(cert);
  int valid = 0;
  int ret = 0;
  memset(not_before, 0, sizeof(struct tm));
  memset(not_after, 0, sizeof(struct tm));
  ASN1_TIME *notAfter = X509_get_notAfter(cert);
  ASN1_TIME *notBefore = X509_get_notBefore(cert);
  ret = _convert_time(not_before, notBefore);
  if (ret == 0)
    return 1;
  ret = _convert_time(not_after, notAfter);
  if (ret == 0)
    return 1;
  if ((X509_cmp_current_time(notBefore) >= 0) ||
      (X509_cmp_current_time(notAfter) <= 0))
    valid = 1;
  if (valid)
    return 0;
  else
    return 1;
}


x86 assembly (clang, -O0):
<abac_check_validity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <assert@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
call   1030 <X509_get_notAfter@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <X509_get_notBefore@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <_convert_time@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    11eb <abac_check_validity+0x8b>
movl   $0x1,-0x4(%rbp)
jmp    125b <abac_check_validity+0xfb>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <_convert_time@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    1211 <abac_check_validity+0xb1>
movl   $0x1,-0x4(%rbp)
jmp    125b <abac_check_validity+0xfb>
mov    -0x38(%rbp),%rdi
call   1080 <X509_cmp_current_time@plt>
cmp    $0x0,%rax
jge    1237 <abac_check_validity+0xd7>
mov    -0x30(%rbp),%rdi
call   1080 <X509_cmp_current_time@plt>
cmp    $0x0,%rax
jg     123e <abac_check_validity+0xde>
movl   $0x1,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1254 <abac_check_validity+0xf4>
movl   $0x0,-0x4(%rbp)
jmp    125b <abac_check_validity+0xfb>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<abac_check_validity>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%rbx
call   1060 <assert@plt>
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
call   1030 <X509_get_notAfter@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <X509_get_notBefore@plt>
mov    %rax,%r12
mov    %r13,%rdi
mov    %rax,%rsi
call   1070 <_convert_time@plt>
mov    $0x1,%ebx
test   %eax,%eax
je     11ed <abac_check_validity+0x8d>
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <_convert_time@plt>
test   %eax,%eax
je     11ed <abac_check_validity+0x8d>
mov    %r12,%rdi
call   1080 <X509_cmp_current_time@plt>
xor    %ebx,%ebx
test   %rax,%rax
jns    11ed <abac_check_validity+0x8d>
mov    %r14,%rdi
call   1080 <X509_cmp_current_time@plt>
xor    %ebx,%ebx
test   %rax,%rax
setg   %bl
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
define i32 @abac_check_validity(i32* %0, %struct.tm* %1, %struct.tm* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca %struct.tm*
%7 = alloca %struct.tm*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
store i32* %0, i32** %5
store %struct.tm* %1, %struct.tm** %6
store %struct.tm* %2, %struct.tm** %7
%12 = load i32*, i32** %5
%13 = call i32 @assert(i32* %12)
store i32 0, i32* %8
store i32 0, i32* %9
%14 = load %struct.tm*, %struct.tm** %6
%15 = call i32 @memset(%struct.tm* %14, i32 0, i32 4)
%16 = load %struct.tm*, %struct.tm** %7
%17 = call i32 @memset(%struct.tm* %16, i32 0, i32 4)
%18 = load i32*, i32** %5
%19 = call i32* @X509_get_notAfter(i32* %18)
store i32* %19, i32** %10
%20 = load i32*, i32** %5
%21 = call i32* @X509_get_notBefore(i32* %20)
store i32* %21, i32** %11
%22 = load %struct.tm*, %struct.tm** %6
%23 = load i32*, i32** %11
%24 = call i32 @_convert_time(%struct.tm* %22, i32* %23)
store i32 %24, i32* %9
%25 = load i32, i32* %9
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %3
store i32 1, i32* %4
br label %49
28: ; preds = %3
%29 = load %struct.tm*, %struct.tm** %7
%30 = load i32*, i32** %10
%31 = call i32 @_convert_time(%struct.tm* %29, i32* %30)
store i32 %31, i32* %9
%32 = load i32, i32* %9
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %28
store i32 1, i32* %4
br label %49
35: ; preds = %28
%36 = load i32*, i32** %11
%37 = call i64 @X509_cmp_current_time(i32* %36)
%38 = icmp sge i64 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %35
%40 = load i32*, i32** %10
%41 = call i64 @X509_cmp_current_time(i32* %40)
%42 = icmp sle i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39, %35
store i32 1, i32* %8
br label %44
44: ; preds = %43, %39
%45 = load i32, i32* %8
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %44
store i32 0, i32* %4
br label %49
48: ; preds = %44
store i32 1, i32* %4
br label %49
49: ; preds = %48, %47, %34, %27
%50 = load i32, i32* %4
ret i32 %50
}

LLVM IR (-O2):
%struct.tm = type { i32 }
define i32 @abac_check_validity(i32* %0, %struct.tm* %1, %struct.tm* %2) {
%4 = tail call i32 @assert(i32* %0)
%5 = tail call i32 @memset(%struct.tm* %1, i32 0, i32 4)
%6 = tail call i32 @memset(%struct.tm* %2, i32 0, i32 4)
%7 = tail call i32* @X509_get_notAfter(i32* %0)
%8 = tail call i32* @X509_get_notBefore(i32* %0)
%9 = tail call i32 @_convert_time(%struct.tm* %1, i32* %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %3
%12 = tail call i32 @_convert_time(%struct.tm* %2, i32* %7)
%13 = icmp eq i32 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = tail call i64 @X509_cmp_current_time(i32* %8)
%16 = icmp sgt i64 %15, -1
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = tail call i64 @X509_cmp_current_time(i32* %7)
%19 = icmp sgt i64 %18, 0
%20 = zext i1 %19 to i32
br label %21
21: ; preds = %17, %14, %11, %3
%22 = phi i32 [ 1, %3 ], [ 1, %11 ], [ 0, %14 ], [ %20, %17 ]
ret i32 %22
}