#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 */

/* Variables and functions */
double DBL_EPSILON;
double RAND_MAX;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  const int N = 10;
  double a;
  double b;
  double c;
  double d;
  printf("DBL_EPSILON = %g \n", DBL_EPSILON);
  srand(time(NULL));
  for (int i = 0; i < N; i++) {
    a = (double)rand() / RAND_MAX;
    b = (double)rand() / RAND_MAX;
    c = 0.0;
    c += a;
    c += b;
    d = c;
    d -= b;
    d -= a;
    printf("% 3d : ", i);
    if (d != 0.0) {
      printf("FAIL (d = %+.4f * DBL_EPSILON)\n", d / DBL_EPSILON);
    } else {
      printf("PASS\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    0x2e8b(%rip),%rax
movsd  (%rax),%xmm0
lea    0xe98(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0xa,-0x2c(%rbp)
jge    1290 <main+0x150>
mov    $0x0,%al
call   1060 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e3d(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e21(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    124c <main+0x10c>
jp     124c <main+0x10c>
jmp    126f <main+0x12f>
movsd  -0x28(%rbp),%xmm0
mov    0x2d90(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdb8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    127d <main+0x13d>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1282 <main+0x142>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1186 <main+0x46>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e86(%rip),%r12
movsd  (%r12),%xmm0
lea    0xe99(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    0x2e55(%rip),%rbx
lea    0xe89(%rip),%r13
lea    0xe8a(%rip),%r14
lea    0xea3(%rip),%r15
xor    %ebp,%ebp
jmp    11c0 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1030 <puts@plt>
add    $0x1,%ebp
cmp    $0xa,%ebp
je     123f <main+0xef>
xor    %eax,%eax
call   1070 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%rbx),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%rbx),%xmm0
movsd  (%rsp),%xmm1
movapd %xmm1,%xmm3
xorpd  %xmm2,%xmm2
addsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
subsd  %xmm0,%xmm3
subsd  %xmm1,%xmm3
movsd  %xmm3,(%rsp)
mov    %r13,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
ucomisd 0xdda(%rip),%xmm0
jne    122a <main+0xda>
jnp    11b0 <main+0x60>
divsd  (%r12),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11b8 <main+0x68>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"DBL_EPSILON = %g \0A\00"
@DBL_EPSILON = global double 0.000000e+00
@RAND_MAX = global double 0.000000e+00
@.str.1 = [8 x i8] c"% 3d : \00"
@.str.2 = [32 x i8] c"FAIL (d = %+.4f * DBL_EPSILON)\0A\00"
@.str.3 = [6 x i8] c"PASS\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
%8 = load double, double* @DBL_EPSILON
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %8)
%10 = call i32 @time(i32* null)
%11 = call i32 @srand(i32 %10)
store i32 0, i32* %7
br label %12
12: ; preds = %49, %0
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 10
br i1 %14, label %15, label %52
15: ; preds = %12
%16 = call i64 (...) @rand()
%17 = sitofp i64 %16 to double
%18 = load double, double* @RAND_MAX
%19 = fdiv double %17, %18
store double %19, double* %3
%20 = call i64 (...) @rand()
%21 = sitofp i64 %20 to double
%22 = load double, double* @RAND_MAX
%23 = fdiv double %21, %22
store double %23, double* %4
store double 0.000000e+00, double* %5
%24 = load double, double* %3
%25 = load double, double* %5
%26 = fadd double %25, %24
store double %26, double* %5
%27 = load double, double* %4
%28 = load double, double* %5
%29 = fadd double %28, %27
store double %29, double* %5
%30 = load double, double* %5
store double %30, double* %6
%31 = load double, double* %4
%32 = load double, double* %6
%33 = fsub double %32, %31
store double %33, double* %6
%34 = load double, double* %3
%35 = load double, double* %6
%36 = fsub double %35, %34
store double %36, double* %6
%37 = load i32, i32* %7
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = load double, double* %6
%40 = fcmp une double %39, 0.000000e+00
br i1 %40, label %41, label %46
41: ; preds = %15
%42 = load double, double* %6
%43 = load double, double* @DBL_EPSILON
%44 = fdiv double %42, %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), double %44)
br label %48
46: ; preds = %15
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %48
48: ; preds = %46, %41
br label %49
49: ; preds = %48
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %12
52: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"DBL_EPSILON = %g \0A\00"
@DBL_EPSILON = global double 0.000000e+00
@RAND_MAX = global double 0.000000e+00
@.str.1 = [8 x i8] c"% 3d : \00"
@.str.2 = [32 x i8] c"FAIL (d = %+.4f * DBL_EPSILON)\0A\00"
@str = [5 x i8] c"PASS\00"
define i32 @main() {
%1 = load double, double* @DBL_EPSILON
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %1)
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
br label %6
5: ; preds = %28
ret i32 0
6: ; preds = %0, %28
%7 = phi i32 [ 0, %0 ], [ %29, %28 ]
%8 = tail call i64 (...) @rand()
%9 = sitofp i64 %8 to double
%10 = load double, double* @RAND_MAX
%11 = fdiv double %9, %10
%12 = tail call i64 (...) @rand()
%13 = sitofp i64 %12 to double
%14 = load double, double* @RAND_MAX
%15 = fdiv double %13, %14
%16 = fadd double %11, 0.000000e+00
%17 = fadd double %16, %15
%18 = fsub double %17, %15
%19 = fsub double %18, %11
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%21 = fcmp une double %19, 0.000000e+00
br i1 %21, label %22, label %26
22: ; preds = %6
%23 = load double, double* @DBL_EPSILON
%24 = fdiv double %19, %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), double %24)
br label %28
26: ; preds = %6
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %28
28: ; preds = %22, %26
%29 = add nuw nsw i32 %7, 1
%30 = icmp eq i32 %29, 10
br i1 %30, label %5, label %6
}