#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;

/* Variables and functions */
scalar_t__ errno;
int /*<<< orphan*/ printf(char *, long, scalar_t__, long, char *);
scalar_t__ time(scalar_t__ *);
int test_time() {
  time_t ret, t;
  errno = 0;
  ret = time(&t);
  printf("time 1: ret = %ld, errno = %d, t = %ld %s\n", (long)ret, errno,
         (long)t, ret == t ? "OK" : "");
  errno = 0;
  ret = time(NULL);
  printf("time 2: ret = %ld, errno = %d, t = %ld %s\n", (long)ret, errno,
         (long)t, ret >= t && ret < t + 10 ? "OK" : "");
}


x86 assembly (clang, -O0):
<test_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x2eb1(%rip),%rax
movq   $0x0,(%rax)
lea    -0x18(%rbp),%rdi
call   1040 <time@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    0x2e92(%rip),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%r9
lea    0xec6(%rip),%r8
lea    0xec0(%rip),%rax
cmp    %r9,%rdi
cmove  %rax,%r8
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e5b(%rip),%rax
movq   $0x0,(%rax)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x2e38(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x19(%rbp)
jl     11df <test_time+0xbf>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    $0xa,%rcx
cmp    %rcx,%rax
setl   %al
mov    %al,-0x19(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rsi
mov    -0x19(%rbp),%dil
lea    0xe34(%rip),%r8
lea    0xe2e(%rip),%rax
test   $0x1,%dil
cmovne %rax,%r8
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_time>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2eb0(%rip),%r14
movq   $0x0,(%r14)
lea    0x8(%rsp),%rdi
call   1040 <time@plt>
mov    (%r14),%rdx
mov    0x8(%rsp),%rcx
cmp    %rcx,%rax
lea    0xed8(%rip),%rbx
lea    0xed0(%rip),%r15
mov    %r15,%r8
cmove  %rbx,%r8
lea    0xe98(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
movq   $0x0,(%r14)
xor    %edi,%edi
call   1040 <time@plt>
mov    0x8(%rsp),%rcx
lea    0xa(%rcx),%rdx
cmp    %rdx,%rax
cmovge %r15,%rbx
mov    (%r14),%rdx
cmp    %rcx,%rax
cmovl  %r15,%rbx
lea    0xe8f(%rip),%rdi
mov    %rax,%rsi
mov    %rbx,%r8
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [43 x i8] c"time 1: ret = %ld, errno = %d, t = %ld %s\0A\00"
@.str.1 = [3 x i8] c"OK\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [43 x i8] c"time 2: ret = %ld, errno = %d, t = %ld %s\0A\00"
define i32 @test_time() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i64 0, i64* @errno
%4 = call i64 @time(i64* %3)
store i64 %4, i64* %2
%5 = load i64, i64* %2
%6 = load i64, i64* @errno
%7 = load i64, i64* %3
%8 = load i64, i64* %2
%9 = load i64, i64* %3
%10 = icmp eq i64 %8, %9
%11 = zext i1 %10 to i64
%12 = select i1 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%13 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i64 %5, i64 %6, i64 %7, i8* %12)
store i64 0, i64* @errno
%14 = call i64 @time(i64* null)
store i64 %14, i64* %2
%15 = load i64, i64* %2
%16 = load i64, i64* @errno
%17 = load i64, i64* %3
%18 = load i64, i64* %2
%19 = load i64, i64* %3
%20 = icmp sge i64 %18, %19
br i1 %20, label %21, label %26
21: ; preds = %0
%22 = load i64, i64* %2
%23 = load i64, i64* %3
%24 = add nsw i64 %23, 10
%25 = icmp slt i64 %22, %24
br label %26
26: ; preds = %21, %0
%27 = phi i1 [ false, %0 ], [ %25, %21 ]
%28 = zext i1 %27 to i64
%29 = select i1 %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%30 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i64 %15, i64 %16, i64 %17, i8* %29)
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [43 x i8] c"time 1: ret = %ld, errno = %d, t = %ld %s\0A\00"
@.str.1 = [3 x i8] c"OK\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [43 x i8] c"time 2: ret = %ld, errno = %d, t = %ld %s\0A\00"
define i32 @test_time() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 0, i64* @errno
%3 = call i64 @time(i64* %1)
%4 = load i64, i64* @errno
%5 = load i64, i64* %1
%6 = icmp eq i64 %3, %5
%7 = select i1 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%8 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i64 %3, i64 %4, i64 %5, i8* %7)
store i64 0, i64* @errno
%9 = call i64 @time(i64* null)
%10 = load i64, i64* @errno
%11 = load i64, i64* %1
%12 = icmp sge i64 %9, %11
%13 = add nsw i64 %11, 10
%14 = icmp slt i64 %9, %13
%15 = select i1 %12, i1 %14, i1 false
%16 = select i1 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%17 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i64 %9, i64 %10, i64 %11, i8* %16)
ret i32 undef
}