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

/* Variables and functions */
double CLOCKS_PER_SEC;
double clock();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ time(int /*<<< orphan*/ *);
int main(void) {
  clock_t c1, c2;
  double sec1, sec2;
  time_t end;
  c1 = clock();
  sec1 = c1 / CLOCKS_PER_SEC;
  end = time(NULL) + 5;
  while (end >= time(NULL)) {
    clock();
  }
  c2 = clock();
  sec2 = c2 / CLOCKS_PER_SEC;
  if (sec2 > sec1) {
    printf("Times T1=%.2f, T2=%.2f\n", sec1, sec2);
    printf("Test PASSED\n");
    return 0;
  } else {
    if (sec2 < sec1) {
      printf("TEST AGAIN:  Times probably wrapped\n");
      return 2;
    } else {
      printf("Error with processor times T1=%.2f, T2=%.2f\n", sec1, sec2);
      return 1;
    }
  }
  return 2;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    0x2e91(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
add    $0x5,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jl     119e <main+0x6e>
mov    $0x0,%al
call   1030 <clock@plt>
jmp    1171 <main+0x41>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    0x2e32(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1201 <main+0xd1>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xe20(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    124e <main+0x11e>
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    122f <main+0xff>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    124e <main+0x11e>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xe0a(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <clock@plt>
mov    0x2e96(%rip),%r14
divsd  (%r14),%xmm0
movsd  %xmm0,(%rsp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,%rbx
add    $0x5,%rbx
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1060 <time@plt>
cmp    %rax,%rbx
jl     1185 <main+0x45>
xor    %eax,%eax
call   1040 <clock@plt>
jmp    1170 <main+0x30>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <clock@plt>
movapd %xmm0,%xmm1
divsd  (%r14),%xmm1
movsd  (%rsp),%xmm0
ucomisd %xmm0,%xmm1
jbe    11be <main+0x7e>
lea    0xe57(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
jmp    11ea <main+0xaa>
ucomisd %xmm1,%xmm0
jbe    11d7 <main+0x97>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%ebx
jmp    11ea <main+0xaa>
lea    0xe3a(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [24 x i8] c"Times T1=%.2f, T2=%.2f\0A\00"
@.str.1 = [13 x i8] c"Test PASSED\0A\00"
@.str.2 = [37 x i8] c"TEST AGAIN: Times probably wrapped\0A\00"
@.str.3 = [45 x i8] c"Error with processor times T1=%.2f, T2=%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i64
store i32 0, i32* %1
%7 = call double (...) @clock()
store double %7, double* %2
%8 = load double, double* %2
%9 = load double, double* @CLOCKS_PER_SEC
%10 = fdiv double %8, %9
store double %10, double* %4
%11 = call i64 @time(i32* null)
%12 = add nsw i64 %11, 5
store i64 %12, i64* %6
br label %13
13: ; preds = %17, %0
%14 = load i64, i64* %6
%15 = call i64 @time(i32* null)
%16 = icmp sge i64 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call double (...) @clock()
br label %13
19: ; preds = %13
%20 = call double (...) @clock()
store double %20, double* %3
%21 = load double, double* %3
%22 = load double, double* @CLOCKS_PER_SEC
%23 = fdiv double %21, %22
store double %23, double* %5
%24 = load double, double* %5
%25 = load double, double* %4
%26 = fcmp ogt double %24, %25
br i1 %26, label %27, label %32
27: ; preds = %19
%28 = load double, double* %4
%29 = load double, double* %5
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), double %28, double %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %42
32: ; preds = %19
%33 = load double, double* %5
%34 = load double, double* %4
%35 = fcmp olt double %33, %34
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %1
br label %42
38: ; preds = %32
%39 = load double, double* %4
%40 = load double, double* %5
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), double %39, double %40)
store i32 1, i32* %1
br label %42
42: ; preds = %38, %36, %27
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [24 x i8] c"Times T1=%.2f, T2=%.2f\0A\00"
@.str.3 = [45 x i8] c"Error with processor times T1=%.2f, T2=%.2f\0A\00"
@str = [36 x i8] c"TEST AGAIN: Times probably wrapped\00"
@str.4 = [12 x i8] c"Test PASSED\00"
define i32 @main() {
%1 = tail call double (...) @clock()
%2 = load double, double* @CLOCKS_PER_SEC
%3 = fdiv double %1, %2
%4 = tail call i64 @time(i32* null)
%5 = add nsw i64 %4, 5
%6 = tail call i64 @time(i32* null)
%7 = icmp slt i64 %5, %6
br i1 %7, label %12, label %8
8: ; preds = %0, %8
%9 = tail call double (...) @clock()
%10 = tail call i64 @time(i32* null)
%11 = icmp slt i64 %5, %10
br i1 %11, label %12, label %8
12: ; preds = %8, %0
%13 = tail call double (...) @clock()
%14 = load double, double* @CLOCKS_PER_SEC
%15 = fdiv double %13, %14
%16 = fcmp ogt double %15, %3
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), double %3, double %15)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0))
br label %26
20: ; preds = %12
%21 = fcmp olt double %15, %3
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
br label %26
24: ; preds = %20
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), double %3, double %15)
br label %26
26: ; preds = %24, %22, %17
%27 = phi i32 [ 0, %17 ], [ 2, %22 ], [ 1, %24 ]
ret i32 %27
}