#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 tripledouble_to_mpfr(mpfr_t rop, double dh, double dm, double dl) {
  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_set_d(temp, dl, GMP_RNDN);
  mpfr_add(rop, rop, temp, GMP_RNDN);
  mpfr_clear(temp);
}


x86 assembly (clang, -O0):
<tripledouble_to_mpfr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <mpfr_get_prec@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x35,-0x28(%rbp)
jge    1186 <tripledouble_to_mpfr+0x36>
movl   $0x35,-0x28(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1070 <mpfr_init2@plt>
mov    -0x4(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
mov    0x2e40(%rip),%rax
mov    (%rax),%esi
call   1030 <mpfr_set_d@plt>
mov    -0x24(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
call   1030 <mpfr_set_d@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x2e13(%rip),%rax
mov    (%rax),%ecx
call   1050 <mpfr_add@plt>
mov    -0x24(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
mov    0x2dfd(%rip),%rax
mov    (%rax),%esi
call   1030 <mpfr_set_d@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    0x2de6(%rip),%rax
mov    (%rax),%ecx
call   1050 <mpfr_add@plt>
mov    -0x24(%rbp),%edi
call   1040 <mpfr_clear@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tripledouble_to_mpfr>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%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    0x2e5a(%rip),%r14
mov    (%r14),%esi
mov    %ebx,%edi
movsd  (%rsp),%xmm0
call   1030 <mpfr_set_d@plt>
mov    (%r14),%esi
movsd  0x8(%rsp),%xmm0
call   1030 <mpfr_set_d@plt>
mov    (%r14),%ecx
mov    %ebx,%edi
mov    %ebx,%esi
call   1050 <mpfr_add@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 @tripledouble_to_mpfr(i32 %0, double %1, double %2, double %3) {
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%11 = load i32, i32* %5
%12 = call i32 @mpfr_get_prec(i32 %11)
store i32 %12, i32* %10
%13 = load i32, i32* %10
%14 = icmp slt i32 %13, 53
br i1 %14, label %15, label %16
15: ; preds = %4
store i32 53, i32* %10
br label %16
16: ; preds = %15, %4
%17 = load i32, i32* %9
%18 = load i32, i32* %10
%19 = call i32 @mpfr_init2(i32 %17, i32 %18)
%20 = load i32, i32* %5
%21 = load double, double* %6
%22 = load i32, i32* @GMP_RNDN
%23 = call i32 @mpfr_set_d(i32 %20, double %21, i32 %22)
%24 = load i32, i32* %9
%25 = load double, double* %7
%26 = load i32, i32* @GMP_RNDN
%27 = call i32 @mpfr_set_d(i32 %24, double %25, i32 %26)
%28 = load i32, i32* %5
%29 = load i32, i32* %5
%30 = load i32, i32* %9
%31 = load i32, i32* @GMP_RNDN
%32 = call i32 @mpfr_add(i32 %28, i32 %29, i32 %30, i32 %31)
%33 = load i32, i32* %9
%34 = load double, double* %8
%35 = load i32, i32* @GMP_RNDN
%36 = call i32 @mpfr_set_d(i32 %33, double %34, i32 %35)
%37 = load i32, i32* %5
%38 = load i32, i32* %5
%39 = load i32, i32* %9
%40 = load i32, i32* @GMP_RNDN
%41 = call i32 @mpfr_add(i32 %37, i32 %38, i32 %39, i32 %40)
%42 = load i32, i32* %9
%43 = call i32 @mpfr_clear(i32 %42)
ret void
}

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