#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_tripledouble(double *dh, double *dm, double *dl, 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_sub(rest, rest, temp, GMP_RNDN);
  *dl = sollya_mpfr_get_d(rest, GMP_RNDN);
  mpfr_set_d(temp, *dl, GMP_RNDN);
  mpfr_add(op, op, temp, GMP_RNDN);
  mpfr_clear(rest);
  mpfr_clear(temp);
}


x86 assembly (clang, -O0):
<mpfr_to_tripledouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
call   1090 <mpfr_get_prec@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
call   10a0 <mpfr_init2@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
call   1090 <mpfr_get_prec@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%esi
call   10a0 <mpfr_init2@plt>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    0x2e0c(%rip),%rax
mov    (%rax),%edx
call   1070 <mpfr_set@plt>
mov    -0x20(%rbp),%edi
mov    0x2dfb(%rip),%rax
mov    (%rax),%esi
call   1080 <sollya_mpfr_get_d@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x24(%rbp),%edi
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x2dda(%rip),%rax
mov    (%rax),%esi
call   1040 <mpfr_set_d@plt>
mov    -0x1c(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    0x2dc6(%rip),%rax
mov    (%rax),%edx
call   1070 <mpfr_set@plt>
mov    -0x20(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x2daf(%rip),%rax
mov    (%rax),%ecx
call   1030 <mpfr_sub@plt>
mov    -0x20(%rbp),%edi
mov    0x2d9e(%rip),%rax
mov    (%rax),%esi
call   1080 <sollya_mpfr_get_d@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x2d7d(%rip),%rax
mov    (%rax),%esi
call   1040 <mpfr_set_d@plt>
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x2d66(%rip),%rax
mov    (%rax),%ecx
call   1060 <mpfr_add@plt>
mov    -0x20(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x2d4f(%rip),%rax
mov    (%rax),%ecx
call   1030 <mpfr_sub@plt>
mov    -0x20(%rbp),%edi
mov    0x2d3e(%rip),%rax
mov    (%rax),%esi
call   1080 <sollya_mpfr_get_d@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    0x2d1d(%rip),%rax
mov    (%rax),%esi
call   1040 <mpfr_set_d@plt>
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x2d06(%rip),%rax
mov    (%rax),%ecx
call   1060 <mpfr_add@plt>
mov    -0x20(%rbp),%edi
call   1050 <mpfr_clear@plt>
mov    -0x24(%rbp),%edi
call   1050 <mpfr_clear@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpfr_to_tripledouble>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %ecx,%ebx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %ecx,%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    0x2e29(%rip),%r13
mov    0x0(%r13),%edx
mov    %ebx,%esi
call   1070 <mpfr_set@plt>
mov    0x0(%r13),%esi
call   1080 <sollya_mpfr_get_d@plt>
movsd  %xmm0,(%r12)
mov    0x0(%r13),%esi
call   1040 <mpfr_set_d@plt>
mov    0x0(%r13),%edx
mov    %ebx,%edi
call   1070 <mpfr_set@plt>
mov    0x0(%r13),%ecx
call   1030 <mpfr_sub@plt>
mov    0x0(%r13),%esi
call   1080 <sollya_mpfr_get_d@plt>
movsd  %xmm0,(%r15)
mov    0x0(%r13),%esi
call   1040 <mpfr_set_d@plt>
mov    0x0(%r13),%ecx
mov    %ebx,%edi
mov    %ebx,%esi
call   1060 <mpfr_add@plt>
mov    0x0(%r13),%ecx
call   1030 <mpfr_sub@plt>
mov    0x0(%r13),%esi
call   1080 <sollya_mpfr_get_d@plt>
movsd  %xmm0,(%r14)
mov    0x0(%r13),%esi
call   1040 <mpfr_set_d@plt>
mov    0x0(%r13),%ecx
mov    %ebx,%edi
mov    %ebx,%esi
call   1060 <mpfr_add@plt>
call   1050 <mpfr_clear@plt>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1050 <mpfr_clear@plt>

LLVM IR (-O0):
@GMP_RNDN = global i32 0
define void @mpfr_to_tripledouble(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
%11 = load i32, i32* %9
%12 = load i32, i32* %8
%13 = call i32 @mpfr_get_prec(i32 %12)
%14 = call i32 @mpfr_init2(i32 %11, i32 %13)
%15 = load i32, i32* %10
%16 = load i32, i32* %8
%17 = call i32 @mpfr_get_prec(i32 %16)
%18 = call i32 @mpfr_init2(i32 %15, i32 %17)
%19 = load i32, i32* %9
%20 = load i32, i32* %8
%21 = load i32, i32* @GMP_RNDN
%22 = call i32 @mpfr_set(i32 %19, i32 %20, i32 %21)
%23 = load i32, i32* %9
%24 = load i32, i32* @GMP_RNDN
%25 = call double @sollya_mpfr_get_d(i32 %23, i32 %24)
%26 = load double*, double** %5
store double %25, double* %26
%27 = load i32, i32* %10
%28 = load double*, double** %5
%29 = load double, double* %28
%30 = load i32, i32* @GMP_RNDN
%31 = call i32 @mpfr_set_d(i32 %27, double %29, i32 %30)
%32 = load i32, i32* %8
%33 = load i32, i32* %10
%34 = load i32, i32* @GMP_RNDN
%35 = call i32 @mpfr_set(i32 %32, i32 %33, i32 %34)
%36 = load i32, i32* %9
%37 = load i32, i32* %9
%38 = load i32, i32* %10
%39 = load i32, i32* @GMP_RNDN
%40 = call i32 @mpfr_sub(i32 %36, i32 %37, i32 %38, i32 %39)
%41 = load i32, i32* %9
%42 = load i32, i32* @GMP_RNDN
%43 = call double @sollya_mpfr_get_d(i32 %41, i32 %42)
%44 = load double*, double** %6
store double %43, double* %44
%45 = load i32, i32* %10
%46 = load double*, double** %6
%47 = load double, double* %46
%48 = load i32, i32* @GMP_RNDN
%49 = call i32 @mpfr_set_d(i32 %45, double %47, i32 %48)
%50 = load i32, i32* %8
%51 = load i32, i32* %8
%52 = load i32, i32* %10
%53 = load i32, i32* @GMP_RNDN
%54 = call i32 @mpfr_add(i32 %50, i32 %51, i32 %52, i32 %53)
%55 = load i32, i32* %9
%56 = load i32, i32* %9
%57 = load i32, i32* %10
%58 = load i32, i32* @GMP_RNDN
%59 = call i32 @mpfr_sub(i32 %55, i32 %56, i32 %57, i32 %58)
%60 = load i32, i32* %9
%61 = load i32, i32* @GMP_RNDN
%62 = call double @sollya_mpfr_get_d(i32 %60, i32 %61)
%63 = load double*, double** %7
store double %62, double* %63
%64 = load i32, i32* %10
%65 = load double*, double** %7
%66 = load double, double* %65
%67 = load i32, i32* @GMP_RNDN
%68 = call i32 @mpfr_set_d(i32 %64, double %66, i32 %67)
%69 = load i32, i32* %8
%70 = load i32, i32* %8
%71 = load i32, i32* %10
%72 = load i32, i32* @GMP_RNDN
%73 = call i32 @mpfr_add(i32 %69, i32 %70, i32 %71, i32 %72)
%74 = load i32, i32* %9
%75 = call i32 @mpfr_clear(i32 %74)
%76 = load i32, i32* %10
%77 = call i32 @mpfr_clear(i32 %76)
ret void
}

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