#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ MPFR_RNDD;
int /*<<< orphan*/ MPFR_RNDN;
int /*<<< orphan*/ MPFR_RNDU;
int /*<<< orphan*/ MPFR_RNDZ;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ mpfr_clear(int /*<<< orphan*/);
scalar_t__ mpfr_cmpabs(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ mpfr_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_init2(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpfr_set_default_prec(int);
int /*<<< orphan*/ mpfr_set_emax(int);
int /*<<< orphan*/ mpfr_set_emin(int);
int /*<<< orphan*/ mpfr_set_str(int /*<<< orphan*/, char *, int /*<<< orphan*/,
                                int /*<<< orphan*/);
int /*<<< orphan*/ print_fp(int /*<<< orphan*/ *, int /*<<< orphan*/, char *);
int string_to_fp(int /*<<< orphan*/, char const *, int /*<<< orphan*/);
void round_str(FILE *fout, const char *s, int prec, int emin, int emax,
               bool ibm_ld) {
  mpfr_t f;
  mpfr_set_default_prec(prec);
  mpfr_set_emin(emin);
  mpfr_set_emax(emax);
  mpfr_init(f);
  int r = string_to_fp(f, s, MPFR_RNDD);
  if (ibm_ld) {
    assert(prec == 106 && emin == -1073 && emax == 1024);
    mpfr_t max_value;
    mpfr_init2(max_value, 107);
    mpfr_set_str(max_value, "0x1.fffffffffffff7ffffffffffffcp+1023", 0,
                 MPFR_RNDN);
    if (mpfr_cmpabs(f, max_value) > 0)
      r = 1;
    mpfr_clear(max_value);
  }
  mpfr_fprintf(fout, "\t%s,\n", r ? "false" : "true");
  print_fp(fout, f, ",\n");
  string_to_fp(f, s, MPFR_RNDN);
  print_fp(fout, f, ",\n");
  string_to_fp(f, s, MPFR_RNDZ);
  print_fp(fout, f, ",\n");
  string_to_fp(f, s, MPFR_RNDU);
  print_fp(fout, f, "");
  mpfr_clear(f);
}


x86 assembly (clang, -O0):
<round_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   10c0 <mpfr_set_default_prec@plt>
mov    -0x18(%rbp),%edi
call   1070 <mpfr_set_emin@plt>
mov    -0x1c(%rbp),%edi
call   10a0 <mpfr_set_emax@plt>
mov    -0x24(%rbp),%edi
call   1040 <mpfr_init@plt>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2dcc(%rip),%rax
mov    (%rax),%edx
call   1030 <string_to_fp@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     12a6 <round_str+0xe6>
xor    %eax,%eax
cmpl   $0x6a,-0x14(%rbp)
mov    %al,-0x2d(%rbp)
jne    124e <round_str+0x8e>
xor    %eax,%eax
cmpl   $0xfffffbcf,-0x18(%rbp)
mov    %al,-0x2d(%rbp)
jne    124e <round_str+0x8e>
cmpl   $0x400,-0x1c(%rbp)
sete   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x2c(%rbp),%edi
mov    $0x6b,%esi
call   10e0 <mpfr_init2@plt>
mov    -0x2c(%rbp),%edi
mov    0x2d76(%rip),%rax
mov    (%rax),%ecx
lea    0xd85(%rip),%rsi
xor    %edx,%edx
call   10b0 <mpfr_set_str@plt>
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   10d0 <mpfr_cmpabs@plt>
cmp    $0x0,%rax
jle    129e <round_str+0xde>
movl   $0x1,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
call   1080 <mpfr_clear@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%ecx
lea    0xd7e(%rip),%rdx
lea    0xd71(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xd5d(%rip),%rsi
call   1050 <mpfr_fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    0xd4d(%rip),%rdx
call   1060 <print_fp@plt>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2cf9(%rip),%rax
mov    (%rax),%edx
call   1030 <string_to_fp@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    0xd25(%rip),%rdx
call   1060 <print_fp@plt>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2cc9(%rip),%rax
mov    (%rax),%edx
call   1030 <string_to_fp@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    0xcfd(%rip),%rdx
call   1060 <print_fp@plt>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2c89(%rip),%rax
mov    (%rax),%edx
call   1030 <string_to_fp@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    0xcd7(%rip),%rdx
call   1060 <print_fp@plt>
mov    -0x24(%rbp),%edi
call   1080 <mpfr_clear@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<round_str>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%ebx
mov    %ecx,%ebp
mov    %edx,%r13d
mov    %rsi,%r12
mov    %rdi,%r15
mov    %edx,%edi
call   10c0 <mpfr_set_default_prec@plt>
mov    %ebp,%edi
call   1070 <mpfr_set_emin@plt>
mov    %ebx,%edi
call   10a0 <mpfr_set_emax@plt>
call   1040 <mpfr_init@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
mov    %r12,(%rsp)
mov    %r12,%rsi
call   1030 <string_to_fp@plt>
mov    %eax,%r12d
test   %r14d,%r14d
je     126a <round_str+0xaa>
xor    $0x6a,%r13d
xor    $0xfffffbcf,%ebp
or     %r13d,%ebp
xor    $0x400,%ebx
xor    %edi,%edi
or     %ebp,%ebx
sete   %dil
call   1090 <assert@plt>
mov    $0x6b,%esi
call   10e0 <mpfr_init2@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%ecx
lea    0xdb3(%rip),%rsi
xor    %edx,%edx
call   10b0 <mpfr_set_str@plt>
call   10d0 <mpfr_cmpabs@plt>
test   %rax,%rax
mov    $0x1,%eax
cmovg  %eax,%r12d
call   1080 <mpfr_clear@plt>
test   %r12d,%r12d
lea    0xdbe(%rip),%rax
lea    0xdb1(%rip),%rdx
cmove  %rax,%rdx
lea    0xda0(%rip),%rsi
mov    %r15,%rdi
call   1050 <mpfr_fprintf@plt>
lea    0xd94(%rip),%rbx
mov    %r15,%rdi
mov    %rbx,%rdx
call   1060 <print_fp@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%edx
mov    (%rsp),%rbp
mov    %rbp,%rsi
call   1030 <string_to_fp@plt>
mov    %r15,%rdi
mov    %rbx,%rdx
call   1060 <print_fp@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rsi
call   1030 <string_to_fp@plt>
mov    %r15,%rdi
mov    %rbx,%rdx
call   1060 <print_fp@plt>
mov    0x2ce5(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rsi
call   1030 <string_to_fp@plt>
lea    0xd37(%rip),%rdx
mov    %r15,%rdi
call   1060 <print_fp@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <mpfr_clear@plt>

LLVM IR (-O0):
@MPFR_RNDD = global i32 0
@.str = [38 x i8] c"0x1.fffffffffffff7ffffffffffffcp+1023\00"
@MPFR_RNDN = global i32 0
@.str.1 = [6 x i8] c"\09%s,\0A\00"
@.str.2 = [6 x i8] c"false\00"
@.str.3 = [5 x i8] c"true\00"
@.str.4 = [3 x i8] c",\0A\00"
@MPFR_RNDZ = global i32 0
@MPFR_RNDU = global i32 0
@.str.5 = [1 x i8] zeroinitializer
define void @round_str(i32* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32* %0, i32** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%16 = load i32, i32* %9
%17 = call i32 @mpfr_set_default_prec(i32 %16)
%18 = load i32, i32* %10
%19 = call i32 @mpfr_set_emin(i32 %18)
%20 = load i32, i32* %11
%21 = call i32 @mpfr_set_emax(i32 %20)
%22 = load i32, i32* %13
%23 = call i32 @mpfr_init(i32 %22)
%24 = load i32, i32* %13
%25 = load i8*, i8** %8
%26 = load i32, i32* @MPFR_RNDD
%27 = call i32 @string_to_fp(i32 %24, i8* %25, i32 %26)
store i32 %27, i32* %14
%28 = load i32, i32* %12
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %56
30: ; preds = %6
%31 = load i32, i32* %9
%32 = icmp eq i32 %31, 106
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %10
%35 = icmp eq i32 %34, -1073
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* %11
%38 = icmp eq i32 %37, 1024
br label %39
39: ; preds = %36, %33, %30
%40 = phi i1 [ false, %33 ], [ false, %30 ], [ %38, %36 ]
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = load i32, i32* %15
%44 = call i32 @mpfr_init2(i32 %43, i32 107)
%45 = load i32, i32* %15
%46 = load i32, i32* @MPFR_RNDN
%47 = call i32 @mpfr_set_str(i32 %45, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 0, i32 %46)
%48 = load i32, i32* %13
%49 = load i32, i32* %15
%50 = call i64 @mpfr_cmpabs(i32 %48, i32 %49)
%51 = icmp sgt i64 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %39
store i32 1, i32* %14
br label %53
53: ; preds = %52, %39
%54 = load i32, i32* %15
%55 = call i32 @mpfr_clear(i32 %54)
br label %56
56: ; preds = %53, %6
%57 = load i32*, i32** %7
%58 = load i32, i32* %14
%59 = icmp ne i32 %58, 0
%60 = zext i1 %59 to i64
%61 = select i1 %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%62 = call i32 @mpfr_fprintf(i32* %57, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %61)
%63 = load i32*, i32** %7
%64 = load i32, i32* %13
%65 = call i32 @print_fp(i32* %63, i32 %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%66 = load i32, i32* %13
%67 = load i8*, i8** %8
%68 = load i32, i32* @MPFR_RNDN
%69 = call i32 @string_to_fp(i32 %66, i8* %67, i32 %68)
%70 = load i32*, i32** %7
%71 = load i32, i32* %13
%72 = call i32 @print_fp(i32* %70, i32 %71, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%73 = load i32, i32* %13
%74 = load i8*, i8** %8
%75 = load i32, i32* @MPFR_RNDZ
%76 = call i32 @string_to_fp(i32 %73, i8* %74, i32 %75)
%77 = load i32*, i32** %7
%78 = load i32, i32* %13
%79 = call i32 @print_fp(i32* %77, i32 %78, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%80 = load i32, i32* %13
%81 = load i8*, i8** %8
%82 = load i32, i32* @MPFR_RNDU
%83 = call i32 @string_to_fp(i32 %80, i8* %81, i32 %82)
%84 = load i32*, i32** %7
%85 = load i32, i32* %13
%86 = call i32 @print_fp(i32* %84, i32 %85, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%87 = load i32, i32* %13
%88 = call i32 @mpfr_clear(i32 %87)
ret void
}

LLVM IR (-O2):
@MPFR_RNDD = global i32 0
@.str = [38 x i8] c"0x1.fffffffffffff7ffffffffffffcp+1023\00"
@MPFR_RNDN = global i32 0
@.str.1 = [6 x i8] c"\09%s,\0A\00"
@.str.2 = [6 x i8] c"false\00"
@.str.3 = [5 x i8] c"true\00"
@.str.4 = [3 x i8] c",\0A\00"
@MPFR_RNDZ = global i32 0
@MPFR_RNDU = global i32 0
@.str.5 = [1 x i8] zeroinitializer
define void @round_str(i32* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = tail call i32 @mpfr_set_default_prec(i32 %2)
%8 = tail call i32 @mpfr_set_emin(i32 %3)
%9 = tail call i32 @mpfr_set_emax(i32 %4)
%10 = tail call i32 @mpfr_init(i32 undef)
%11 = load i32, i32* @MPFR_RNDD
%12 = tail call i32 @string_to_fp(i32 undef, i8* %1, i32 %11)
%13 = icmp eq i32 %5, 0
br i1 %13, label %29, label %14
14: ; preds = %6
%15 = icmp eq i32 %2, 106
%16 = icmp eq i32 %3, -1073
%17 = and i1 %15, %16
%18 = icmp eq i32 %4, 1024
%19 = and i1 %17, %18
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i32 @mpfr_init2(i32 undef, i32 107)
%23 = load i32, i32* @MPFR_RNDN
%24 = tail call i32 @mpfr_set_str(i32 undef, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 0, i32 %23)
%25 = tail call i64 @mpfr_cmpabs(i32 undef, i32 undef)
%26 = icmp sgt i64 %25, 0
%27 = select i1 %26, i32 1, i32 %12
%28 = tail call i32 @mpfr_clear(i32 undef)
br label %29
29: ; preds = %14, %6
%30 = phi i32 [ %27, %14 ], [ %12, %6 ]
%31 = icmp eq i32 %30, 0
%32 = select i1 %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%33 = tail call i32 @mpfr_fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = tail call i32 @print_fp(i32* %0, i32 undef, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%35 = load i32, i32* @MPFR_RNDN
%36 = tail call i32 @string_to_fp(i32 undef, i8* %1, i32 %35)
%37 = tail call i32 @print_fp(i32* %0, i32 undef, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%38 = load i32, i32* @MPFR_RNDZ
%39 = tail call i32 @string_to_fp(i32 undef, i8* %1, i32 %38)
%40 = tail call i32 @print_fp(i32* %0, i32 undef, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%41 = load i32, i32* @MPFR_RNDU
%42 = tail call i32 @string_to_fp(i32 undef, i8* %1, i32 %41)
%43 = tail call i32 @print_fp(i32* %0, i32 undef, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%44 = tail call i32 @mpfr_clear(i32 undef)
ret void
}