#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 scalar_t__ time_t;
typedef int /*<<< orphan*/ CT_POLICY_EVAL_CTX;

/* Variables and functions */
int /*<<< orphan*/ CT_POLICY_EVAL_CTX_free(int /*<<< orphan*/ *);
int CT_POLICY_EVAL_CTX_get_time(int /*<<< orphan*/ *);
int /*<<< orphan*/ *CT_POLICY_EVAL_CTX_new();
int /*<<< orphan*/ difftime(int /*<<< orphan*/, scalar_t__ const);
scalar_t__ const fabs(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int test_default_ct_policy_eval_ctx_time_is_now() {
  int success = 0;
  CT_POLICY_EVAL_CTX *ct_policy_ctx = CT_POLICY_EVAL_CTX_new();
  const time_t default_time = CT_POLICY_EVAL_CTX_get_time(ct_policy_ctx) / 1000;
  const time_t time_tolerance = 600;
  if (fabs(difftime(time(NULL), default_time)) > time_tolerance) {
    fprintf(stderr,
            "Default CT_POLICY_EVAL_CTX time is not approximately now.\n");
    goto end;
  }
  success = 1;
end:
  CT_POLICY_EVAL_CTX_free(ct_policy_ctx);
  return success;
}


x86 assembly (clang, -O0):
<test_default_ct_policy_eval_ctx_time_is_now>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1090 <CT_POLICY_EVAL_CTX_new@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <CT_POLICY_EVAL_CTX_get_time@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x18(%rbp)
movq   $0x258,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
mov    -0x18(%rbp),%rsi
call   1040 <difftime@plt>
mov    %eax,%edi
call   1050 <fabs@plt>
cmp    $0x258,%rax
jle    11ea <test_default_ct_policy_eval_ctx_time_is_now+0x7a>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11f1 <test_default_ct_policy_eval_ctx_time_is_now+0x81>
movl   $0x1,-0x4(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <CT_POLICY_EVAL_CTX_free@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_default_ct_policy_eval_ctx_time_is_now>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1090 <CT_POLICY_EVAL_CTX_new@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <CT_POLICY_EVAL_CTX_get_time@plt>
cltq
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
movslq %eax,%rbp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
mov    %rbp,%rsi
call   1040 <difftime@plt>
mov    %eax,%edi
call   1050 <fabs@plt>
mov    $0x1,%ebp
cmp    $0x259,%rax
jl     11da <test_default_ct_policy_eval_ctx_time_is_now+0x6a>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
call   1060 <fprintf@plt>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1030 <CT_POLICY_EVAL_CTX_free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [59 x i8] c"Default CT_POLICY_EVAL_CTX time is not approximately now.\0A\00"
define i32 @test_default_ct_policy_eval_ctx_time_is_now() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
%5 = call i32* (...) @CT_POLICY_EVAL_CTX_new()
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = call i32 @CT_POLICY_EVAL_CTX_get_time(i32* %6)
%8 = sdiv i32 %7, 1000
%9 = sext i32 %8 to i64
store i64 %9, i64* %3
store i64 600, i64* %4
%10 = call i32 @time(i32* null)
%11 = load i64, i64* %3
%12 = call i32 @difftime(i32 %10, i64 %11)
%13 = call i64 @fabs(i32 %12)
%14 = icmp sgt i64 %13, 600
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
br label %19
18: ; preds = %0
store i32 1, i32* %1
br label %19
19: ; preds = %18, %15
%20 = load i32*, i32** %2
%21 = call i32 @CT_POLICY_EVAL_CTX_free(i32* %20)
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [59 x i8] c"Default CT_POLICY_EVAL_CTX time is not approximately now.\0A\00"
define i32 @test_default_ct_policy_eval_ctx_time_is_now() {
%1 = tail call i32* (...) @CT_POLICY_EVAL_CTX_new()
%2 = tail call i32 @CT_POLICY_EVAL_CTX_get_time(i32* %1)
%3 = sdiv i32 %2, 1000
%4 = sext i32 %3 to i64
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @difftime(i32 %5, i64 %4)
%7 = tail call i64 @fabs(i32 %6)
%8 = icmp sgt i64 %7, 600
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %0, %9
%13 = phi i32 [ 0, %9 ], [ 1, %0 ]
%14 = tail call i32 @CT_POLICY_EVAL_CTX_free(i32* %1)
ret i32 %13
}