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

/* Variables and functions */
int /*<<< orphan*/ MPFR_RNDN;
int /*<<< orphan*/ m_clear(int /*<<< orphan*/);
int /*<<< orphan*/ m_init2(int /*<<< orphan*/, int);
int /*<<< orphan*/ m_print(int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_set_d(int /*<<< orphan*/, double, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stochasticRounding(int /*<<< orphan*/ *, int);
void quickTestStochasticRounding() {
  mpfr_t number;
  mpfr_prec_t numberPrecision = 8;
  double value = 1.234375;
  mpfr_prec_t desiredPrecision = 5;
  m_init2(number, numberPrecision);
  mpfr_set_d(number, value, MPFR_RNDN);
  printf("\nAffichage du nombre avant opération :\n\t");
  m_print(number);
  stochasticRounding(&number, desiredPrecision);
  printf("\nAffichage du nombre APRES opération : \n\t");
  m_print(number);
  m_clear(number);
}


x86 assembly (clang, -O0):
<quickTestStochasticRounding>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x8,-0x8(%rbp)
movsd  0xe89(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x5,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1080 <m_init2@plt>
mov    -0x4(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
call   1040 <mpfr_set_d@plt>
lea    0xe5d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
call   1030 <m_print@plt>
mov    -0x14(%rbp),%esi
lea    -0x4(%rbp),%rdi
call   1060 <stochasticRounding@plt>
lea    0xe67(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
call   1030 <m_print@plt>
mov    -0x4(%rbp),%edi
call   1070 <m_clear@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quickTestStochasticRounding>:
push   %rax
mov    $0x8,%esi
call   1080 <m_init2@plt>
mov    0x2e76(%rip),%rax
mov    (%rax),%esi
movsd  0xe84(%rip),%xmm0
call   1040 <mpfr_set_d@plt>
lea    0xe80(%rip),%rdi
call   1050 <printf@plt>
call   1030 <m_print@plt>
lea    0x4(%rsp),%rdi
mov    $0x5,%esi
call   1060 <stochasticRounding@plt>
lea    0xe8a(%rip),%rdi
call   1050 <printf@plt>
mov    0x4(%rsp),%edi
call   1030 <m_print@plt>
mov    0x4(%rsp),%edi
call   1070 <m_clear@plt>
pop    %rax
ret

LLVM IR (-O0):
@MPFR_RNDN = global i32 0
@.str = [42 x i8] c"\0AAffichage du nombre avant op\C3\A9ration :\0A\09\00"
@.str.1 = [43 x i8] c"\0AAffichage du nombre APRES op\C3\A9ration : \0A\09\00"
define void @quickTestStochasticRounding() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca i32
store i32 8, i32* %2
store double 0x3FF3C00000000000, double* %3
store i32 5, i32* %4
%5 = load i32, i32* %1
%6 = load i32, i32* %2
%7 = call i32 @m_init2(i32 %5, i32 %6)
%8 = load i32, i32* %1
%9 = load double, double* %3
%10 = load i32, i32* @MPFR_RNDN
%11 = call i32 @mpfr_set_d(i32 %8, double %9, i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* %1
%14 = call i32 @m_print(i32 %13)
%15 = load i32, i32* %4
%16 = call i32 @stochasticRounding(i32* %1, i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* %1
%19 = call i32 @m_print(i32 %18)
%20 = load i32, i32* %1
%21 = call i32 @m_clear(i32 %20)
ret void
}

LLVM IR (-O2):
@MPFR_RNDN = global i32 0
@.str = [42 x i8] c"\0AAffichage du nombre avant op\C3\A9ration :\0A\09\00"
@.str.1 = [43 x i8] c"\0AAffichage du nombre APRES op\C3\A9ration : \0A\09\00"
define void @quickTestStochasticRounding() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @m_init2(i32 undef, i32 8)
%4 = load i32, i32* @MPFR_RNDN
%5 = tail call i32 @mpfr_set_d(i32 undef, double 0x3FF3C00000000000, i32 %4)
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @m_print(i32 undef)
%8 = call i32 @stochasticRounding(i32* %1, i32 5)
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = call i32 @m_print(i32 %10)
%12 = load i32, i32* %1
%13 = call i32 @m_clear(i32 %12)
ret void
}