#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);
    if (!(a % (times / 200)))
      printf("%d\n", a * 2 / (times / 100));
  }
  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     12b2 <wallis+0x122>
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
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xc8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    129f <wallis+0x10f>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a4 <wallis+0x114>
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    0x2d17(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%ecx
mov    $0xa,%esi
xor    %edx,%edx
call   1080 <mpf_out_str@plt>
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wallis>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r14d
mov    $0x400,%esi
call   10c0 <mpf_init2@plt>
mov    $0x400,%esi
call   10c0 <mpf_init2@plt>
mov    $0x400,%esi
call   10c0 <mpf_init2@plt>
mov    $0x1,%r15d
mov    $0x1,%esi
call   1070 <mpf_set_ui@plt>
cmp    $0x2,%r14d
jge    1219 <wallis+0x79>
mov    $0x2,%edx
call   1080 <mpf_mul_ui@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    $0xa,%esi
xor    %edx,%edx
call   1090 <mpf_out_str@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
mov    %r14d,%eax
shr    %r14d
imul   $0x51eb851f,%rax,%r12
mov    %r12,%r13
shr    $0x26,%r13
shr    $0x25,%r12
neg    %r14d
mov    $0x3,%ebx
jmp    1258 <wallis+0xb8>
nopl   0x0(%rax,%rax,1)
lea    (%r14,%r15,1),%eax
add    $0x1,%eax
mov    %r15d,%ecx
add    $0x1,%ecx
add    $0x2,%ebx
mov    %ecx,%r15d
cmp    $0x1,%eax
je     11e2 <wallis+0x42>
lea    -0x1(%rbx),%ebp
mov    %ebp,%esi
call   1060 <mpf_set_d@plt>
call   10a0 <mpf_mul@plt>
lea    -0x2(%rbx),%esi
call   1050 <mpf_set_si@plt>
mov    %ebx,%edx
call   1080 <mpf_mul_ui@plt>
call   10b0 <mpf_div@plt>
call   10a0 <mpf_mul@plt>
mov    %r15d,%eax
xor    %edx,%edx
div    %r13d
test   %edx,%edx
jne    1240 <wallis+0xa0>
mov    %ebp,%eax
xor    %edx,%edx
div    %r12d
lea    0xd66(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1240 <wallis+0xa0>

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@stdout = global i32 0
@.str.1 = [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 = %61, %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 %64
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)
%48 = load i32, i32* %6
%49 = load i32, i32* %2
%50 = sdiv i32 %49, 200
%51 = srem i32 %48, %50
%52 = icmp ne i32 %51, 0
br i1 %52, label %60, label %53
53: ; preds = %20
%54 = load i32, i32* %6
%55 = mul nsw i32 %54, 2
%56 = load i32, i32* %2
%57 = sdiv i32 %56, 100
%58 = sdiv i32 %55, %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %53, %20
br label %61
61: ; preds = %60
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
br label %15
64: ; preds = %15
%65 = load i32, i32* %3
%66 = load i32, i32* %3
%67 = call i32 @mpf_mul_ui(i32 %65, i32 %66, i32 2)
%68 = load i32, i32* @stdout
%69 = load i32, i32* %3
%70 = call i32 @mpf_out_str(i32 %68, i32 10, i32 0, i32 %69)
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@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 %30, label %7
7: ; preds = %1
%8 = lshr i32 %0, 1
%9 = udiv i32 %0, 200
%10 = udiv i32 %0, 100
br label %11
11: ; preds = %7, %27
%12 = phi i32 [ 1, %7 ], [ %28, %27 ]
%13 = shl nuw nsw i32 %12, 1
%14 = tail call i32 @mpf_set_d(i32 undef, i32 %13)
%15 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%16 = add nsw i32 %13, -1
%17 = tail call i32 @mpf_set_si(i32 undef, i32 %16)
%18 = or i32 %13, 1
%19 = tail call i32 @mpf_mul_ui(i32 undef, i32 undef, i32 %18)
%20 = tail call i32 @mpf_div(i32 undef, i32 undef, i32 undef)
%21 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%22 = urem i32 %12, %9
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %11
%25 = udiv i32 %13, %10
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %11, %24
%28 = add nuw nsw i32 %12, 1
%29 = icmp eq i32 %12, %8
br i1 %29, label %30, label %11
30: ; preds = %27, %1
%31 = tail call i32 @mpf_mul_ui(i32 undef, i32 undef, i32 2)
%32 = load i32, i32* @stdout
%33 = tail call i32 @mpf_out_str(i32 %32, i32 10, i32 0, i32 undef)
%34 = tail call i32 @putchar(i32 10)
ret void
}