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

/* Variables and functions */
int /*<<< orphan*/ GMP_RNDN;
int /*<<< orphan*/ mpfr_add(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_init2(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpfr_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_set(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_set_prec(int /*<<< orphan*/, int);
void func(mpfr_t s, mpfr_t x, mpfr_t *coef, int n) {
  mpfr_set_prec(s, 53);
  mpfr_set(s, coef[n - 1], GMP_RNDN);
  for (int i = n - 1; i > 0; i--) {
    if (i == 2 - 1) {
      mpfr_t t;
      mpfr_init2(t, (53 * 4));
      mpfr_set(t, s, GMP_RNDN);
      mpfr_set_prec(s, (53 * 4));
      mpfr_set(s, t, GMP_RNDN);
      mpfr_clear(t);
    }
    mpfr_mul(s, s, x, GMP_RNDN);
    mpfr_add(s, s, coef[i - 1], GMP_RNDN);
  }
}


x86 assembly (clang, -O0):
<func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x35,%esi
call   1040 <mpfr_set_prec@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
mov    0x2e44(%rip),%rax
mov    (%rax),%edx
call   1070 <mpfr_set@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1253 <func+0xf3>
cmpl   $0x1,-0x18(%rbp)
jne    120a <func+0xaa>
mov    -0x1c(%rbp),%edi
mov    $0xd4,%esi
call   1080 <mpfr_init2@plt>
mov    -0x1c(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    0x2e06(%rip),%rax
mov    (%rax),%edx
call   1070 <mpfr_set@plt>
mov    -0x4(%rbp),%edi
mov    $0xd4,%esi
call   1040 <mpfr_set_prec@plt>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    0x2de5(%rip),%rax
mov    (%rax),%edx
call   1070 <mpfr_set@plt>
mov    -0x1c(%rbp),%edi
call   1050 <mpfr_clear@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    0x2dc6(%rip),%rax
mov    (%rax),%ecx
call   1030 <mpfr_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    0x2da2(%rip),%rax
mov    (%rax),%ecx
call   1060 <mpfr_add@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    11ac <func+0x4c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %rdx,%r12
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0x35,%esi
call   1040 <mpfr_set_prec@plt>
movslq %r15d,%rax
mov    -0x4(%r12,%rax,4),%esi
mov    0x2e51(%rip),%r13
mov    0x0(%r13),%edx
mov    %ebp,%edi
call   1070 <mpfr_set@plt>
cmp    $0x2,%r15d
jl     1219 <func+0xb9>
add    $0xffffffff,%r15d
mov    %r15d,%ebx
add    $0xffffffffffffffff,%rbx
mov    %rbx,%r15
jmp    11e0 <func+0x80>
mov    0x0(%r13),%ecx
mov    %ebp,%edi
mov    %ebp,%esi
mov    %r14d,%edx
call   1030 <mpfr_mul@plt>
mov    %ebx,%eax
mov    (%r12,%rax,4),%edx
mov    0x0(%r13),%ecx
mov    %ebp,%edi
mov    %ebp,%esi
call   1060 <mpfr_add@plt>
lea    0x2(%r15),%rax
mov    %r15,%rbx
cmp    $0x1,%rax
jle    1219 <func+0xb9>
sub    $0x1,%r15
jae    11b0 <func+0x50>
mov    $0xd4,%esi
call   1080 <mpfr_init2@plt>
mov    0x0(%r13),%edx
mov    %ebp,%esi
call   1070 <mpfr_set@plt>
mov    %ebp,%edi
mov    $0xd4,%esi
call   1040 <mpfr_set_prec@plt>
mov    0x0(%r13),%edx
mov    %ebp,%edi
call   1070 <mpfr_set@plt>
call   1050 <mpfr_clear@plt>
jmp    11b0 <func+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GMP_RNDN = global i32 0
define void @func(i32 %0, i32 %1, i32* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%11 = load i32, i32* %5
%12 = call i32 @mpfr_set_prec(i32 %11, i32 53)
%13 = load i32, i32* %5
%14 = load i32*, i32** %7
%15 = load i32, i32* %8
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %14, i64 %17
%19 = load i32, i32* %18
%20 = load i32, i32* @GMP_RNDN
%21 = call i32 @mpfr_set(i32 %13, i32 %19, i32 %20)
%22 = load i32, i32* %8
%23 = sub nsw i32 %22, 1
store i32 %23, i32* %9
br label %24
24: ; preds = %61, %4
%25 = load i32, i32* %9
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %64
27: ; preds = %24
%28 = load i32, i32* %9
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %45
30: ; preds = %27
%31 = load i32, i32* %10
%32 = call i32 @mpfr_init2(i32 %31, i32 212)
%33 = load i32, i32* %10
%34 = load i32, i32* %5
%35 = load i32, i32* @GMP_RNDN
%36 = call i32 @mpfr_set(i32 %33, i32 %34, i32 %35)
%37 = load i32, i32* %5
%38 = call i32 @mpfr_set_prec(i32 %37, i32 212)
%39 = load i32, i32* %5
%40 = load i32, i32* %10
%41 = load i32, i32* @GMP_RNDN
%42 = call i32 @mpfr_set(i32 %39, i32 %40, i32 %41)
%43 = load i32, i32* %10
%44 = call i32 @mpfr_clear(i32 %43)
br label %45
45: ; preds = %30, %27
%46 = load i32, i32* %5
%47 = load i32, i32* %5
%48 = load i32, i32* %6
%49 = load i32, i32* @GMP_RNDN
%50 = call i32 @mpfr_mul(i32 %46, i32 %47, i32 %48, i32 %49)
%51 = load i32, i32* %5
%52 = load i32, i32* %5
%53 = load i32*, i32** %7
%54 = load i32, i32* %9
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %53, i64 %56
%58 = load i32, i32* %57
%59 = load i32, i32* @GMP_RNDN
%60 = call i32 @mpfr_add(i32 %51, i32 %52, i32 %58, i32 %59)
br label %61
61: ; preds = %45
%62 = load i32, i32* %9
%63 = add nsw i32 %62, -1
store i32 %63, i32* %9
br label %24
64: ; preds = %24
ret void
}

LLVM IR (-O2):
@GMP_RNDN = global i32 0
define void @func(i32 %0, i32 %1, i32* nocapture %2, i32 %3) {
%5 = tail call i32 @mpfr_set_prec(i32 %0, i32 53)
%6 = add nsw i32 %3, -1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i32, i32* %2, i64 %7
%9 = load i32, i32* %8
%10 = load i32, i32* @GMP_RNDN
%11 = tail call i32 @mpfr_set(i32 %0, i32 %9, i32 %10)
%12 = icmp sgt i32 %3, 1
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = zext i32 %6 to i64
br label %16
15: ; preds = %27, %4
ret void
16: ; preds = %13, %27
%17 = phi i64 [ %14, %13 ], [ %30, %27 ]
%18 = icmp eq i64 %17, 1
br i1 %18, label %19, label %27
19: ; preds = %16
%20 = tail call i32 @mpfr_init2(i32 undef, i32 212)
%21 = load i32, i32* @GMP_RNDN
%22 = tail call i32 @mpfr_set(i32 undef, i32 %0, i32 %21)
%23 = tail call i32 @mpfr_set_prec(i32 %0, i32 212)
%24 = load i32, i32* @GMP_RNDN
%25 = tail call i32 @mpfr_set(i32 %0, i32 undef, i32 %24)
%26 = tail call i32 @mpfr_clear(i32 undef)
br label %27
27: ; preds = %19, %16
%28 = load i32, i32* @GMP_RNDN
%29 = tail call i32 @mpfr_mul(i32 %0, i32 %0, i32 %1, i32 %28)
%30 = add nsw i64 %17, -1
%31 = and i64 %30, 4294967295
%32 = getelementptr inbounds i32, i32* %2, i64 %31
%33 = load i32, i32* %32
%34 = load i32, i32* @GMP_RNDN
%35 = tail call i32 @mpfr_add(i32 %0, i32 %0, i32 %33, i32 %34)
%36 = icmp sgt i64 %17, 1
br i1 %36, label %16, label %15
}