#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 /*<<< orphan*/ mpfr_exp_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ MPFR_RNDN;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ mpfr_clear(int /*<<< orphan*/);
scalar_t__ mpfr_fits_sint_p(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_fpif_export(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_fpif_import(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ mpfr_free_str(char *);
int /*<<< orphan*/ mpfr_frexp(int /*<<< orphan*/ *, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/);
double mpfr_get_d(int /*<<< orphan*/, int /*<<< orphan*/);
double mpfr_get_d_2exp(int /*<<< orphan*/ *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int mpfr_get_si(int /*<<< orphan*/, int /*<<< orphan*/);
char *mpfr_get_str(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int,
                   int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_get_str_ndigits(int, int);
int /*<<< orphan*/ mpfr_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_set_d(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  mpfr_t x, y, z;
  double d;
  int i;
  mpfr_exp_t e;
  if (argc != 2)
    exit(1);
  mpfr_init(x);
  mpfr_set_d(x, 1. / 3., MPFR_RNDN);
  d = mpfr_get_d(x, MPFR_RNDN);
  printf("%e\n", d);
  i = mpfr_get_si(x, MPFR_RNDN);
  printf("%d\n", i);
  d = mpfr_get_d_2exp(&e, x, MPFR_RNDN);
  printf("%e %ld\n", d, e);
  mpfr_init(y);
  mpfr_frexp(&e, y, x, MPFR_RNDN);
  printf("%ld\n", e);
  printf("%zu\n", mpfr_get_str_ndigits(10, 100));
  char *buffer;
  buffer = mpfr_get_str(NULL, &e, 10, 0, x, MPFR_RNDN);
  printf("%s %ld\n", buffer, e);
  mpfr_printf("%.Re\n", x);
  FILE *stream;
  stream = fopen("fpif_export.expected", "w");
  mpfr_fpif_export(stream, x);
  fclose(stream);
  mpfr_init(z);
  stream = fopen(argv[1], "r");
  mpfr_fpif_import(z, stream);
  mpfr_printf("%.Re\n", z);
  fclose(stream);
  if (mpfr_fits_sint_p(x, MPFR_RNDN))
    printf("true\n");
  else
    printf("false\n");
  mpfr_free_str(buffer);
  mpfr_clear(x);
  mpfr_clear(y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     124a <main+0x2a>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x14(%rbp),%edi
call   1030 <mpfr_init@plt>
mov    -0x14(%rbp),%edi
mov    0x2d8c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <mpfr_set_d@plt>
mov    -0x14(%rbp),%edi
mov    0x2d79(%rip),%rax
mov    (%rax),%esi
call   1060 <mpfr_get_d@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xd79(%rip),%rdi
mov    $0x1,%al
call   1090 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2d50(%rip),%rax
mov    (%rax),%esi
call   10d0 <mpfr_get_si@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x14(%rbp),%esi
mov    0x2d2b(%rip),%rax
mov    (%rax),%edx
lea    -0x30(%rbp),%rdi
call   1130 <mpfr_get_d_2exp@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%esi
lea    0xd2c(%rip),%rdi
mov    $0x1,%al
call   1090 <printf@plt>
mov    -0x18(%rbp),%edi
call   1030 <mpfr_init@plt>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    0x2cf0(%rip),%rax
mov    (%rax),%ecx
lea    -0x30(%rbp),%rdi
call   10f0 <mpfr_frexp@plt>
mov    -0x30(%rbp),%esi
lea    0xcfe(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0xa,%edi
mov    $0x64,%esi
call   10a0 <mpfr_get_str_ndigits@plt>
mov    %eax,%esi
lea    0xce4(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x14(%rbp),%r8d
mov    0x2caa(%rip),%rax
mov    (%rax),%r9d
xor    %eax,%eax
mov    %eax,%edi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
xor    %ecx,%ecx
call   10e0 <mpfr_get_str@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%edx
lea    0xcae(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xca5(%rip),%rdi
call   10c0 <mpfr_printf@plt>
lea    0xc9f(%rip),%rdi
lea    0xcad(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <mpfr_fpif_export@plt>
mov    -0x40(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x1c(%rbp),%edi
call   1030 <mpfr_init@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc7a(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x40(%rbp),%rsi
call   1140 <mpfr_fpif_import@plt>
mov    -0x1c(%rbp),%esi
lea    0xc3e(%rip),%rdi
call   10c0 <mpfr_printf@plt>
mov    -0x40(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x14(%rbp),%edi
mov    0x2bf1(%rip),%rax
mov    (%rax),%esi
call   1050 <mpfr_fits_sint_p@plt>
cmp    $0x0,%rax
je     141b <main+0x1fb>
lea    0xc2d(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    1429 <main+0x209>
lea    0xc20(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1100 <mpfr_free_str@plt>
mov    -0x14(%rbp),%edi
call   10b0 <mpfr_clear@plt>
mov    -0x18(%rbp),%edi
call   10b0 <mpfr_clear@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    13cc <main+0x19c>
mov    %rsi,%r14
call   1030 <mpfr_init@plt>
mov    0x2d93(%rip),%r13
mov    0x0(%r13),%edx
xor    %esi,%esi
call   1080 <mpfr_set_d@plt>
mov    0x0(%r13),%esi
call   1070 <mpfr_get_d@plt>
lea    0xd90(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
mov    0x0(%r13),%esi
call   10e0 <mpfr_get_si@plt>
lea    0xd7d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x0(%r13),%edx
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1140 <mpfr_get_d_2exp@plt>
mov    0xc(%rsp),%esi
lea    0xd5c(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
call   1030 <mpfr_init@plt>
mov    0x0(%r13),%ecx
mov    %rbx,%rdi
call   1100 <mpfr_frexp@plt>
mov    0xc(%rsp),%esi
lea    0xd3c(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0xa,%edi
mov    $0x64,%esi
call   10b0 <mpfr_get_str_ndigits@plt>
lea    0xd24(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x0(%r13),%r9d
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0xa,%edx
xor    %ecx,%ecx
call   10f0 <mpfr_get_str@plt>
mov    %rax,%r12
mov    0xc(%rsp),%edx
lea    0xcfd(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
lea    0xcf4(%rip),%r15
mov    %r15,%rdi
call   10d0 <mpfr_printf@plt>
lea    0xceb(%rip),%rdi
lea    0xcf9(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <mpfr_fpif_export@plt>
mov    %rbx,%rdi
call   1090 <fclose@plt>
call   1030 <mpfr_init@plt>
mov    0x8(%r14),%rdi
lea    0xcd3(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rsi
call   1150 <mpfr_fpif_import@plt>
mov    %r15,%rdi
call   10d0 <mpfr_printf@plt>
mov    %rbx,%rdi
call   1090 <fclose@plt>
mov    0x0(%r13),%esi
call   1060 <mpfr_fits_sint_p@plt>
test   %rax,%rax
lea    0xca2(%rip),%rax
lea    0xca1(%rip),%rdi
cmove  %rax,%rdi
call   1050 <puts@plt>
mov    %r12,%rdi
call   1110 <mpfr_free_str@plt>
call   10c0 <mpfr_clear@plt>
call   10c0 <mpfr_clear@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
call   1130 <exit@plt>

LLVM IR (-O0):
@MPFR_RNDN = global i32 0
@.str = [4 x i8] c"%e\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [8 x i8] c"%e %ld\0A\00"
@.str.3 = [5 x i8] c"%ld\0A\00"
@.str.4 = [5 x i8] c"%zu\0A\00"
@.str.5 = [8 x i8] c"%s %ld\0A\00"
@.str.6 = [6 x i8] c"%.Re\0A\00"
@.str.7 = [21 x i8] c"fpif_export.expected\00"
@.str.8 = [2 x i8] c"w\00"
@.str.9 = [2 x i8] c"r\00"
@.str.10 = [6 x i8] c"true\0A\00"
@.str.11 = [7 x i8] c"false\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 2
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i32, i32* %6
%20 = call i32 @mpfr_init(i32 %19)
%21 = load i32, i32* %6
%22 = load i32, i32* @MPFR_RNDN
%23 = call i32 @mpfr_set_d(i32 %21, i32 0, i32 %22)
%24 = load i32, i32* %6
%25 = load i32, i32* @MPFR_RNDN
%26 = call double @mpfr_get_d(i32 %24, i32 %25)
store double %26, double* %9
%27 = load double, double* %9
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %27)
%29 = load i32, i32* %6
%30 = load i32, i32* @MPFR_RNDN
%31 = call i32 @mpfr_get_si(i32 %29, i32 %30)
store i32 %31, i32* %10
%32 = load i32, i32* %10
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %6
%35 = load i32, i32* @MPFR_RNDN
%36 = call double @mpfr_get_d_2exp(i32* %11, i32 %34, i32 %35)
store double %36, double* %9
%37 = load double, double* %9
%38 = load i32, i32* %11
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %37, i32 %38)
%40 = load i32, i32* %7
%41 = call i32 @mpfr_init(i32 %40)
%42 = load i32, i32* %7
%43 = load i32, i32* %6
%44 = load i32, i32* @MPFR_RNDN
%45 = call i32 @mpfr_frexp(i32* %11, i32 %42, i32 %43, i32 %44)
%46 = load i32, i32* %11
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%48 = call i32 @mpfr_get_str_ndigits(i32 10, i32 100)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %6
%51 = load i32, i32* @MPFR_RNDN
%52 = call i8* @mpfr_get_str(i32* null, i32* %11, i32 10, i32 0, i32 %50, i32 %51)
store i8* %52, i8** %12
%53 = load i8*, i8** %12
%54 = load i32, i32* %11
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %53, i32 %54)
%56 = load i32, i32* %6
%57 = call i32 @mpfr_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %56)
%58 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %58, i32** %13
%59 = load i32*, i32** %13
%60 = load i32, i32* %6
%61 = call i32 @mpfr_fpif_export(i32* %59, i32 %60)
%62 = load i32*, i32** %13
%63 = call i32 @fclose(i32* %62)
%64 = load i32, i32* %8
%65 = call i32 @mpfr_init(i32 %64)
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 1
%68 = load i8*, i8** %67
%69 = call i32* @fopen(i8* %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %69, i32** %13
%70 = load i32, i32* %8
%71 = load i32*, i32** %13
%72 = call i32 @mpfr_fpif_import(i32 %70, i32* %71)
%73 = load i32, i32* %8
%74 = call i32 @mpfr_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %73)
%75 = load i32*, i32** %13
%76 = call i32 @fclose(i32* %75)
%77 = load i32, i32* %6
%78 = load i32, i32* @MPFR_RNDN
%79 = call i64 @mpfr_fits_sint_p(i32 %77, i32 %78)
%80 = icmp ne i64 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %18
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
br label %85
83: ; preds = %18
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
br label %85
85: ; preds = %83, %81
%86 = load i8*, i8** %12
%87 = call i32 @mpfr_free_str(i8* %86)
%88 = load i32, i32* %6
%89 = call i32 @mpfr_clear(i32 %88)
%90 = load i32, i32* %7
%91 = call i32 @mpfr_clear(i32 %90)
ret i32 0
}

LLVM IR (-O2):
@MPFR_RNDN = global i32 0
@.str = [4 x i8] c"%e\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [8 x i8] c"%e %ld\0A\00"
@.str.3 = [5 x i8] c"%ld\0A\00"
@.str.4 = [5 x i8] c"%zu\0A\00"
@.str.5 = [8 x i8] c"%s %ld\0A\00"
@.str.6 = [6 x i8] c"%.Re\0A\00"
@.str.7 = [21 x i8] c"fpif_export.expected\00"
@.str.8 = [2 x i8] c"w\00"
@.str.9 = [2 x i8] c"r\00"
@str = [6 x i8] c"false\00"
@str.12 = [5 x i8] c"true\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = tail call i32 @mpfr_init(i32 undef)
%10 = load i32, i32* @MPFR_RNDN
%11 = tail call i32 @mpfr_set_d(i32 undef, i32 0, i32 %10)
%12 = load i32, i32* @MPFR_RNDN
%13 = tail call double @mpfr_get_d(i32 undef, i32 %12)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %13)
%15 = load i32, i32* @MPFR_RNDN
%16 = tail call i32 @mpfr_get_si(i32 undef, i32 %15)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @MPFR_RNDN
%19 = call double @mpfr_get_d_2exp(i32* %3, i32 undef, i32 %18)
%20 = load i32, i32* %3
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %19, i32 %20)
%22 = call i32 @mpfr_init(i32 undef)
%23 = load i32, i32* @MPFR_RNDN
%24 = call i32 @mpfr_frexp(i32* %3, i32 undef, i32 undef, i32 %23)
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = call i32 @mpfr_get_str_ndigits(i32 10, i32 100)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @MPFR_RNDN
%30 = call i8* @mpfr_get_str(i32* null, i32* %3, i32 10, i32 0, i32 undef, i32 %29)
%31 = load i32, i32* %3
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %30, i32 %31)
%33 = call i32 @mpfr_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 undef)
%34 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%35 = call i32 @mpfr_fpif_export(i32* %34, i32 undef)
%36 = call i32 @fclose(i32* %34)
%37 = call i32 @mpfr_init(i32 undef)
%38 = getelementptr inbounds i8*, i8** %1, i64 1
%39 = load i8*, i8** %38
%40 = call i32* @fopen(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%41 = call i32 @mpfr_fpif_import(i32 undef, i32* %40)
%42 = call i32 @mpfr_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 undef)
%43 = call i32 @fclose(i32* %40)
%44 = load i32, i32* @MPFR_RNDN
%45 = call i64 @mpfr_fits_sint_p(i32 undef, i32 %44)
%46 = icmp eq i64 %45, 0
%47 = select i1 %46, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.12, i64 0, i64 0)
%48 = call i32 @puts(i8* dereferenceable(1) %47)
%49 = call i32 @mpfr_free_str(i8* %30)
%50 = call i32 @mpfr_clear(i32 undef)
%51 = call i32 @mpfr_clear(i32 undef)
ret i32 0
}