#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 */
double difftime(scalar_t__, scalar_t__);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ time(int /*<<< orphan*/ *);
int main(void) {
  time_t time0;
  double time_diff;
  time0 = time(NULL);
  time_diff = difftime(time0 + 1, 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)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <difftime@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1194 <main+0x54>
jp     1194 <main+0x54>
jmp    11ac <main+0x6c>
lea    0xe6d(%rip),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11bf <main+0x7f>
lea    0xe8d(%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   %rbx
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <time@plt>
lea    0x1(%rax),%rdi
mov    %rax,%rsi
call   1040 <difftime@plt>
ucomisd 0xea2(%rip),%xmm0
jne    1172 <main+0x32>
jp     1172 <main+0x32>
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret
lea    0xe8f(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%ebx
jmp    116e <main+0x2e>

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 i64
%3 = alloca double
store i32 0, i32* %1
%4 = call i64 @time(i32* null)
store i64 %4, i64* %2
%5 = load i64, i64* %2
%6 = add nsw i64 %5, 1
%7 = load i64, i64* %2
%8 = call double @difftime(i64 %6, i64 %7)
store double %8, double* %3
%9 = load double, double* %3
%10 = fcmp une double %9, 1.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @perror(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %15
13: ; preds = %0
%14 = 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 %15
15: ; preds = %13, %11
%16 = load i32, i32* %1
ret i32 %16
}

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 i64 @time(i32* null)
%2 = add nsw i64 %1, 1
%3 = tail call double @difftime(i64 %2, i64 %1)
%4 = fcmp une double %3, 1.000000e+00
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
br label %9
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ 1, %5 ], [ 0, %7 ]
ret i32 %10
}