#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*/ mpfr_t;
typedef int mp_prec_t;

/* Variables and functions */
int /*<<< orphan*/ GMP_RNDN;
int /*<<< orphan*/ mpfr_add(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_clear(int /*<<< orphan*/);
int mpfr_get_prec(int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_init2(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpfr_set_d(int /*<<< orphan*/, double, int /*<<< orphan*/);
void doubledouble_to_mpfr(mpfr_t rop, double dh, double dm) {
  mpfr_t temp;
  mp_prec_t prec;
  prec = mpfr_get_prec(rop);
  if (prec < 53)
    prec = 53;
  mpfr_init2(temp, prec);
  mpfr_set_d(rop, dh, GMP_RNDN);
  mpfr_set_d(temp, dm, GMP_RNDN);
  mpfr_add(rop, rop, temp, GMP_RNDN);
  mpfr_clear(temp);
}


x86 assembly (clang, -O0):
<doubledouble_to_mpfr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <mpfr_get_prec@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x35,-0x20(%rbp)
jge    1181 <doubledouble_to_mpfr+0x31>
movl   $0x35,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1070 <mpfr_init2@plt>
mov    -0x4(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
call   1030 <mpfr_set_d@plt>
mov    -0x1c(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
mov    0x2e2f(%rip),%rax
mov    (%rax),%esi
call   1030 <mpfr_set_d@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    0x2e18(%rip),%rax
mov    (%rax),%ecx
call   1050 <mpfr_add@plt>
mov    -0x1c(%rbp),%edi
call   1040 <mpfr_clear@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubledouble_to_mpfr>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %edi,%ebx
call   1060 <mpfr_get_prec@plt>
cmp    $0x36,%eax
mov    $0x35,%esi
cmovge %eax,%esi
call   1070 <mpfr_init2@plt>
mov    0x2e5f(%rip),%r14
mov    (%r14),%esi
mov    %ebx,%edi
movsd  0x8(%rsp),%xmm0
call   1030 <mpfr_set_d@plt>
mov    (%r14),%esi
movsd  0x10(%rsp),%xmm0
call   1030 <mpfr_set_d@plt>
mov    (%r14),%ecx
mov    %ebx,%edi
mov    %ebx,%esi
call   1050 <mpfr_add@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1040 <mpfr_clear@plt>

LLVM IR (-O0):
@GMP_RNDN = global i32 0
define void @doubledouble_to_mpfr(i32 %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store double %1, double* %5
store double %2, double* %6
%9 = load i32, i32* %4
%10 = call i32 @mpfr_get_prec(i32 %9)
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = icmp slt i32 %11, 53
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 53, i32* %8
br label %14
14: ; preds = %13, %3
%15 = load i32, i32* %7
%16 = load i32, i32* %8
%17 = call i32 @mpfr_init2(i32 %15, i32 %16)
%18 = load i32, i32* %4
%19 = load double, double* %5
%20 = load i32, i32* @GMP_RNDN
%21 = call i32 @mpfr_set_d(i32 %18, double %19, i32 %20)
%22 = load i32, i32* %7
%23 = load double, double* %6
%24 = load i32, i32* @GMP_RNDN
%25 = call i32 @mpfr_set_d(i32 %22, double %23, i32 %24)
%26 = load i32, i32* %4
%27 = load i32, i32* %4
%28 = load i32, i32* %7
%29 = load i32, i32* @GMP_RNDN
%30 = call i32 @mpfr_add(i32 %26, i32 %27, i32 %28, i32 %29)
%31 = load i32, i32* %7
%32 = call i32 @mpfr_clear(i32 %31)
ret void
}

LLVM IR (-O2):
@GMP_RNDN = global i32 0
define void @doubledouble_to_mpfr(i32 %0, double %1, double %2) {
%4 = tail call i32 @mpfr_get_prec(i32 %0)
%5 = icmp sgt i32 %4, 53
%6 = select i1 %5, i32 %4, i32 53
%7 = tail call i32 @mpfr_init2(i32 undef, i32 %6)
%8 = load i32, i32* @GMP_RNDN
%9 = tail call i32 @mpfr_set_d(i32 %0, double %1, i32 %8)
%10 = load i32, i32* @GMP_RNDN
%11 = tail call i32 @mpfr_set_d(i32 undef, double %2, i32 %10)
%12 = load i32, i32* @GMP_RNDN
%13 = tail call i32 @mpfr_add(i32 %0, i32 %0, i32 undef, i32 %12)
%14 = tail call i32 @mpfr_clear(i32 undef)
ret void
}