#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*/ mpz_t;
typedef int /*<<< orphan*/ mpfr_t;
typedef int /*<<< orphan*/ mpfr_srcptr;
typedef scalar_t__ mpfr_rnd_t;
typedef int /*<<< orphan*/ mpfr_ptr;
typedef int /*<<< orphan*/ mpfr_exp_t;
typedef scalar_t__ mp_bitcnt_t;

/* Variables and functions */
scalar_t__ MPFR_RNDD;
scalar_t__ MPFR_RNDU;
int /*<<< orphan*/ assert(int);
int cmp_rev(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
            int (*)(int /*<<< orphan*/, int /*<<< orphan*/, void const *),
            void const *, int);
int /*<<< orphan*/ mpfr_as_mpz(int /*<<< orphan*/, int /*<<< orphan*/,
                               int /*<<< orphan*/, int /*<<< orphan*/,
                               int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_clear(int /*<<< orphan*/);
int mpfr_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_from_mpz(int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_get_emax();
int /*<<< orphan*/ mpfr_get_emin();
int /*<<< orphan*/ mpfr_get_prec(int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_init2(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_cdiv_q_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
scalar_t__ mpz_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_fdiv_q_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mul_2exp(int /*<<< orphan*/, int /*<<< orphan*/,
                                scalar_t__);
int /*<<< orphan*/ mpz_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_sub(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int p1788_rev_bin(mpfr_ptr rop, mpfr_srcptr rlim, mpfr_srcptr op,
                  int (*fwd_fun)(mpfr_ptr rop, mpfr_srcptr op, const void *env),
                  const void *env, int decrease, mpfr_rnd_t rnd) {
  assert(rnd == MPFR_RNDU || rnd == MPFR_RNDD);
  assert(mpfr_cmp(rop, rlim) == (rnd == MPFR_RNDU ? 1 : -1));
  mpfr_exp_t emin_rop = mpfr_get_emin();
  mpfr_exp_t emax_rop = mpfr_get_emax();
  mpfr_t tmp_op;
  mpfr_init2(tmp_op, mpfr_get_prec(op));
  mpz_t rop_z, rlim_z, z;
  mpz_init(rop_z);
  mpfr_as_mpz(rop_z, rop, emin_rop, emax_rop, 0);
  mpz_init(rlim_z);
  mpfr_as_mpz(rlim_z, rlim, emin_rop, emax_rop, 0);
  mpz_init(z);
  mp_bitcnt_t k;
  for (k = 0;; k++) {
    mpz_set_ui(z, 1);
    mpz_mul_2exp(z, z, k);
    if (rnd == MPFR_RNDU) {
      mpz_sub(z, rop_z, z);
      if (mpz_cmp(z, rlim_z) <= 0) {
        mpz_set(z, rlim_z);
        break;
      }
    } else {
      mpz_add(z, rop_z, z);
      if (mpz_cmp(z, rlim_z) >= 0) {
        mpz_set(z, rlim_z);
        break;
      }
    }
    mpfr_from_mpz(rop, z, emin_rop, emax_rop, 0);
    int t = cmp_rev(rop, op, tmp_op, fwd_fun, env, decrease);
    if (rnd == MPFR_RNDU ? t < 0 : t > 0)
      break;
    mpz_set(rop_z, z);
    if (t == 0) {
      mpfr_clear(tmp_op);
      mpz_clear(rop_z);
      mpz_clear(rlim_z);
      mpz_clear(z);
      return 0;
    }
  }
  mpz_t m;
  mpz_init(m);
  for (;;) {
    mpz_add(m, rop_z, z);
    if (rnd == MPFR_RNDU)
      mpz_cdiv_q_ui(m, m, 2);
    else
      mpz_fdiv_q_ui(m, m, 2);
    mpfr_from_mpz(rop, m, emin_rop, emax_rop, 0);
    if (mpz_cmp(m, rop_z) == 0) {
      mpfr_clear(tmp_op);
      mpz_clear(rop_z);
      mpz_clear(rlim_z);
      mpz_clear(z);
      mpz_clear(m);
      return rnd == MPFR_RNDU ? 1 : -1;
    }
    if (rnd == MPFR_RNDU)
      assert(mpz_cmp(m, z) > 0);
    else
      assert(mpz_cmp(m, z) < 0);
    int t = cmp_rev(rop, op, tmp_op, fwd_fun, env, decrease);
    if (rnd == MPFR_RNDU ? t < 0 : t > 0) {
      mpz_set(z, m);
    } else {
      mpz_set(rop_z, m);
      if (t == 0) {
        mpfr_clear(tmp_op);
        mpz_clear(rop_z);
        mpz_clear(rlim_z);
        mpz_clear(z);
        mpz_clear(m);
        return 0;
      }
    }
  }
}


x86 assembly (clang, -O0):
<p1788_rev_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    0x10(%rbp),%rcx
mov    $0x1,%al
mov    0x2d6a(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x55(%rbp)
je     128e <p1788_rev_bin+0x4e>
mov    0x10(%rbp),%rax
mov    0x2d63(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1130 <mpfr_cmp@plt>
mov    0x10(%rbp),%rsi
mov    0x2d27(%rip),%rcx
mov    (%rcx),%rdi
mov    $0xffffffff,%ecx
mov    $0x1,%edx
cmp    %rdi,%rsi
cmove  %edx,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    $0x0,%al
call   10c0 <mpfr_get_emin@plt>
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   10f0 <mpfr_get_emax@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%edi
call   1150 <mpfr_get_prec@plt>
mov    -0x5c(%rbp),%edi
mov    %eax,%esi
call   1160 <mpfr_init2@plt>
mov    -0x34(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0x34(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
xor    %r8d,%r8d
call   1090 <mpfr_as_mpz@plt>
mov    -0x38(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0x38(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
xor    %r8d,%r8d
call   1090 <mpfr_as_mpz@plt>
mov    -0x3c(%rbp),%edi
call   1060 <mpz_init@plt>
movq   $0x0,-0x48(%rbp)
mov    -0x3c(%rbp),%edi
mov    $0x1,%esi
call   1120 <mpz_set_ui@plt>
mov    -0x3c(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x48(%rbp),%rdx
call   10a0 <mpz_mul_2exp@plt>
mov    0x10(%rbp),%rax
mov    0x2c6a(%rip),%rcx
cmp    (%rcx),%rax
jne    13af <p1788_rev_bin+0x16f>
mov    -0x3c(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0x3c(%rbp),%edx
call   1040 <mpz_sub@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1110 <mpz_cmp@plt>
cmp    $0x0,%rax
jg     13aa <p1788_rev_bin+0x16a>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1030 <mpz_set@plt>
jmp    14a1 <p1788_rev_bin+0x261>
jmp    13e7 <p1788_rev_bin+0x1a7>
mov    -0x3c(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0x3c(%rbp),%edx
call   10b0 <mpz_add@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1110 <mpz_cmp@plt>
cmp    $0x0,%rax
jl     13e2 <p1788_rev_bin+0x1a2>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1030 <mpz_set@plt>
jmp    14a1 <p1788_rev_bin+0x261>
jmp    13e7 <p1788_rev_bin+0x1a7>
mov    -0x8(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
xor    %r8d,%r8d
call   10e0 <mpfr_from_mpz@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
call   1070 <cmp_rev@plt>
mov    %eax,-0x4c(%rbp)
mov    0x10(%rbp),%rax
mov    0x2bb5(%rip),%rcx
cmp    (%rcx),%rax
jne    143b <p1788_rev_bin+0x1fb>
cmpl   $0x0,-0x4c(%rbp)
jl     1445 <p1788_rev_bin+0x205>
jmp    144a <p1788_rev_bin+0x20a>
cmpl   $0x0,-0x4c(%rbp)
jle    144a <p1788_rev_bin+0x20a>
jmp    14a1 <p1788_rev_bin+0x261>
mov    -0x34(%rbp),%edi
mov    -0x3c(%rbp),%esi
call   1030 <mpz_set@plt>
cmpl   $0x0,-0x4c(%rbp)
jne    148b <p1788_rev_bin+0x24b>
mov    -0x30(%rbp),%edi
call   1050 <mpfr_clear@plt>
mov    -0x34(%rbp),%edi
call   1140 <mpz_clear@plt>
mov    -0x38(%rbp),%edi
call   1140 <mpz_clear@plt>
mov    -0x3c(%rbp),%edi
call   1140 <mpz_clear@plt>
movl   $0x0,-0x4(%rbp)
jmp    1665 <p1788_rev_bin+0x425>
jmp    1490 <p1788_rev_bin+0x250>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1347 <p1788_rev_bin+0x107>
mov    -0x50(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0x50(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0x3c(%rbp),%edx
call   10b0 <mpz_add@plt>
mov    0x10(%rbp),%rax
mov    0x2b16(%rip),%rcx
cmp    (%rcx),%rax
jne    14e0 <p1788_rev_bin+0x2a0>
mov    -0x50(%rbp),%edi
mov    -0x50(%rbp),%esi
mov    $0x2,%edx
call   10d0 <mpz_cdiv_q_ui@plt>
jmp    14f0 <p1788_rev_bin+0x2b0>
mov    -0x50(%rbp),%edi
mov    -0x50(%rbp),%esi
mov    $0x2,%edx
call   1100 <mpz_fdiv_q_ui@plt>
mov    -0x8(%rbp),%edi
mov    -0x50(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
xor    %r8d,%r8d
call   10e0 <mpfr_from_mpz@plt>
mov    -0x50(%rbp),%edi
mov    -0x34(%rbp),%esi
call   1110 <mpz_cmp@plt>
cmp    $0x0,%rax
jne    1567 <p1788_rev_bin+0x327>
mov    -0x30(%rbp),%edi
call   1050 <mpfr_clear@plt>
mov    -0x34(%rbp),%edi
call   1140 <mpz_clear@plt>
mov    -0x38(%rbp),%edi
call   1140 <mpz_clear@plt>
mov    -0x3c(%rbp),%edi
call   1140 <mpz_clear@plt>
mov    -0x50(%rbp),%edi
call   1140 <mpz_clear@plt>
mov    0x10(%rbp),%rdx
mov    0x2a8c(%rip),%rax
mov    (%rax),%rsi
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    %rsi,%rdx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1665 <p1788_rev_bin+0x425>
mov    0x10(%rbp),%rax
mov    0x2a66(%rip),%rcx
cmp    (%rcx),%rax
jne    159c <p1788_rev_bin+0x35c>
mov    -0x50(%rbp),%edi
mov    -0x3c(%rbp),%esi
call   1110 <mpz_cmp@plt>
cmp    $0x0,%rax
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
jmp    15b8 <p1788_rev_bin+0x378>
mov    -0x50(%rbp),%edi
mov    -0x3c(%rbp),%esi
call   1110 <mpz_cmp@plt>
cmp    $0x0,%rax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
call   1070 <cmp_rev@plt>
mov    %eax,-0x54(%rbp)
mov    0x10(%rbp),%rax
mov    0x29f8(%rip),%rcx
cmp    (%rcx),%rax
jne    15f8 <p1788_rev_bin+0x3b8>
cmpl   $0x0,-0x54(%rbp)
jl     1602 <p1788_rev_bin+0x3c2>
jmp    1612 <p1788_rev_bin+0x3d2>
cmpl   $0x0,-0x54(%rbp)
jle    1612 <p1788_rev_bin+0x3d2>
mov    -0x3c(%rbp),%edi
mov    -0x50(%rbp),%esi
call   1030 <mpz_set@plt>
jmp    1660 <p1788_rev_bin+0x420>
mov    -0x34(%rbp),%edi
mov    -0x50(%rbp),%esi
call   1030 <mpz_set@plt>
cmpl   $0x0,-0x54(%rbp)
jne    165b <p1788_rev_bin+0x41b>
mov    -0x30(%rbp),%edi
call   1050 <mpfr_clear@plt>
mov    -0x34(%rbp),%edi
call   1140 <mpz_clear@plt>
mov    -0x38(%rbp),%edi
call   1140 <mpz_clear@plt>
mov    -0x3c(%rbp),%edi
call   1140 <mpz_clear@plt>
mov    -0x50(%rbp),%edi
call   1140 <mpz_clear@plt>
movl   $0x0,-0x4(%rbp)
jmp    1665 <p1788_rev_bin+0x425>
jmp    1660 <p1788_rev_bin+0x420>
jmp    14a9 <p1788_rev_bin+0x269>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<p1788_rev_bin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x60(%rsp),%rbx
mov    0x2d7e(%rip),%r12
cmp    %rbx,(%r12)
sete   %al
mov    0x2d80(%rip),%rbp
cmp    %rbx,0x0(%rbp)
mov    %r9d,0x10(%rsp)
mov    %r8,0x20(%rsp)
mov    %rcx,0x18(%rsp)
mov    %edx,0xc(%rsp)
mov    %esi,%r14d
mov    %esi,0x14(%rsp)
mov    %edi,%ebp
sete   %cl
or     %al,%cl
movzbl %cl,%edi
call   1080 <assert@plt>
mov    %ebp,%edi
mov    %r14d,%esi
call   1130 <mpfr_cmp@plt>
xor    %ecx,%ecx
cmp    %rbx,(%r12)
sete   %cl
add    %ecx,%ecx
add    $0xffffffff,%ecx
xor    %edi,%edi
cmp    %ecx,%eax
sete   %dil
call   1080 <assert@plt>
xor    %r15d,%r15d
xor    %eax,%eax
call   10c0 <mpfr_get_emin@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   10f0 <mpfr_get_emax@plt>
mov    %eax,%r14d
mov    0xc(%rsp),%edi
call   1150 <mpfr_get_prec@plt>
mov    %eax,%esi
call   1160 <mpfr_init2@plt>
call   1060 <mpz_init@plt>
mov    %ebp,%esi
mov    %r13d,%edx
mov    %r14d,%ecx
xor    %r8d,%r8d
call   1090 <mpfr_as_mpz@plt>
call   1060 <mpz_init@plt>
mov    0x14(%rsp),%esi
mov    %r13d,%edx
mov    %r14d,%ecx
xor    %r8d,%r8d
call   1090 <mpfr_as_mpz@plt>
call   1060 <mpz_init@plt>
jmp    1347 <p1788_rev_bin+0x107>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %r12d,%r12d
jg     13d1 <p1788_rev_bin+0x191>
call   1030 <mpz_set@plt>
add    $0x1,%r15
test   %r12d,%r12d
mov    0x60(%rsp),%rbx
mov    0x2c97(%rip),%r12
je     14d8 <p1788_rev_bin+0x298>
mov    $0x1,%esi
call   1120 <mpz_set_ui@plt>
mov    %r15,%rdx
call   10a0 <mpz_mul_2exp@plt>
cmp    %rbx,(%r12)
jne    1370 <p1788_rev_bin+0x130>
call   1040 <mpz_sub@plt>
call   1110 <mpz_cmp@plt>
test   %rax,%rax
jg     137f <p1788_rev_bin+0x13f>
jmp    13cc <p1788_rev_bin+0x18c>
call   10b0 <mpz_add@plt>
call   1110 <mpz_cmp@plt>
test   %rax,%rax
jns    13cc <p1788_rev_bin+0x18c>
mov    %ebp,%edi
mov    %r13d,%edx
mov    %r14d,%ecx
xor    %r8d,%r8d
call   10e0 <mpfr_from_mpz@plt>
mov    %ebp,%edi
mov    0xc(%rsp),%esi
mov    0x18(%rsp),%rcx
mov    0x20(%rsp),%r8
mov    0x10(%rsp),%r9d
call   1070 <cmp_rev@plt>
mov    %eax,%r12d
mov    0x60(%rsp),%rax
mov    0x2c20(%rip),%rcx
cmp    %rax,(%rcx)
jne    1320 <p1788_rev_bin+0xe0>
test   %r12d,%r12d
jns    1329 <p1788_rev_bin+0xe9>
jmp    13d1 <p1788_rev_bin+0x191>
call   1030 <mpz_set@plt>
call   1060 <mpz_init@plt>
mov    0x60(%rsp),%r15
mov    0x2bf6(%rip),%r12
jmp    13fd <p1788_rev_bin+0x1bd>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %ebx,%ebx
jle    1496 <p1788_rev_bin+0x256>
call   1030 <mpz_set@plt>
call   10b0 <mpz_add@plt>
cmp    %r15,(%r12)
jne    1420 <p1788_rev_bin+0x1e0>
mov    $0x2,%edx
call   10d0 <mpz_cdiv_q_ui@plt>
jmp    142a <p1788_rev_bin+0x1ea>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2,%edx
call   1100 <mpz_fdiv_q_ui@plt>
mov    %ebp,%edi
mov    %r13d,%edx
mov    %r14d,%ecx
xor    %r8d,%r8d
call   10e0 <mpfr_from_mpz@plt>
call   1110 <mpz_cmp@plt>
test   %rax,%rax
je     14af <p1788_rev_bin+0x26f>
mov    (%r12),%rbx
call   1110 <mpz_cmp@plt>
mov    %rax,%rcx
shr    $0x3f,%rcx
xor    %edi,%edi
test   %rax,%rax
setg   %dil
cmp    %r15,%rbx
cmovne %ecx,%edi
call   1080 <assert@plt>
mov    %ebp,%edi
mov    0xc(%rsp),%esi
mov    0x18(%rsp),%rcx
mov    0x20(%rsp),%r8
mov    0x10(%rsp),%r9d
call   1070 <cmp_rev@plt>
mov    %eax,%ebx
cmp    %r15,(%r12)
jne    13f0 <p1788_rev_bin+0x1b0>
test   %ebx,%ebx
js     13f8 <p1788_rev_bin+0x1b8>
call   1030 <mpz_set@plt>
test   %ebx,%ebx
jne    13fd <p1788_rev_bin+0x1bd>
call   1050 <mpfr_clear@plt>
call   1140 <mpz_clear@plt>
jmp    14dd <p1788_rev_bin+0x29d>
call   1050 <mpfr_clear@plt>
call   1140 <mpz_clear@plt>
call   1140 <mpz_clear@plt>
call   1140 <mpz_clear@plt>
call   1140 <mpz_clear@plt>
xor    %eax,%eax
cmp    %r15,(%r12)
sete   %al
add    %eax,%eax
add    $0xffffffff,%eax
jmp    14ee <p1788_rev_bin+0x2ae>
call   1050 <mpfr_clear@plt>
call   1140 <mpz_clear@plt>
call   1140 <mpz_clear@plt>
call   1140 <mpz_clear@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MPFR_RNDU = global i64 0
@MPFR_RNDD = global i64 0
define i32 @p1788_rev_bin(i32 %0, i32 %1, i32 %2, i32 (i32, i32, i8*)* %3, i8* %4, i32 %5, i64 %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32 (i32, i32, i8*)*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i64
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 (i32, i32, i8*)* %3, i32 (i32, i32, i8*)** %12
store i8* %4, i8** %13
store i32 %5, i32* %14
store i64 %6, i64* %15
%26 = load i64, i64* %15
%27 = load i64, i64* @MPFR_RNDU
%28 = icmp eq i64 %26, %27
br i1 %28, label %33, label %29
29: ; preds = %7
%30 = load i64, i64* %15
%31 = load i64, i64* @MPFR_RNDD
%32 = icmp eq i64 %30, %31
br label %33
33: ; preds = %29, %7
%34 = phi i1 [ true, %7 ], [ %32, %29 ]
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i32, i32* %9
%38 = load i32, i32* %10
%39 = call i32 @mpfr_cmp(i32 %37, i32 %38)
%40 = load i64, i64* %15
%41 = load i64, i64* @MPFR_RNDU
%42 = icmp eq i64 %40, %41
%43 = zext i1 %42 to i64
%44 = select i1 %42, i32 1, i32 -1
%45 = icmp eq i32 %39, %44
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = call i32 (...) @mpfr_get_emin()
store i32 %48, i32* %16
%49 = call i32 (...) @mpfr_get_emax()
store i32 %49, i32* %17
%50 = load i32, i32* %18
%51 = load i32, i32* %11
%52 = call i32 @mpfr_get_prec(i32 %51)
%53 = call i32 @mpfr_init2(i32 %50, i32 %52)
%54 = load i32, i32* %19
%55 = call i32 @mpz_init(i32 %54)
%56 = load i32, i32* %19
%57 = load i32, i32* %9
%58 = load i32, i32* %16
%59 = load i32, i32* %17
%60 = call i32 @mpfr_as_mpz(i32 %56, i32 %57, i32 %58, i32 %59, i32 0)
%61 = load i32, i32* %20
%62 = call i32 @mpz_init(i32 %61)
%63 = load i32, i32* %20
%64 = load i32, i32* %10
%65 = load i32, i32* %16
%66 = load i32, i32* %17
%67 = call i32 @mpfr_as_mpz(i32 %63, i32 %64, i32 %65, i32 %66, i32 0)
%68 = load i32, i32* %21
%69 = call i32 @mpz_init(i32 %68)
store i64 0, i64* %22
br label %70
70: ; preds = %147, %33
%71 = load i32, i32* %21
%72 = call i32 @mpz_set_ui(i32 %71, i32 1)
%73 = load i32, i32* %21
%74 = load i32, i32* %21
%75 = load i64, i64* %22
%76 = call i32 @mpz_mul_2exp(i32 %73, i32 %74, i64 %75)
%77 = load i64, i64* %15
%78 = load i64, i64* @MPFR_RNDU
%79 = icmp eq i64 %77, %78
br i1 %79, label %80, label %94
80: ; preds = %70
%81 = load i32, i32* %21
%82 = load i32, i32* %19
%83 = load i32, i32* %21
%84 = call i32 @mpz_sub(i32 %81, i32 %82, i32 %83)
%85 = load i32, i32* %21
%86 = load i32, i32* %20
%87 = call i64 @mpz_cmp(i32 %85, i32 %86)
%88 = icmp sle i64 %87, 0
br i1 %88, label %89, label %93
89: ; preds = %80
%90 = load i32, i32* %21
%91 = load i32, i32* %20
%92 = call i32 @mpz_set(i32 %90, i32 %91)
br label %150
93: ; preds = %80
br label %108
94: ; preds = %70
%95 = load i32, i32* %21
%96 = load i32, i32* %19
%97 = load i32, i32* %21
%98 = call i32 @mpz_add(i32 %95, i32 %96, i32 %97)
%99 = load i32, i32* %21
%100 = load i32, i32* %20
%101 = call i64 @mpz_cmp(i32 %99, i32 %100)
%102 = icmp sge i64 %101, 0
br i1 %102, label %103, label %107
103: ; preds = %94
%104 = load i32, i32* %21
%105 = load i32, i32* %20
%106 = call i32 @mpz_set(i32 %104, i32 %105)
br label %150
107: ; preds = %94
br label %108
108: ; preds = %107, %93
%109 = load i32, i32* %9
%110 = load i32, i32* %21
%111 = load i32, i32* %16
%112 = load i32, i32* %17
%113 = call i32 @mpfr_from_mpz(i32 %109, i32 %110, i32 %111, i32 %112, i32 0)
%114 = load i32, i32* %9
%115 = load i32, i32* %11
%116 = load i32, i32* %18
%117 = load i32 (i32, i32, i8*)*, i32 (i32, i32, i8*)** %12
%118 = load i8*, i8** %13
%119 = load i32, i32* %14
%120 = call i32 @cmp_rev(i32 %114, i32 %115, i32 %116, i32 (i32, i32, i8*)* %117, i8* %118, i32 %119)
store i32 %120, i32* %23
%121 = load i64, i64* %15
%122 = load i64, i64* @MPFR_RNDU
%123 = icmp eq i64 %121, %122
br i1 %123, label %124, label %127
124: ; preds = %108
%125 = load i32, i32* %23
%126 = icmp slt i32 %125, 0
br i1 %126, label %130, label %131
127: ; preds = %108
%128 = load i32, i32* %23
%129 = icmp sgt i32 %128, 0
br i1 %129, label %130, label %131
130: ; preds = %127, %124
br label %150
131: ; preds = %127, %124
%132 = load i32, i32* %19
%133 = load i32, i32* %21
%134 = call i32 @mpz_set(i32 %132, i32 %133)
%135 = load i32, i32* %23
%136 = icmp eq i32 %135, 0
br i1 %136, label %137, label %146
137: ; preds = %131
%138 = load i32, i32* %18
%139 = call i32 @mpfr_clear(i32 %138)
%140 = load i32, i32* %19
%141 = call i32 @mpz_clear(i32 %140)
%142 = load i32, i32* %20
%143 = call i32 @mpz_clear(i32 %142)
%144 = load i32, i32* %21
%145 = call i32 @mpz_clear(i32 %144)
store i32 0, i32* %8
br label %253
146: ; preds = %131
br label %147
147: ; preds = %146
%148 = load i64, i64* %22
%149 = add nsw i64 %148, 1
store i64 %149, i64* %22
br label %70
150: ; preds = %130, %103, %89
%151 = load i32, i32* %24
%152 = call i32 @mpz_init(i32 %151)
br label %153
153: ; preds = %252, %150
%154 = load i32, i32* %24
%155 = load i32, i32* %19
%156 = load i32, i32* %21
%157 = call i32 @mpz_add(i32 %154, i32 %155, i32 %156)
%158 = load i64, i64* %15
%159 = load i64, i64* @MPFR_RNDU
%160 = icmp eq i64 %158, %159
br i1 %160, label %161, label %165
161: ; preds = %153
%162 = load i32, i32* %24
%163 = load i32, i32* %24
%164 = call i32 @mpz_cdiv_q_ui(i32 %162, i32 %163, i32 2)
br label %169
165: ; preds = %153
%166 = load i32, i32* %24
%167 = load i32, i32* %24
%168 = call i32 @mpz_fdiv_q_ui(i32 %166, i32 %167, i32 2)
br label %169
169: ; preds = %165, %161
%170 = load i32, i32* %9
%171 = load i32, i32* %24
%172 = load i32, i32* %16
%173 = load i32, i32* %17
%174 = call i32 @mpfr_from_mpz(i32 %170, i32 %171, i32 %172, i32 %173, i32 0)
%175 = load i32, i32* %24
%176 = load i32, i32* %19
%177 = call i64 @mpz_cmp(i32 %175, i32 %176)
%178 = icmp eq i64 %177, 0
br i1 %178, label %179, label %195
179: ; preds = %169
%180 = load i32, i32* %18
%181 = call i32 @mpfr_clear(i32 %180)
%182 = load i32, i32* %19
%183 = call i32 @mpz_clear(i32 %182)
%184 = load i32, i32* %20
%185 = call i32 @mpz_clear(i32 %184)
%186 = load i32, i32* %21
%187 = call i32 @mpz_clear(i32 %186)
%188 = load i32, i32* %24
%189 = call i32 @mpz_clear(i32 %188)
%190 = load i64, i64* %15
%191 = load i64, i64* @MPFR_RNDU
%192 = icmp eq i64 %190, %191
%193 = zext i1 %192 to i64
%194 = select i1 %192, i32 1, i32 -1
store i32 %194, i32* %8
br label %253
195: ; preds = %169
%196 = load i64, i64* %15
%197 = load i64, i64* @MPFR_RNDU
%198 = icmp eq i64 %196, %197
br i1 %198, label %199, label %206
199: ; preds = %195
%200 = load i32, i32* %24
%201 = load i32, i32* %21
%202 = call i64 @mpz_cmp(i32 %200, i32 %201)
%203 = icmp sgt i64 %202, 0
%204 = zext i1 %203 to i32
%205 = call i32 @assert(i32 %204)
br label %213
206: ; preds = %195
%207 = load i32, i32* %24
%208 = load i32, i32* %21
%209 = call i64 @mpz_cmp(i32 %207, i32 %208)
%210 = icmp slt i64 %209, 0
%211 = zext i1 %210 to i32
%212 = call i32 @assert(i32 %211)
br label %213
213: ; preds = %206, %199
%214 = load i32, i32* %9
%215 = load i32, i32* %11
%216 = load i32, i32* %18
%217 = load i32 (i32, i32, i8*)*, i32 (i32, i32, i8*)** %12
%218 = load i8*, i8** %13
%219 = load i32, i32* %14
%220 = call i32 @cmp_rev(i32 %214, i32 %215, i32 %216, i32 (i32, i32, i8*)* %217, i8* %218, i32 %219)
store i32 %220, i32* %25
%221 = load i64, i64* %15
%222 = load i64, i64* @MPFR_RNDU
%223 = icmp eq i64 %221, %222
br i1 %223, label %224, label %227
224: ; preds = %213
%225 = load i32, i32* %25
%226 = icmp slt i32 %225, 0
br i1 %226, label %230, label %234
227: ; preds = %213
%228 = load i32, i32* %25
%229 = icmp sgt i32 %228, 0
br i1 %229, label %230, label %234
230: ; preds = %227, %224
%231 = load i32, i32* %21
%232 = load i32, i32* %24
%233 = call i32 @mpz_set(i32 %231, i32 %232)
br label %252
234: ; preds = %227, %224
%235 = load i32, i32* %19
%236 = load i32, i32* %24
%237 = call i32 @mpz_set(i32 %235, i32 %236)
%238 = load i32, i32* %25
%239 = icmp eq i32 %238, 0
br i1 %239, label %240, label %251
240: ; preds = %234
%241 = load i32, i32* %18
%242 = call i32 @mpfr_clear(i32 %241)
%243 = load i32, i32* %19
%244 = call i32 @mpz_clear(i32 %243)
%245 = load i32, i32* %20
%246 = call i32 @mpz_clear(i32 %245)
%247 = load i32, i32* %21
%248 = call i32 @mpz_clear(i32 %247)
%249 = load i32, i32* %24
%250 = call i32 @mpz_clear(i32 %249)
store i32 0, i32* %8
br label %253
251: ; preds = %234
br label %252
252: ; preds = %251, %230
br label %153
253: ; preds = %240, %179, %137
%254 = load i32, i32* %8
ret i32 %254
}

LLVM IR (-O2):
@MPFR_RNDU = global i64 0
@MPFR_RNDD = global i64 0
define i32 @p1788_rev_bin(i32 %0, i32 %1, i32 %2, i32 (i32, i32, i8*)* %3, i8* %4, i32 %5, i64 %6) {
%8 = load i64, i64* @MPFR_RNDU
%9 = icmp eq i64 %8, %6
%10 = load i64, i64* @MPFR_RNDD
%11 = icmp eq i64 %10, %6
%12 = select i1 %9, i1 true, i1 %11
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = tail call i32 @mpfr_cmp(i32 %0, i32 %1)
%16 = load i64, i64* @MPFR_RNDU
%17 = icmp eq i64 %16, %6
%18 = select i1 %17, i32 1, i32 -1
%19 = icmp eq i32 %15, %18
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i32 (...) @mpfr_get_emin()
%23 = tail call i32 (...) @mpfr_get_emax()
%24 = tail call i32 @mpfr_get_prec(i32 %2)
%25 = tail call i32 @mpfr_init2(i32 undef, i32 %24)
%26 = tail call i32 @mpz_init(i32 undef)
%27 = tail call i32 @mpfr_as_mpz(i32 undef, i32 %0, i32 %22, i32 %23, i32 0)
%28 = tail call i32 @mpz_init(i32 undef)
%29 = tail call i32 @mpfr_as_mpz(i32 undef, i32 %1, i32 %22, i32 %23, i32 0)
%30 = tail call i32 @mpz_init(i32 undef)
br label %31
31: ; preds = %54, %7
%32 = phi i64 [ 0, %7 ], [ %57, %54 ]
%33 = tail call i32 @mpz_set_ui(i32 undef, i32 1)
%34 = tail call i32 @mpz_mul_2exp(i32 undef, i32 undef, i64 %32)
%35 = load i64, i64* @MPFR_RNDU
%36 = icmp eq i64 %35, %6
br i1 %36, label %37, label %41
37: ; preds = %31
%38 = tail call i32 @mpz_sub(i32 undef, i32 undef, i32 undef)
%39 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%40 = icmp slt i64 %39, 1
br i1 %40, label %63, label %45
41: ; preds = %31
%42 = tail call i32 @mpz_add(i32 undef, i32 undef, i32 undef)
%43 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%44 = icmp sgt i64 %43, -1
br i1 %44, label %63, label %45
45: ; preds = %41, %37
%46 = tail call i32 @mpfr_from_mpz(i32 %0, i32 undef, i32 %22, i32 %23, i32 0)
%47 = tail call i32 @cmp_rev(i32 %0, i32 %2, i32 undef, i32 (i32, i32, i8*)* %3, i8* %4, i32 %5)
%48 = load i64, i64* @MPFR_RNDU
%49 = icmp eq i64 %48, %6
br i1 %49, label %50, label %52
50: ; preds = %45
%51 = icmp slt i32 %47, 0
br i1 %51, label %65, label %54
52: ; preds = %45
%53 = icmp sgt i32 %47, 0
br i1 %53, label %65, label %54
54: ; preds = %52, %50
%55 = tail call i32 @mpz_set(i32 undef, i32 undef)
%56 = icmp eq i32 %47, 0
%57 = add nuw nsw i64 %32, 1
br i1 %56, label %58, label %31
58: ; preds = %54
%59 = tail call i32 @mpfr_clear(i32 undef)
%60 = tail call i32 @mpz_clear(i32 undef)
%61 = tail call i32 @mpz_clear(i32 undef)
%62 = tail call i32 @mpz_clear(i32 undef)
br label %117
63: ; preds = %41, %37
%64 = tail call i32 @mpz_set(i32 undef, i32 undef)
br label %65
65: ; preds = %50, %52, %63
%66 = tail call i32 @mpz_init(i32 undef)
br label %67
67: ; preds = %107, %65
%68 = tail call i32 @mpz_add(i32 undef, i32 undef, i32 undef)
%69 = load i64, i64* @MPFR_RNDU
%70 = icmp eq i64 %69, %6
br i1 %70, label %71, label %73
71: ; preds = %67
%72 = tail call i32 @mpz_cdiv_q_ui(i32 undef, i32 undef, i32 2)
br label %75
73: ; preds = %67
%74 = tail call i32 @mpz_fdiv_q_ui(i32 undef, i32 undef, i32 2)
br label %75
75: ; preds = %73, %71
%76 = tail call i32 @mpfr_from_mpz(i32 %0, i32 undef, i32 %22, i32 %23, i32 0)
%77 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %88
79: ; preds = %75
%80 = tail call i32 @mpfr_clear(i32 undef)
%81 = tail call i32 @mpz_clear(i32 undef)
%82 = tail call i32 @mpz_clear(i32 undef)
%83 = tail call i32 @mpz_clear(i32 undef)
%84 = tail call i32 @mpz_clear(i32 undef)
%85 = load i64, i64* @MPFR_RNDU
%86 = icmp eq i64 %85, %6
%87 = select i1 %86, i32 1, i32 -1
br label %117
88: ; preds = %75
%89 = load i64, i64* @MPFR_RNDU
%90 = icmp eq i64 %89, %6
%91 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%92 = lshr i64 %91, 63
%93 = trunc i64 %92 to i32
%94 = icmp sgt i64 %91, 0
%95 = zext i1 %94 to i32
%96 = select i1 %90, i32 %95, i32 %93
%97 = tail call i32 @assert(i32 %96)
%98 = tail call i32 @cmp_rev(i32 %0, i32 %2, i32 undef, i32 (i32, i32, i8*)* %3, i8* %4, i32 %5)
%99 = load i64, i64* @MPFR_RNDU
%100 = icmp eq i64 %99, %6
br i1 %100, label %101, label %103
101: ; preds = %88
%102 = icmp slt i32 %98, 0
br i1 %102, label %105, label %108
103: ; preds = %88
%104 = icmp sgt i32 %98, 0
br i1 %104, label %105, label %108
105: ; preds = %103, %101
%106 = tail call i32 @mpz_set(i32 undef, i32 undef)
br label %107
107: ; preds = %105, %108
br label %67
108: ; preds = %103, %101
%109 = tail call i32 @mpz_set(i32 undef, i32 undef)
%110 = icmp eq i32 %98, 0
br i1 %110, label %111, label %107
111: ; preds = %108
%112 = tail call i32 @mpfr_clear(i32 undef)
%113 = tail call i32 @mpz_clear(i32 undef)
%114 = tail call i32 @mpz_clear(i32 undef)
%115 = tail call i32 @mpz_clear(i32 undef)
%116 = tail call i32 @mpz_clear(i32 undef)
br label %117
117: ; preds = %58, %79, %111
%118 = phi i32 [ %87, %79 ], [ 0, %111 ], [ 0, %58 ]
ret i32 %118
}