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

/* Variables and functions */
int /*<<< orphan*/ GMP_RNDZ;
int /*<<< orphan*/ mpfr_const_log2(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_get_z(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_init2(int /*<<< orphan*/, unsigned long);
int /*<<< orphan*/ mpfr_log(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_mul_2exp(int /*<<< orphan*/, int /*<<< orphan*/,
                                 unsigned long, int /*<<< orphan*/);
int /*<<< orphan*/ mpfr_set_ui(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_cdiv_q_2exp(int /*<<< orphan*/, int /*<<< orphan*/, int);
scalar_t__ mpz_cmp_ui(int /*<<< orphan*/, unsigned long);
int /*<<< orphan*/ mpz_div_ui(int /*<<< orphan*/, int /*<<< orphan*/,
                              unsigned long);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_mul_2exp(int /*<<< orphan*/, int /*<<< orphan*/,
                                unsigned long);
scalar_t__ mpz_tstbit(int /*<<< orphan*/, unsigned long);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  {
    mpfr_t pi;
    mpz_t z;
    unsigned long bits = 1000000;
    unsigned long i, j, prev;
    mpfr_init2(pi, bits);
    mpfr_const_log2(pi, GMP_RNDZ);
    mpfr_mul_2exp(pi, pi, bits - 1, GMP_RNDZ);
    mpz_init(z);
    mpfr_get_z(z, pi, GMP_RNDZ);
    i = bits;
    j = 1;
    prev = 1;
    for (;;) {
      if (mpz_tstbit(z, i)) {
        printf("%lu\n", j - prev);
        prev = j;
      } else {
      }
      if (i == 0)
        break;
      i--;
      j++;
    }
    printf("\n");
    return 0;
  }
  {
    mpz_t total, num, q;
    unsigned long bits = 1000000;
    unsigned long k, den;
    mpz_init_set_ui(total, 0);
    mpz_init_set_ui(num, 1);
    mpz_init(q);
    mpz_mul_2exp(num, num, bits);
    for (k = 0;; k++) {
      den = 2 * k + 1;
      mpz_div_ui(q, num, den);
      mpz_add(total, total, q);
      mpz_cdiv_q_2exp(num, num, 2);
      if (mpz_cmp_ui(num, den) < 0) {
        break;
      }
    }
    return 0;
  }
  {
    mpfr_t ln;
    unsigned long bits = 1000000;
    mpfr_init2(ln, bits);
    mpfr_set_ui(ln, 3, GMP_RNDZ);
    mpfr_log(ln, ln, GMP_RNDZ);
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0xf4240,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1090 <mpfr_init2@plt>
mov    -0x8(%rbp),%edi
mov    0x2e43(%rip),%rax
mov    (%rax),%esi
call   1080 <mpfr_const_log2@plt>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
sub    $0x1,%rdx
mov    0x2e27(%rip),%rax
mov    (%rax),%ecx
call   1070 <mpfr_mul_2exp@plt>
mov    -0xc(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x2e0b(%rip),%rax
mov    (%rax),%edx
call   1040 <mpfr_get_z@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x1,-0x28(%rbp)
movq   $0x1,-0x30(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1030 <mpz_tstbit@plt>
cmp    $0x0,%rax
je     122d <main+0xbd>
mov    -0x28(%rbp),%rsi
sub    -0x30(%rbp),%rsi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1232 <main+0xc2>
jmp    1232 <main+0xc2>
cmpq   $0x0,-0x20(%rbp)
jne    1242 <main+0xd2>
jmp    125f <main+0xef>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11f4 <main+0x84>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0xf4240,%ebx
mov    $0xf4240,%esi
call   10a0 <mpfr_init2@plt>
mov    0x2e42(%rip),%r14
mov    (%r14),%esi
call   1090 <mpfr_const_log2@plt>
mov    (%r14),%ecx
mov    $0xf423f,%edx
call   1080 <mpfr_mul_2exp@plt>
call   1070 <mpz_init@plt>
mov    (%r14),%edx
call   1050 <mpfr_get_z@plt>
mov    $0x1,%r15d
lea    0xe33(%rip),%r14
mov    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rsi
call   1030 <mpz_tstbit@plt>
test   %rax,%rax
je     1200 <main+0x80>
mov    %r15,%rsi
sub    %r12,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%r12
sub    $0x1,%rbx
jb     120c <main+0x8c>
add    $0x1,%r15
jmp    11e0 <main+0x60>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@GMP_RNDZ = global i32 0
@.str = [5 x i8] c"%lu\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i32
%15 = alloca i64
store i32 0, i32* %1
store i64 1000000, i64* %4
%16 = load i32, i32* %2
%17 = load i64, i64* %4
%18 = call i32 @mpfr_init2(i32 %16, i64 %17)
%19 = load i32, i32* %2
%20 = load i32, i32* @GMP_RNDZ
%21 = call i32 @mpfr_const_log2(i32 %19, i32 %20)
%22 = load i32, i32* %2
%23 = load i32, i32* %2
%24 = load i64, i64* %4
%25 = sub i64 %24, 1
%26 = load i32, i32* @GMP_RNDZ
%27 = call i32 @mpfr_mul_2exp(i32 %22, i32 %23, i64 %25, i32 %26)
%28 = load i32, i32* %3
%29 = call i32 @mpz_init(i32 %28)
%30 = load i32, i32* %3
%31 = load i32, i32* %2
%32 = load i32, i32* @GMP_RNDZ
%33 = call i32 @mpfr_get_z(i32 %30, i32 %31, i32 %32)
%34 = load i64, i64* %4
store i64 %34, i64* %5
store i64 1, i64* %6
store i64 1, i64* %7
br label %35
35: ; preds = %51, %0
%36 = load i32, i32* %3
%37 = load i64, i64* %5
%38 = call i64 @mpz_tstbit(i32 %36, i64 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %35
%41 = load i64, i64* %6
%42 = load i64, i64* %7
%43 = sub i64 %41, %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %43)
%45 = load i64, i64* %6
store i64 %45, i64* %7
br label %47
46: ; preds = %35
br label %47
47: ; preds = %46, %40
%48 = load i64, i64* %5
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %47
br label %56
51: ; preds = %47
%52 = load i64, i64* %5
%53 = add i64 %52, -1
store i64 %53, i64* %5
%54 = load i64, i64* %6
%55 = add i64 %54, 1
store i64 %55, i64* %6
br label %35
56: ; preds = %50
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@GMP_RNDZ = global i32 0
@.str = [5 x i8] c"%lu\0A\00"
define i32 @main() {
%1 = tail call i32 @mpfr_init2(i32 undef, i64 1000000)
%2 = load i32, i32* @GMP_RNDZ
%3 = tail call i32 @mpfr_const_log2(i32 undef, i32 %2)
%4 = load i32, i32* @GMP_RNDZ
%5 = tail call i32 @mpfr_mul_2exp(i32 undef, i32 undef, i64 999999, i32 %4)
%6 = tail call i32 @mpz_init(i32 undef)
%7 = load i32, i32* @GMP_RNDZ
%8 = tail call i32 @mpfr_get_z(i32 undef, i32 undef, i32 %7)
br label %9
9: ; preds = %21, %0
%10 = phi i64 [ 1000000, %0 ], [ %22, %21 ]
%11 = phi i64 [ 1, %0 ], [ %23, %21 ]
%12 = phi i64 [ 1, %0 ], [ %19, %21 ]
%13 = tail call i64 @mpz_tstbit(i32 undef, i64 %10)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %9
%16 = sub i64 %11, %12
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %16)
br label %18
18: ; preds = %9, %15
%19 = phi i64 [ %11, %15 ], [ %12, %9 ]
%20 = icmp eq i64 %10, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = add nsw i64 %10, -1
%23 = add nuw nsw i64 %11, 1
br label %9
24: ; preds = %18
%25 = tail call i32 @putchar(i32 10)
ret i32 0
}