int test_almost_equal(void) {
  printf("\n\n\t%s\n\n", "Testing almost equal function for comparing doubles");
  ;
  int failn = 0;
  double athird1 = 0.3333333;
  double athird2 = 0.3333333;
  double athird3 = 0.3333334;
  double frac1 = 1.2345678;
  double frac2 = 1.2346789;
  if (!mpl_almost_equal(athird1, athird2)) {
    ++failn;
    printf("[  FAIL  ] %s, line: %i in: %s\n", __FUNCTION__, 111,
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/mbrazeau/MorphyLib/refs/heads/master/"
           "tests/testmorphy.c");
  } else {
    printf("[  PASS  ] %s\n", __FUNCTION__);
  }
  if (mpl_almost_equal(athird1, athird3)) {
    ++failn;
    printf("[  FAIL  ] %s, line: %i in: %s\n", __FUNCTION__, 119,
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/mbrazeau/MorphyLib/refs/heads/master/"
           "tests/testmorphy.c");
  } else {
    printf("[  PASS  ] %s\n", __FUNCTION__);
  }
  if (mpl_almost_equal(frac1, frac2)) {
    ++failn;
    printf("[  FAIL  ] %s, line: %i in: %s\n", __FUNCTION__, 127,
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/mbrazeau/MorphyLib/refs/heads/master/"
           "tests/testmorphy.c");
  } else {
    printf("[  PASS  ] %s\n", __FUNCTION__);
  }
  return failn;
}


x86 assembly (clang, -O0):
<test_almost_equal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xef1(%rip),%rdi
lea    0xef2(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
movsd  0xecc(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xebf(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeaa(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe95(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe80(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    $0x2,%al
call   1040 <mpl_almost_equal@plt>
cmp    $0x0,%eax
jne    11ce <test_almost_equal+0xae>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    0xead(%rip),%rdi
lea    0xec6(%rip),%rsi
mov    $0x6f,%edx
lea    0xecc(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <test_almost_equal+0xc3>
lea    0xf4b(%rip),%rdi
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    $0x2,%al
call   1040 <mpl_almost_equal@plt>
cmp    $0x0,%eax
je     122c <test_almost_equal+0x10c>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    0xe4f(%rip),%rdi
lea    0xe68(%rip),%rsi
mov    $0x77,%edx
lea    0xe6e(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1241 <test_almost_equal+0x121>
lea    0xeed(%rip),%rdi
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
mov    $0x2,%al
call   1040 <mpl_almost_equal@plt>
cmp    $0x0,%eax
je     128a <test_almost_equal+0x16a>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    0xdf1(%rip),%rdi
lea    0xe0a(%rip),%rsi
mov    $0x7f,%edx
lea    0xe10(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129f <test_almost_equal+0x17f>
lea    0xe8f(%rip),%rdi
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_almost_equal>:
push   %rbx
lea    0xef8(%rip),%rdi
lea    0xef9(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0xec0(%rip),%xmm0
movaps %xmm0,%xmm1
mov    $0x2,%al
call   1040 <mpl_almost_equal@plt>
test   %eax,%eax
je     1165 <test_almost_equal+0x45>
lea    0xfcb(%rip),%rdi
lea    0xf20(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    118b <test_almost_equal+0x6b>
lea    0xef0(%rip),%rdi
lea    0xf09(%rip),%rsi
lea    0xf14(%rip),%rcx
mov    $0x6f,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebx
movsd  0xe6d(%rip),%xmm0
movsd  0xe6d(%rip),%xmm1
mov    $0x2,%al
call   1040 <mpl_almost_equal@plt>
test   %eax,%eax
je     11cc <test_almost_equal+0xac>
add    $0x1,%ebx
lea    0xeac(%rip),%rdi
lea    0xec5(%rip),%rsi
lea    0xed0(%rip),%rcx
mov    $0x77,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11e1 <test_almost_equal+0xc1>
lea    0xf4d(%rip),%rdi
lea    0xea2(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0xe27(%rip),%xmm0
movsd  0xe27(%rip),%xmm1
mov    $0x2,%al
call   1040 <mpl_almost_equal@plt>
test   %eax,%eax
je     1222 <test_almost_equal+0x102>
add    $0x1,%ebx
lea    0xe56(%rip),%rdi
lea    0xe6f(%rip),%rsi
lea    0xe7a(%rip),%rcx
mov    $0x7f,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1237 <test_almost_equal+0x117>
lea    0xef7(%rip),%rdi
lea    0xe4c(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"\0A\0A\09%s\0A\0A\00"
@.str.1 = [52 x i8] c"Testing almost equal function for comparing doubles\00"
@.str.2 = [32 x i8] c"[ FAIL ] %s, line: %i in: %s\0A\00"
@__FUNCTION__.test_almost_equal = [18 x i8] c"test_almost_equal\00"
@.str.3 = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mbrazeau/MorphyLib/refs/heads/master/tests/testmorphy.c\00"
@.str.4 = [15 x i8] c"[ PASS ] %s\0A\00"
define i32 @test_almost_equal() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
store double 0x3FD55555318ABC87, double* %2
store double 0x3FD55555318ABC87, double* %3
store double 0x3FD555559CEA86F2, double* %4
store double 0x3FF3C0CA2A5B1D5D, double* %5
store double 0x3FF3C13EA988FAE6, double* %6
%8 = load double, double* %2
%9 = load double, double* %3
%10 = call i32 (double, double, ...) bitcast (i32 (...)* @mpl_almost_equal to i32 (double, double, ...)*)(double %8, double %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %0
%13 = load i32, i32* %1
%14 = add nsw i32 %13, 1
store i32 %14, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__FUNCTION__.test_almost_equal, i64 0, i64 0), i32 111, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.3, i64 0, i64 0))
br label %18
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__FUNCTION__.test_almost_equal, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
%19 = load double, double* %2
%20 = load double, double* %4
%21 = call i32 (double, double, ...) bitcast (i32 (...)* @mpl_almost_equal to i32 (double, double, ...)*)(double %19, double %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load i32, i32* %1
%25 = add nsw i32 %24, 1
store i32 %25, i32* %1
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__FUNCTION__.test_almost_equal, i64 0, i64 0), i32 119, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.3, i64 0, i64 0))
br label %29
27: ; preds = %18
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__FUNCTION__.test_almost_equal, i64 0, i64 0))
br label %29
29: ; preds = %27, %23
%30 = load double, double* %5
%31 = load double, double* %6
%32 = call i32 (double, double, ...) bitcast (i32 (...)* @mpl_almost_equal to i32 (double, double, ...)*)(double %30, double %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i32, i32* %1
%36 = add nsw i32 %35, 1
store i32 %36, i32* %1
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__FUNCTION__.test_almost_equal, i64 0, i64 0), i32 127, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.3, i64 0, i64 0))
br label %40
38: ; preds = %29
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__FUNCTION__.test_almost_equal, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [8 x i8] c"\0A\0A\09%s\0A\0A\00"
@.str.1 = [52 x i8] c"Testing almost equal function for comparing doubles\00"
@.str.2 = [32 x i8] c"[ FAIL ] %s, line: %i in: %s\0A\00"
@__FUNCTION__.test_almost_equal = [18 x i8] c"test_almost_equal\00"
@.str.3 = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mbrazeau/MorphyLib/refs/heads/master/tests/testmorphy.c\00"
@.str.4 = [15 x i8] c"[ PASS ] %s\0A\00"
define i32 @test_almost_equal() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 (double, double, ...) bitcast (i32 (...)* @mpl_almost_equal to i32 (double, double, ...)*)(double 0x3FD55555318ABC87, double 0x3FD55555318ABC87)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__FUNCTION__.test_almost_equal, i64 0, i64 0), i32 111, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.3, i64 0, i64 0))
br label %8
6: ; preds = %0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__FUNCTION__.test_almost_equal, i64 0, i64 0))
br label %8
8: ; preds = %6, %4
%9 = phi i32 [ 0, %6 ], [ 1, %4 ]
%10 = tail call i32 (double, double, ...) bitcast (i32 (...)* @mpl_almost_equal to i32 (double, double, ...)*)(double 0x3FD55555318ABC87, double 0x3FD555559CEA86F2)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = add nuw nsw i32 %9, 1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__FUNCTION__.test_almost_equal, i64 0, i64 0), i32 119, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.3, i64 0, i64 0))
br label %17
15: ; preds = %8
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__FUNCTION__.test_almost_equal, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = phi i32 [ %13, %12 ], [ %9, %15 ]
%19 = tail call i32 (double, double, ...) bitcast (i32 (...)* @mpl_almost_equal to i32 (double, double, ...)*)(double 0x3FF3C0CA2A5B1D5D, double 0x3FF3C13EA988FAE6)
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = add nuw nsw i32 %18, 1
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__FUNCTION__.test_almost_equal, i64 0, i64 0), i32 127, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.3, i64 0, i64 0))
br label %26
24: ; preds = %17
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @__FUNCTION__.test_almost_equal, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
%27 = phi i32 [ %22, %21 ], [ %18, %24 ]
ret i32 %27
}