#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_rnd_t;
typedef int mpfr_prec_t;

/* Variables and functions */
int /*<<< orphan*/ MPFR_RNDN;
int mpfr_can_round(int /*<<< orphan*/, int /*<<< orphan*/, int, int, int);
int /*<<< orphan*/ mpfr_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_const_pi(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpfr_free_cache();
int /*<<< orphan*/ mpfr_get_prec(int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_init2(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpfr_out_str(int /*<<< orphan*/, int, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/);
char *mpfr_print_rnd_mode(int);
int /*<<< orphan*/ mpfr_set(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int main(void) {
  mpfr_t x, y;
  mpfr_prec_t px = 53, py = 50;
  mpfr_rnd_t r1, r2;
  int ok;
  mpfr_init2(x, px);
  mpfr_init2(y, py);
  for (r1 = 0; r1 < 4; r1++) {
    mpfr_const_pi(x, r1);
    printf("r1=%s approx=", mpfr_print_rnd_mode(r1));
    mpfr_out_str(stdout, 2, 0, x, MPFR_RNDN);
    printf("\n");
    for (r2 = 0; r2 < 4; r2++) {
      ok = mpfr_can_round(x, mpfr_get_prec(x), r1, r2, py);
      printf("r2=%s ok=%d", mpfr_print_rnd_mode(r2), ok);
      if (ok) {
        mpfr_set(y, x, r2);
        printf("   ");
        mpfr_out_str(stdout, 2, 0, y, MPFR_RNDN);
      }
      printf("\n");
    }
  }
  mpfr_clear(x);
  mpfr_clear(y);
  mpfr_free_cache();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x35,-0x10(%rbp)
movl   $0x32,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   10b0 <mpfr_init2@plt>
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
call   10b0 <mpfr_init2@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    1301 <main+0x161>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <mpfr_const_pi@plt>
mov    -0x18(%rbp),%edi
call   1090 <mpfr_print_rnd_mode@plt>
mov    %rax,%rsi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%ecx
mov    0x2dcd(%rip),%rax
mov    (%rax),%r8d
mov    $0x2,%esi
xor    %edx,%edx
call   1070 <mpfr_out_str@plt>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    12ee <main+0x14e>
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
call   10a0 <mpfr_get_prec@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x14(%rbp),%r8d
call   10c0 <mpfr_can_round@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1090 <mpfr_print_rnd_mode@plt>
mov    %rax,%rsi
mov    -0x20(%rbp),%edx
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x20(%rbp)
je     12d2 <main+0x132>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1080 <mpfr_set@plt>
lea    0xd73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%ecx
mov    0x2d25(%rip),%rax
mov    (%rax),%r8d
mov    $0x2,%esi
xor    %edx,%edx
call   1070 <mpfr_out_str@plt>
lea    0xd35(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    123f <main+0x9f>
jmp    12f3 <main+0x153>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11da <main+0x3a>
mov    -0x8(%rbp),%edi
call   1060 <mpfr_clear@plt>
mov    -0xc(%rbp),%edi
call   1060 <mpfr_clear@plt>
mov    $0x0,%al
call   1030 <mpfr_free_cache@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x35,%esi
call   10c0 <mpfr_init2@plt>
mov    $0x32,%esi
call   10c0 <mpfr_init2@plt>
mov    0x2e02(%rip),%r13
mov    0x2e0b(%rip),%r14
lea    0xe2a(%rip),%r12
lea    0xe2f(%rip),%r15
xor    %ebp,%ebp
jmp    1206 <main+0x56>
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    $0x4,%ebp
je     13dc <main+0x22c>
mov    %ebp,%esi
call   1050 <mpfr_const_pi@plt>
mov    %ebp,%edi
call   10a0 <mpfr_print_rnd_mode@plt>
lea    0xde5(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x0(%r13),%edi
mov    (%r14),%r8d
mov    $0x2,%esi
xor    %edx,%edx
call   1080 <mpfr_out_str@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
call   10b0 <mpfr_get_prec@plt>
mov    %eax,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
mov    $0x32,%r8d
call   10d0 <mpfr_can_round@plt>
mov    %eax,%ebx
xor    %edi,%edi
call   10a0 <mpfr_print_rnd_mode@plt>
mov    %r12,%rdi
mov    %rax,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebx,%ebx
je     1298 <main+0xe8>
xor    %edx,%edx
call   1090 <mpfr_set@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x0(%r13),%edi
mov    (%r14),%r8d
mov    $0x2,%esi
xor    %edx,%edx
call   1080 <mpfr_out_str@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
call   10b0 <mpfr_get_prec@plt>
mov    %eax,%esi
mov    %ebp,%edx
mov    $0x1,%ecx
mov    $0x32,%r8d
call   10d0 <mpfr_can_round@plt>
mov    %eax,%ebx
mov    $0x1,%edi
call   10a0 <mpfr_print_rnd_mode@plt>
mov    %r12,%rdi
mov    %rax,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebx,%ebx
je     1301 <main+0x151>
mov    $0x1,%edx
call   1090 <mpfr_set@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x0(%r13),%edi
mov    (%r14),%r8d
mov    $0x2,%esi
xor    %edx,%edx
call   1080 <mpfr_out_str@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
call   10b0 <mpfr_get_prec@plt>
mov    %eax,%esi
mov    %ebp,%edx
mov    $0x2,%ecx
mov    $0x32,%r8d
call   10d0 <mpfr_can_round@plt>
mov    %eax,%ebx
mov    $0x2,%edi
call   10a0 <mpfr_print_rnd_mode@plt>
mov    %r12,%rdi
mov    %rax,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebx,%ebx
je     136a <main+0x1ba>
mov    $0x2,%edx
call   1090 <mpfr_set@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x0(%r13),%edi
mov    (%r14),%r8d
mov    $0x2,%esi
xor    %edx,%edx
call   1080 <mpfr_out_str@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
call   10b0 <mpfr_get_prec@plt>
mov    %eax,%esi
mov    %ebp,%edx
mov    $0x3,%ecx
mov    $0x32,%r8d
call   10d0 <mpfr_can_round@plt>
mov    %eax,%ebx
mov    $0x3,%edi
call   10a0 <mpfr_print_rnd_mode@plt>
mov    %r12,%rdi
mov    %rax,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebx,%ebx
je     11f0 <main+0x40>
mov    $0x3,%edx
call   1090 <mpfr_set@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x0(%r13),%edi
mov    (%r14),%r8d
mov    $0x2,%esi
xor    %edx,%edx
call   1080 <mpfr_out_str@plt>
jmp    11f0 <main+0x40>
call   1070 <mpfr_clear@plt>
call   1070 <mpfr_clear@plt>
xor    %eax,%eax
call   1040 <mpfr_free_cache@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"r1=%s approx=\00"
@stdout = global i32 0
@MPFR_RNDN = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [12 x i8] c"r2=%s ok=%d\00"
@.str.3 = [4 x i8] c" \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 53, i32* %4
store i32 50, i32* %5
%9 = load i32, i32* %2
%10 = load i32, i32* %4
%11 = call i32 @mpfr_init2(i32 %9, i32 %10)
%12 = load i32, i32* %3
%13 = load i32, i32* %5
%14 = call i32 @mpfr_init2(i32 %12, i32 %13)
store i32 0, i32* %6
br label %15
15: ; preds = %63, %0
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %66
18: ; preds = %15
%19 = load i32, i32* %2
%20 = load i32, i32* %6
%21 = call i32 @mpfr_const_pi(i32 %19, i32 %20)
%22 = load i32, i32* %6
%23 = call i8* @mpfr_print_rnd_mode(i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = load i32, i32* @stdout
%26 = load i32, i32* %2
%27 = load i32, i32* @MPFR_RNDN
%28 = call i32 @mpfr_out_str(i32 %25, i32 2, i32 0, i32 %26, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %30
30: ; preds = %59, %18
%31 = load i32, i32* %7
%32 = icmp slt i32 %31, 4
br i1 %32, label %33, label %62
33: ; preds = %30
%34 = load i32, i32* %2
%35 = load i32, i32* %2
%36 = call i32 @mpfr_get_prec(i32 %35)
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = load i32, i32* %5
%40 = call i32 @mpfr_can_round(i32 %34, i32 %36, i32 %37, i32 %38, i32 %39)
store i32 %40, i32* %8
%41 = load i32, i32* %7
%42 = call i8* @mpfr_print_rnd_mode(i32 %41)
%43 = load i32, i32* %8
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %42, i32 %43)
%45 = load i32, i32* %8
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %57
47: ; preds = %33
%48 = load i32, i32* %3
%49 = load i32, i32* %2
%50 = load i32, i32* %7
%51 = call i32 @mpfr_set(i32 %48, i32 %49, i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%53 = load i32, i32* @stdout
%54 = load i32, i32* %3
%55 = load i32, i32* @MPFR_RNDN
%56 = call i32 @mpfr_out_str(i32 %53, i32 2, i32 0, i32 %54, i32 %55)
br label %57
57: ; preds = %47, %33
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %59
59: ; preds = %57
%60 = load i32, i32* %7
%61 = add nsw i32 %60, 1
store i32 %61, i32* %7
br label %30
62: ; preds = %30
br label %63
63: ; preds = %62
%64 = load i32, i32* %6
%65 = add nsw i32 %64, 1
store i32 %65, i32* %6
br label %15
66: ; preds = %15
%67 = load i32, i32* %2
%68 = call i32 @mpfr_clear(i32 %67)
%69 = load i32, i32* %3
%70 = call i32 @mpfr_clear(i32 %69)
%71 = call i32 (...) @mpfr_free_cache()
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"r1=%s approx=\00"
@stdout = global i32 0
@MPFR_RNDN = global i32 0
@.str.2 = [12 x i8] c"r2=%s ok=%d\00"
@.str.3 = [4 x i8] c" \00"
define i32 @main() {
%1 = tail call i32 @mpfr_init2(i32 undef, i32 53)
%2 = tail call i32 @mpfr_init2(i32 undef, i32 50)
br label %3
3: ; preds = %0, %62
%4 = phi i32 [ 0, %0 ], [ %64, %62 ]
%5 = tail call i32 @mpfr_const_pi(i32 undef, i32 %4)
%6 = tail call i8* @mpfr_print_rnd_mode(i32 %4)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @stdout
%9 = load i32, i32* @MPFR_RNDN
%10 = tail call i32 @mpfr_out_str(i32 %8, i32 2, i32 0, i32 undef, i32 %9)
%11 = tail call i32 @putchar(i32 10)
%12 = tail call i32 @mpfr_get_prec(i32 undef)
%13 = tail call i32 @mpfr_can_round(i32 undef, i32 %12, i32 %4, i32 0, i32 50)
%14 = tail call i8* @mpfr_print_rnd_mode(i32 0)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32 %13)
%16 = icmp eq i32 %13, 0
br i1 %16, label %23, label %17
17: ; preds = %3
%18 = tail call i32 @mpfr_set(i32 undef, i32 undef, i32 0)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* @stdout
%21 = load i32, i32* @MPFR_RNDN
%22 = tail call i32 @mpfr_out_str(i32 %20, i32 2, i32 0, i32 undef, i32 %21)
br label %23
23: ; preds = %17, %3
%24 = tail call i32 @putchar(i32 10)
%25 = tail call i32 @mpfr_get_prec(i32 undef)
%26 = tail call i32 @mpfr_can_round(i32 undef, i32 %25, i32 %4, i32 1, i32 50)
%27 = tail call i8* @mpfr_print_rnd_mode(i32 1)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %27, i32 %26)
%29 = icmp eq i32 %26, 0
br i1 %29, label %36, label %30
30: ; preds = %23
%31 = tail call i32 @mpfr_set(i32 undef, i32 undef, i32 1)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* @stdout
%34 = load i32, i32* @MPFR_RNDN
%35 = tail call i32 @mpfr_out_str(i32 %33, i32 2, i32 0, i32 undef, i32 %34)
br label %36
36: ; preds = %30, %23
%37 = tail call i32 @putchar(i32 10)
%38 = tail call i32 @mpfr_get_prec(i32 undef)
%39 = tail call i32 @mpfr_can_round(i32 undef, i32 %38, i32 %4, i32 2, i32 50)
%40 = tail call i8* @mpfr_print_rnd_mode(i32 2)
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %40, i32 %39)
%42 = icmp eq i32 %39, 0
br i1 %42, label %49, label %43
43: ; preds = %36
%44 = tail call i32 @mpfr_set(i32 undef, i32 undef, i32 2)
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%46 = load i32, i32* @stdout
%47 = load i32, i32* @MPFR_RNDN
%48 = tail call i32 @mpfr_out_str(i32 %46, i32 2, i32 0, i32 undef, i32 %47)
br label %49
49: ; preds = %43, %36
%50 = tail call i32 @putchar(i32 10)
%51 = tail call i32 @mpfr_get_prec(i32 undef)
%52 = tail call i32 @mpfr_can_round(i32 undef, i32 %51, i32 %4, i32 3, i32 50)
%53 = tail call i8* @mpfr_print_rnd_mode(i32 3)
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %53, i32 %52)
%55 = icmp eq i32 %52, 0
br i1 %55, label %62, label %56
56: ; preds = %49
%57 = tail call i32 @mpfr_set(i32 undef, i32 undef, i32 3)
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%59 = load i32, i32* @stdout
%60 = load i32, i32* @MPFR_RNDN
%61 = tail call i32 @mpfr_out_str(i32 %59, i32 2, i32 0, i32 undef, i32 %60)
br label %62
62: ; preds = %56, %49
%63 = tail call i32 @putchar(i32 10)
%64 = add nuw nsw i32 %4, 1
%65 = icmp eq i32 %64, 4
br i1 %65, label %66, label %3
66: ; preds = %62
%67 = tail call i32 @mpfr_clear(i32 undef)
%68 = tail call i32 @mpfr_clear(i32 undef)
%69 = tail call i32 (...) @mpfr_free_cache()
ret i32 0
}