#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;

/* 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 /*<<< orphan*/ mpfr_get_prec(int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_init2(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_set(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_set_d(int /*<<< orphan*/, double, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_sub(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
double sollya_mpfr_get_d(int /*<<< orphan*/, int /*<<< orphan*/);
void mpfr_to_doubledouble(double *dh, double *dm, mpfr_t op) {
  mpfr_t rest, temp;
  mpfr_init2(rest, mpfr_get_prec(op));
  mpfr_init2(temp, mpfr_get_prec(op));
  mpfr_set(rest, op, GMP_RNDN);
  *dh = sollya_mpfr_get_d(rest, GMP_RNDN);
  mpfr_set_d(temp, *dh, GMP_RNDN);
  mpfr_set(op, temp, GMP_RNDN);
  mpfr_sub(rest, rest, temp, GMP_RNDN);
  *dm = sollya_mpfr_get_d(rest, GMP_RNDN);
  mpfr_set_d(temp, *dm, GMP_RNDN);
  mpfr_add(op, op, temp, GMP_RNDN);
  mpfr_clear(rest);
  mpfr_clear(temp);
}


x86 assembly (clang, -O0):
<mpfr_to_doubledouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
call   1090 <mpfr_get_prec@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
call   10a0 <mpfr_init2@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1090 <mpfr_get_prec@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%esi
call   10a0 <mpfr_init2@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    0x2e10(%rip),%rax
mov    (%rax),%edx
call   1070 <mpfr_set@plt>
mov    -0x18(%rbp),%edi
mov    0x2dff(%rip),%rax
mov    (%rax),%esi
call   1080 <sollya_mpfr_get_d@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x1c(%rbp),%edi
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x2dde(%rip),%rax
mov    (%rax),%esi
call   1040 <mpfr_set_d@plt>
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    0x2dca(%rip),%rax
mov    (%rax),%edx
call   1070 <mpfr_set@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    0x2db3(%rip),%rax
mov    (%rax),%ecx
call   1030 <mpfr_sub@plt>
mov    -0x18(%rbp),%edi
mov    0x2da2(%rip),%rax
mov    (%rax),%esi
call   1080 <sollya_mpfr_get_d@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x2d81(%rip),%rax
mov    (%rax),%esi
call   1040 <mpfr_set_d@plt>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    0x2d6a(%rip),%rax
mov    (%rax),%ecx
call   1060 <mpfr_add@plt>
mov    -0x18(%rbp),%edi
call   1050 <mpfr_clear@plt>
mov    -0x1c(%rbp),%edi
call   1050 <mpfr_clear@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpfr_to_doubledouble>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%edi
call   1090 <mpfr_get_prec@plt>
mov    %eax,%esi
call   10a0 <mpfr_init2@plt>
mov    %ebx,%edi
call   1090 <mpfr_get_prec@plt>
mov    %eax,%esi
call   10a0 <mpfr_init2@plt>
mov    0x2e2d(%rip),%r12
mov    (%r12),%edx
mov    %ebx,%esi
call   1070 <mpfr_set@plt>
mov    (%r12),%esi
call   1080 <sollya_mpfr_get_d@plt>
movsd  %xmm0,(%r15)
mov    (%r12),%esi
call   1040 <mpfr_set_d@plt>
mov    (%r12),%edx
mov    %ebx,%edi
call   1070 <mpfr_set@plt>
mov    (%r12),%ecx
call   1030 <mpfr_sub@plt>
mov    (%r12),%esi
call   1080 <sollya_mpfr_get_d@plt>
movsd  %xmm0,(%r14)
mov    (%r12),%esi
call   1040 <mpfr_set_d@plt>
mov    (%r12),%ecx
mov    %ebx,%edi
mov    %ebx,%esi
call   1060 <mpfr_add@plt>
call   1050 <mpfr_clear@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <mpfr_clear@plt>

LLVM IR (-O0):
@GMP_RNDN = global i32 0
define void @mpfr_to_doubledouble(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = call i32 @mpfr_get_prec(i32 %10)
%12 = call i32 @mpfr_init2(i32 %9, i32 %11)
%13 = load i32, i32* %8
%14 = load i32, i32* %6
%15 = call i32 @mpfr_get_prec(i32 %14)
%16 = call i32 @mpfr_init2(i32 %13, i32 %15)
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = load i32, i32* @GMP_RNDN
%20 = call i32 @mpfr_set(i32 %17, i32 %18, i32 %19)
%21 = load i32, i32* %7
%22 = load i32, i32* @GMP_RNDN
%23 = call double @sollya_mpfr_get_d(i32 %21, i32 %22)
%24 = load double*, double** %4
store double %23, double* %24
%25 = load i32, i32* %8
%26 = load double*, double** %4
%27 = load double, double* %26
%28 = load i32, i32* @GMP_RNDN
%29 = call i32 @mpfr_set_d(i32 %25, double %27, i32 %28)
%30 = load i32, i32* %6
%31 = load i32, i32* %8
%32 = load i32, i32* @GMP_RNDN
%33 = call i32 @mpfr_set(i32 %30, i32 %31, i32 %32)
%34 = load i32, i32* %7
%35 = load i32, i32* %7
%36 = load i32, i32* %8
%37 = load i32, i32* @GMP_RNDN
%38 = call i32 @mpfr_sub(i32 %34, i32 %35, i32 %36, i32 %37)
%39 = load i32, i32* %7
%40 = load i32, i32* @GMP_RNDN
%41 = call double @sollya_mpfr_get_d(i32 %39, i32 %40)
%42 = load double*, double** %5
store double %41, double* %42
%43 = load i32, i32* %8
%44 = load double*, double** %5
%45 = load double, double* %44
%46 = load i32, i32* @GMP_RNDN
%47 = call i32 @mpfr_set_d(i32 %43, double %45, i32 %46)
%48 = load i32, i32* %6
%49 = load i32, i32* %6
%50 = load i32, i32* %8
%51 = load i32, i32* @GMP_RNDN
%52 = call i32 @mpfr_add(i32 %48, i32 %49, i32 %50, i32 %51)
%53 = load i32, i32* %7
%54 = call i32 @mpfr_clear(i32 %53)
%55 = load i32, i32* %8
%56 = call i32 @mpfr_clear(i32 %55)
ret void
}

LLVM IR (-O2):
@GMP_RNDN = global i32 0
define void @mpfr_to_doubledouble(double* nocapture writeonly %0, double* nocapture writeonly %1, i32 %2) {
%4 = tail call i32 @mpfr_get_prec(i32 %2)
%5 = tail call i32 @mpfr_init2(i32 undef, i32 %4)
%6 = tail call i32 @mpfr_get_prec(i32 %2)
%7 = tail call i32 @mpfr_init2(i32 undef, i32 %6)
%8 = load i32, i32* @GMP_RNDN
%9 = tail call i32 @mpfr_set(i32 undef, i32 %2, i32 %8)
%10 = load i32, i32* @GMP_RNDN
%11 = tail call double @sollya_mpfr_get_d(i32 undef, i32 %10)
store double %11, double* %0
%12 = load i32, i32* @GMP_RNDN
%13 = tail call i32 @mpfr_set_d(i32 undef, double %11, i32 %12)
%14 = load i32, i32* @GMP_RNDN
%15 = tail call i32 @mpfr_set(i32 %2, i32 undef, i32 %14)
%16 = load i32, i32* @GMP_RNDN
%17 = tail call i32 @mpfr_sub(i32 undef, i32 undef, i32 undef, i32 %16)
%18 = load i32, i32* @GMP_RNDN
%19 = tail call double @sollya_mpfr_get_d(i32 undef, i32 %18)
store double %19, double* %1
%20 = load i32, i32* @GMP_RNDN
%21 = tail call i32 @mpfr_set_d(i32 undef, double %19, i32 %20)
%22 = load i32, i32* @GMP_RNDN
%23 = tail call i32 @mpfr_add(i32 %2, i32 %2, i32 undef, i32 %22)
%24 = tail call i32 @mpfr_clear(i32 undef)
%25 = tail call i32 @mpfr_clear(i32 undef)
ret void
}