#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;
struct timeval {
  scalar_t__ tv_sec;
  int /*<<< orphan*/ member_1;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
scalar_t__ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
scalar_t__ time(int /*<<< orphan*/ *);
int main(void) {
  struct timeval t_m = {0, 0};
  time_t t;
  if ((t = time(NULL)) == (time_t)-1 || gettimeofday(&t_m, NULL) != 0 ||
      t_m.tv_sec == 0 || (t != t_m.tv_sec && t + 1 != t_m.tv_sec)) {
    printf("fail\n");
    exit(1);
  }
  printf("pass\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %rax,-0x20(%rbp)
cmp    $0xffffffffffffffff,%rax
je     11c8 <main+0x78>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
cmp    $0x0,%rax
jne    11c8 <main+0x78>
cmpq   $0x0,-0x18(%rbp)
je     11c8 <main+0x78>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     11de <main+0x8e>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
cmp    -0x18(%rbp),%rax
je     11de <main+0x8e>
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
xor    %edi,%edi
call   1050 <time@plt>
cmp    $0xffffffffffffffff,%rax
je     1182 <main+0x42>
mov    %rax,%rbx
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
test   %rax,%rax
jne    1182 <main+0x42>
mov    (%rsp),%rax
test   %rax,%rax
je     1182 <main+0x42>
cmp    %rax,%rbx
je     1198 <main+0x58>
add    $0x1,%rbx
cmp    %rax,%rbx
je     1198 <main+0x58>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i64, i32, i32 }
@.str = [6 x i8] c"fail\0A\00"
@.str.1 = [6 x i8] c"pass\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = alloca i64
store i32 0, i32* %1
%4 = bitcast %struct.timeval* %2 to i8*
%5 = call i64 @time(i32* null)
store i64 %5, i64* %3
%6 = icmp eq i64 %5, -1
br i1 %6, label %25, label %7
7: ; preds = %0
%8 = call i64 @gettimeofday(%struct.timeval* %2, i32* null)
%9 = icmp ne i64 %8, 0
br i1 %9, label %25, label %10
10: ; preds = %7
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%12 = load i64, i64* %11
%13 = icmp eq i64 %12, 0
br i1 %13, label %25, label %14
14: ; preds = %10
%15 = load i64, i64* %3
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%17 = load i64, i64* %16
%18 = icmp ne i64 %15, %17
br i1 %18, label %19, label %28
19: ; preds = %14
%20 = load i64, i64* %3
%21 = add nsw i64 %20, 1
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%23 = load i64, i64* %22
%24 = icmp ne i64 %21, %23
br i1 %24, label %25, label %28
25: ; preds = %19, %10, %7, %0
%26 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %19, %14
%29 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.timeval = type { i64, i32, i32 }
@str = [5 x i8] c"pass\00"
@str.2 = [5 x i8] c"fail\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = tail call i64 @time(i32* null)
%4 = icmp eq i64 %3, -1
br i1 %4, label %17, label %5
5: ; preds = %0
%6 = call i64 @gettimeofday(%struct.timeval* %1, i32* null)
%7 = icmp ne i64 %6, 0
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%9 = load i64, i64* %8
%10 = icmp eq i64 %9, 0
%11 = select i1 %7, i1 true, i1 %10
br i1 %11, label %17, label %12
12: ; preds = %5
%13 = icmp eq i64 %3, %9
%14 = add nuw nsw i64 %3, 1
%15 = icmp eq i64 %14, %9
%16 = select i1 %13, i1 true, i1 %15
br i1 %16, label %20, label %17
17: ; preds = %12, %5, %0
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.2, i64 0, i64 0))
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %12
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%22 = tail call i32 @exit(i32 0)
unreachable
}