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

/* Variables and functions */
scalar_t__ MPFR_PREC_MAX;
int /*<<< orphan*/ MPFR_RNDN;
int /*<<< orphan*/ m_init2(int /*<<< orphan*/, scalar_t__);
scalar_t__ mpfr_get_prec(int /*<<< orphan*/ const);
int /*<<< orphan*/ mpfr_set(int /*<<< orphan*/, int /*<<< orphan*/ const,
                            int /*<<< orphan*/);
void handleExtendedRounding(mpfr_t longValue1, mpfr_t longValue2,
                            mpfr_t longResult, const mpfr_t shortValue1,
                            const mpfr_t shortValue2) {
  mpfr_prec_t currentPrecision1 = mpfr_get_prec(shortValue1);
  mpfr_prec_t currentPrecision2 = mpfr_get_prec(shortValue2);
  mpfr_prec_t extendedPrecision = 0L;
  if (currentPrecision1 + currentPrecision2 < MPFR_PREC_MAX) {
    extendedPrecision = currentPrecision1 + currentPrecision2;
  } else {
    extendedPrecision = MPFR_PREC_MAX;
  }
  m_init2(longValue1, extendedPrecision);
  m_init2(longValue2, extendedPrecision);
  m_init2(longResult, extendedPrecision);
  mpfr_set(longValue1, shortValue1, MPFR_RNDN);
  mpfr_set(longValue2, shortValue2, MPFR_RNDN);
}


x86 assembly (clang, -O0):
<handleExtendedRounding>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <mpfr_get_prec@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <mpfr_get_prec@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    0x2e59(%rip),%rcx
cmp    (%rcx),%rax
jge    1191 <handleExtendedRounding+0x61>
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    119f <handleExtendedRounding+0x6f>
mov    0x2e38(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1050 <m_init2@plt>
mov    -0x8(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1050 <m_init2@plt>
mov    -0xc(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1050 <m_init2@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    0x2e18(%rip),%rax
mov    (%rax),%edx
call   1030 <mpfr_set@plt>
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    0x2e04(%rip),%rax
mov    (%rax),%edx
call   1030 <mpfr_set@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handleExtendedRounding>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%r13d
mov    %edx,%r12d
mov    %esi,%r15d
mov    %edi,%ebp
mov    %ecx,%edi
call   1040 <mpfr_get_prec@plt>
mov    %rax,%rbx
mov    %r14d,%edi
call   1040 <mpfr_get_prec@plt>
add    %rax,%rbx
mov    0x2e6b(%rip),%rax
mov    (%rax),%rax
cmp    %rax,%rbx
cmovge %rax,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <m_init2@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
call   1050 <m_init2@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
call   1050 <m_init2@plt>
mov    0x2e52(%rip),%rbx
mov    (%rbx),%edx
mov    %ebp,%edi
mov    %r13d,%esi
call   1030 <mpfr_set@plt>
mov    (%rbx),%edx
mov    %r15d,%edi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <mpfr_set@plt>

LLVM IR (-O0):
@MPFR_PREC_MAX = global i64 0
@MPFR_RNDN = global i32 0
define void @handleExtendedRounding(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%14 = load i32, i32* %9
%15 = call i64 @mpfr_get_prec(i32 %14)
store i64 %15, i64* %11
%16 = load i32, i32* %10
%17 = call i64 @mpfr_get_prec(i32 %16)
store i64 %17, i64* %12
store i64 0, i64* %13
%18 = load i64, i64* %11
%19 = load i64, i64* %12
%20 = add nsw i64 %18, %19
%21 = load i64, i64* @MPFR_PREC_MAX
%22 = icmp slt i64 %20, %21
br i1 %22, label %23, label %27
23: ; preds = %5
%24 = load i64, i64* %11
%25 = load i64, i64* %12
%26 = add nsw i64 %24, %25
store i64 %26, i64* %13
br label %29
27: ; preds = %5
%28 = load i64, i64* @MPFR_PREC_MAX
store i64 %28, i64* %13
br label %29
29: ; preds = %27, %23
%30 = load i32, i32* %6
%31 = load i64, i64* %13
%32 = call i32 @m_init2(i32 %30, i64 %31)
%33 = load i32, i32* %7
%34 = load i64, i64* %13
%35 = call i32 @m_init2(i32 %33, i64 %34)
%36 = load i32, i32* %8
%37 = load i64, i64* %13
%38 = call i32 @m_init2(i32 %36, i64 %37)
%39 = load i32, i32* %6
%40 = load i32, i32* %9
%41 = load i32, i32* @MPFR_RNDN
%42 = call i32 @mpfr_set(i32 %39, i32 %40, i32 %41)
%43 = load i32, i32* %7
%44 = load i32, i32* %10
%45 = load i32, i32* @MPFR_RNDN
%46 = call i32 @mpfr_set(i32 %43, i32 %44, i32 %45)
ret void
}

LLVM IR (-O2):
@MPFR_PREC_MAX = global i64 0
@MPFR_RNDN = global i32 0
define void @handleExtendedRounding(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i64 @mpfr_get_prec(i32 %3)
%7 = tail call i64 @mpfr_get_prec(i32 %4)
%8 = add nsw i64 %7, %6
%9 = load i64, i64* @MPFR_PREC_MAX
%10 = icmp slt i64 %8, %9
%11 = select i1 %10, i64 %8, i64 %9
%12 = tail call i32 @m_init2(i32 %0, i64 %11)
%13 = tail call i32 @m_init2(i32 %1, i64 %11)
%14 = tail call i32 @m_init2(i32 %2, i64 %11)
%15 = load i32, i32* @MPFR_RNDN
%16 = tail call i32 @mpfr_set(i32 %0, i32 %3, i32 %15)
%17 = load i32, i32* @MPFR_RNDN
%18 = tail call i32 @mpfr_set(i32 %1, i32 %4, i32 %17)
ret void
}