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

/* Variables and functions */
int /*<<< orphan*/ mpf_div(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_init2(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_mul_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_out_str(int /*<<< orphan*/, int, int /*<<< orphan*/,
                               int /*<<< orphan*/);
int /*<<< orphan*/ mpf_set_d(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_set_si(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
void wallis(int times) {
  mpf_t pi, numer, term;
  mpf_init2(pi, 1024);
  mpf_init2(numer, 1024);
  mpf_init2(term, 1024);
  mpf_set_ui(pi, 1);
  int a;
  for (a = 1; a <= times / 2; a++) {
    mpf_set_d(numer, 2 * a);
    mpf_mul(numer, numer, numer);
    mpf_set_si(term, 2 * a - 1);
    mpf_mul_ui(term, term, 2 * a + 1);
    mpf_div(term, numer, term);
    mpf_mul(pi, pi, term);
  }
  mpf_mul_ui(pi, pi, 2);
  mpf_out_str(stdout, 10, 0, pi);
  printf("\n");
}


x86 assembly (clang, -O0):
<wallis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x400,%esi
call   10b0 <mpf_init2@plt>
mov    -0xc(%rbp),%edi
mov    $0x400,%esi
call   10b0 <mpf_init2@plt>
mov    -0x10(%rbp),%edi
mov    $0x400,%esi
call   10b0 <mpf_init2@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1060 <mpf_set_ui@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jg     125f <wallis+0xcf>
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
shl    $0x1,%esi
call   1050 <mpf_set_d@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1090 <mpf_mul@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
shl    $0x1,%esi
sub    $0x1,%esi
call   1040 <mpf_set_si@plt>
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
shl    $0x1,%edx
add    $0x1,%edx
call   1070 <mpf_mul_ui@plt>
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   10a0 <mpf_div@plt>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1090 <mpf_mul@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d6 <wallis+0x46>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x2,%edx
call   1070 <mpf_mul_ui@plt>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%ecx
mov    $0xa,%esi
xor    %edx,%edx
call   1080 <mpf_out_str@plt>
lea    0xd72(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wallis>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x400,%esi
call   10b0 <mpf_init2@plt>
mov    $0x400,%esi
call   10b0 <mpf_init2@plt>
mov    $0x400,%esi
call   10b0 <mpf_init2@plt>
mov    $0x1,%esi
call   1060 <mpf_set_ui@plt>
cmp    $0x2,%ebp
jl     11fe <wallis+0x6e>
shr    %ebp
mov    $0x3,%ebx
nopl   0x0(%rax)
lea    -0x1(%rbx),%esi
call   1050 <mpf_set_d@plt>
call   1090 <mpf_mul@plt>
lea    -0x2(%rbx),%esi
call   1040 <mpf_set_si@plt>
mov    %ebx,%edx
call   1070 <mpf_mul_ui@plt>
call   10a0 <mpf_div@plt>
call   1090 <mpf_mul@plt>
add    $0x2,%ebx
add    $0xffffffff,%ebp
jne    11d0 <wallis+0x40>
mov    $0x2,%edx
call   1070 <mpf_mul_ui@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
mov    $0xa,%esi
xor    %edx,%edx
call   1080 <mpf_out_str@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [2 x i8] c"\0A\00"
define void @wallis(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %3
%8 = call i32 @mpf_init2(i32 %7, i32 1024)
%9 = load i32, i32* %4
%10 = call i32 @mpf_init2(i32 %9, i32 1024)
%11 = load i32, i32* %5
%12 = call i32 @mpf_init2(i32 %11, i32 1024)
%13 = load i32, i32* %3
%14 = call i32 @mpf_set_ui(i32 %13, i32 1)
store i32 1, i32* %6
br label %15
15: ; preds = %48, %1
%16 = load i32, i32* %6
%17 = load i32, i32* %2
%18 = sdiv i32 %17, 2
%19 = icmp sle i32 %16, %18
br i1 %19, label %20, label %51
20: ; preds = %15
%21 = load i32, i32* %4
%22 = load i32, i32* %6
%23 = mul nsw i32 2, %22
%24 = call i32 @mpf_set_d(i32 %21, i32 %23)
%25 = load i32, i32* %4
%26 = load i32, i32* %4
%27 = load i32, i32* %4
%28 = call i32 @mpf_mul(i32 %25, i32 %26, i32 %27)
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = mul nsw i32 2, %30
%32 = sub nsw i32 %31, 1
%33 = call i32 @mpf_set_si(i32 %29, i32 %32)
%34 = load i32, i32* %5
%35 = load i32, i32* %5
%36 = load i32, i32* %6
%37 = mul nsw i32 2, %36
%38 = add nsw i32 %37, 1
%39 = call i32 @mpf_mul_ui(i32 %34, i32 %35, i32 %38)
%40 = load i32, i32* %5
%41 = load i32, i32* %4
%42 = load i32, i32* %5
%43 = call i32 @mpf_div(i32 %40, i32 %41, i32 %42)
%44 = load i32, i32* %3
%45 = load i32, i32* %3
%46 = load i32, i32* %5
%47 = call i32 @mpf_mul(i32 %44, i32 %45, i32 %46)
br label %48
48: ; preds = %20
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %15
51: ; preds = %15
%52 = load i32, i32* %3
%53 = load i32, i32* %3
%54 = call i32 @mpf_mul_ui(i32 %52, i32 %53, i32 2)
%55 = load i32, i32* @stdout
%56 = load i32, i32* %3
%57 = call i32 @mpf_out_str(i32 %55, i32 10, i32 0, i32 %56)
%58 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
define void @wallis(i32 %0) {
%2 = tail call i32 @mpf_init2(i32 undef, i32 1024)
%3 = tail call i32 @mpf_init2(i32 undef, i32 1024)
%4 = tail call i32 @mpf_init2(i32 undef, i32 1024)
%5 = tail call i32 @mpf_set_ui(i32 undef, i32 1)
%6 = icmp slt i32 %0, 2
br i1 %6, label %22, label %7
7: ; preds = %1
%8 = lshr i32 %0, 1
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ %20, %9 ], [ 1, %7 ]
%11 = shl nuw nsw i32 %10, 1
%12 = tail call i32 @mpf_set_d(i32 undef, i32 %11)
%13 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%14 = add nsw i32 %11, -1
%15 = tail call i32 @mpf_set_si(i32 undef, i32 %14)
%16 = or i32 %11, 1
%17 = tail call i32 @mpf_mul_ui(i32 undef, i32 undef, i32 %16)
%18 = tail call i32 @mpf_div(i32 undef, i32 undef, i32 undef)
%19 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%20 = add nuw nsw i32 %10, 1
%21 = icmp eq i32 %10, %8
br i1 %21, label %22, label %9
22: ; preds = %9, %1
%23 = tail call i32 @mpf_mul_ui(i32 undef, i32 undef, i32 2)
%24 = load i32, i32* @stdout
%25 = tail call i32 @mpf_out_str(i32 %24, i32 10, i32 0, i32 undef)
%26 = tail call i32 @putchar(i32 10)
ret void
}