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

/* Variables and functions */
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  time_t time1, time0;
  double time_diff;
  time_diff = 0;
  time0 = time(NULL);
  sleep(1);
  time1 = time(NULL);
  time_diff = difftime(time1, time0);
  if (time_diff != 1) {
    perror("Test FAILED: difftime did not return the correct value\n");
    return 1;
  }
  printf("Test PASSED\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0xc(%rbp)
mov    $0x1,%edi
call   1070 <sleep@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <difftime@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe5a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11bb <main+0x6b>
jp     11bb <main+0x6b>
jmp    11d3 <main+0x83>
lea    0xe46(%rip),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e6 <main+0x96>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%ebp
mov    $0x1,%ebx
mov    $0x1,%edi
call   1070 <sleep@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1040 <difftime@plt>
ucomisd 0xe7d(%rip),%xmm0
jne    119e <main+0x4e>
jp     119e <main+0x4e>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe63(%rip),%rdi
call   1060 <perror@plt>
jmp    1195 <main+0x45>

LLVM IR (-O0):
@.str = [56 x i8] c"Test FAILED: difftime did not return the correct value\0A\00"
@.str.1 = [13 x i8] c"Test PASSED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %4
%5 = call i32 @time(i32* null)
store i32 %5, i32* %3
%6 = call i32 @sleep(i32 1)
%7 = call i32 @time(i32* null)
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = call double @difftime(i32 %8, i32 %9)
store double %10, double* %4
%11 = load double, double* %4
%12 = fcmp une double %11, 1.000000e+00
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @perror(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %17
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %17
17: ; preds = %15, %13
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [56 x i8] c"Test FAILED: difftime did not return the correct value\0A\00"
@str = [12 x i8] c"Test PASSED\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @sleep(i32 1)
%3 = tail call i32 @time(i32* null)
%4 = tail call double @difftime(i32 %3, i32 %1)
%5 = fcmp une double %4, 1.000000e+00
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 @perror(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
br label %10
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
%11 = phi i32 [ 1, %6 ], [ 0, %8 ]
ret i32 %11
}