#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 */
int doubles_equal_helper(double, int, double, unsigned int);
double frexp(double, int *);
int assert_doubles_equal(double d1, double d2, unsigned fuzz_ulps) {
  int exp1, exp2;
  double frac1 = frexp(d1, &exp1);
  double frac2 = frexp(d2, &exp2);
  return (exp2 > exp1) ? (doubles_equal_helper(frac1, exp1, d2, fuzz_ulps))
                       : (doubles_equal_helper(frac2, exp2, d1, fuzz_ulps));
}


x86 assembly (clang, -O0):
<assert_doubles_equal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    -0x18(%rbp),%rdi
call   1040 <frexp@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    -0x1c(%rbp),%rdi
call   1040 <frexp@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    1184 <assert_doubles_equal+0x64>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%edi
movsd  -0x10(%rbp),%xmm1
mov    -0x14(%rbp),%esi
call   1030 <doubles_equal_helper@plt>
mov    %eax,-0x34(%rbp)
jmp    119c <assert_doubles_equal+0x7c>
movsd  -0x30(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
movsd  -0x8(%rbp),%xmm1
mov    -0x14(%rbp),%esi
call   1030 <doubles_equal_helper@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assert_doubles_equal>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
movsd  %xmm1,0x8(%rsp)
lea    0x4(%rsp),%rdi
movsd  %xmm0,0x18(%rsp)
call   1040 <frexp@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rsp,%rdi
movsd  0x8(%rsp),%xmm0
call   1040 <frexp@plt>
mov    (%rsp),%edi
mov    0x4(%rsp),%eax
cmp    %eax,%edi
jle    116c <assert_doubles_equal+0x4c>
movsd  0x10(%rsp),%xmm0
mov    %eax,%edi
movsd  0x8(%rsp),%xmm1
jmp    1172 <assert_doubles_equal+0x52>
movsd  0x18(%rsp),%xmm1
mov    %ebx,%esi
add    $0x20,%rsp
pop    %rbx
jmp    1030 <doubles_equal_helper@plt>

LLVM IR (-O0):
define i32 @assert_doubles_equal(double %0, double %1, i32 %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
store double %0, double* %4
store double %1, double* %5
store i32 %2, i32* %6
%11 = load double, double* %4
%12 = call double @frexp(double %11, i32* %7)
store double %12, double* %9
%13 = load double, double* %5
%14 = call double @frexp(double %13, i32* %8)
store double %14, double* %10
%15 = load i32, i32* %8
%16 = load i32, i32* %7
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %24
18: ; preds = %3
%19 = load double, double* %9
%20 = load i32, i32* %7
%21 = load double, double* %5
%22 = load i32, i32* %6
%23 = call i32 @doubles_equal_helper(double %19, i32 %20, double %21, i32 %22)
br label %30
24: ; preds = %3
%25 = load double, double* %10
%26 = load i32, i32* %8
%27 = load double, double* %4
%28 = load i32, i32* %6
%29 = call i32 @doubles_equal_helper(double %25, i32 %26, double %27, i32 %28)
br label %30
30: ; preds = %24, %18
%31 = phi i32 [ %23, %18 ], [ %29, %24 ]
ret i32 %31
}

LLVM IR (-O2):
define i32 @assert_doubles_equal(double %0, double %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = call double @frexp(double %0, i32* %4)
%9 = call double @frexp(double %1, i32* %5)
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp sgt i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = tail call i32 @doubles_equal_helper(double %8, i32 %11, double %1, i32 %2)
br label %17
15: ; preds = %3
%16 = tail call i32 @doubles_equal_helper(double %9, i32 %10, double %0, i32 %2)
br label %17
17: ; preds = %15, %13
%18 = phi i32 [ %14, %13 ], [ %16, %15 ]
ret i32 %18
}