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

/* Variables and functions */
int /*<<< orphan*/ gmp_printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_add_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_cdiv_q_2exp(int /*<<< orphan*/, int /*<<< orphan*/, int);
scalar_t__ mpz_cmp_ui(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mul_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_sqrtrem(int /*<<< orphan*/, int /*<<< orphan*/,
                               int /*<<< orphan*/);
int /*<<< orphan*/ mpz_sub_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_ui_pow_ui(int /*<<< orphan*/, int, int);
int main(int argc, char **argv) {
  mpz_t discs;
  mpz_init(discs);
  mpz_ui_pow_ui(discs, 10, 12);
  mpz_t r;
  mpz_init(r);
  mpz_t rem;
  mpz_init(rem);
  for (;; mpz_add_ui(discs, discs, 1)) {
    mpz_sub_ui(r, discs, 1);
    mpz_mul(r, r, discs);
    mpz_mul_ui(r, r, 8);
    mpz_add_ui(r, r, 4);
    mpz_sqrtrem(r, rem, r);
    if (0 == mpz_cmp_ui(rem, 0)) {
      mpz_add_ui(r, r, 2);
      mpz_cdiv_q_2exp(r, r, 2);
      gmp_printf("%Zd\n", r);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x14(%rbp),%edi
mov    $0xa,%esi
mov    $0xc,%edx
call   10c0 <mpz_ui_pow_ui@plt>
mov    -0x18(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x1c(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x1,%edx
call   1070 <mpz_sub_ui@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1060 <mpz_mul@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x8,%edx
call   10b0 <mpz_mul_ui@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x4,%edx
call   1040 <mpz_add_ui@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1090 <mpz_sqrtrem@plt>
mov    -0x1c(%rbp),%edi
xor    %esi,%esi
call   1080 <mpz_cmp_ui@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1278 <main+0xd8>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x2,%edx
call   1040 <mpz_add_ui@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x2,%edx
call   1030 <mpz_cdiv_q_2exp@plt>
mov    -0x18(%rbp),%esi
lea    0xd92(%rip),%rdi
call   10a0 <gmp_printf@plt>
jmp    1292 <main+0xf2>
jmp    127d <main+0xdd>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x1,%edx
call   1040 <mpz_add_ui@plt>
jmp    11e0 <main+0x40>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
call   1050 <mpz_init@plt>
mov    $0xa,%esi
mov    $0xc,%edx
call   10c0 <mpz_ui_pow_ui@plt>
call   1050 <mpz_init@plt>
call   1050 <mpz_init@plt>
nop
mov    $0x1,%edx
call   1070 <mpz_sub_ui@plt>
call   1060 <mpz_mul@plt>
mov    $0x8,%edx
call   10b0 <mpz_mul_ui@plt>
mov    $0x4,%edx
call   1040 <mpz_add_ui@plt>
call   1090 <mpz_sqrtrem@plt>
xor    %esi,%esi
call   1080 <mpz_cmp_ui@plt>
test   %rax,%rax
je     1200 <main+0x60>
mov    $0x1,%edx
call   1040 <mpz_add_ui@plt>
jmp    11c0 <main+0x20>
mov    $0x2,%edx
call   1040 <mpz_add_ui@plt>
mov    $0x2,%edx
call   1030 <mpz_cdiv_q_2exp@plt>
lea    0xde5(%rip),%rdi
call   10a0 <gmp_printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%Zd\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %6
%10 = call i32 @mpz_init(i32 %9)
%11 = load i32, i32* %6
%12 = call i32 @mpz_ui_pow_ui(i32 %11, i32 10, i32 12)
%13 = load i32, i32* %7
%14 = call i32 @mpz_init(i32 %13)
%15 = load i32, i32* %8
%16 = call i32 @mpz_init(i32 %15)
br label %17
17: ; preds = %48, %2
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = call i32 @mpz_sub_ui(i32 %18, i32 %19, i32 1)
%21 = load i32, i32* %7
%22 = load i32, i32* %7
%23 = load i32, i32* %6
%24 = call i32 @mpz_mul(i32 %21, i32 %22, i32 %23)
%25 = load i32, i32* %7
%26 = load i32, i32* %7
%27 = call i32 @mpz_mul_ui(i32 %25, i32 %26, i32 8)
%28 = load i32, i32* %7
%29 = load i32, i32* %7
%30 = call i32 @mpz_add_ui(i32 %28, i32 %29, i32 4)
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = load i32, i32* %7
%34 = call i32 @mpz_sqrtrem(i32 %31, i32 %32, i32 %33)
%35 = load i32, i32* %8
%36 = call i64 @mpz_cmp_ui(i32 %35, i32 0)
%37 = icmp eq i64 0, %36
br i1 %37, label %38, label %47
38: ; preds = %17
%39 = load i32, i32* %7
%40 = load i32, i32* %7
%41 = call i32 @mpz_add_ui(i32 %39, i32 %40, i32 2)
%42 = load i32, i32* %7
%43 = load i32, i32* %7
%44 = call i32 @mpz_cdiv_q_2exp(i32 %42, i32 %43, i32 2)
%45 = load i32, i32* %7
%46 = call i32 @gmp_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %45)
br label %52
47: ; preds = %17
br label %48
48: ; preds = %47
%49 = load i32, i32* %6
%50 = load i32, i32* %6
%51 = call i32 @mpz_add_ui(i32 %49, i32 %50, i32 1)
br label %17
52: ; preds = %38
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%Zd\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @mpz_init(i32 undef)
%4 = tail call i32 @mpz_ui_pow_ui(i32 undef, i32 10, i32 12)
%5 = tail call i32 @mpz_init(i32 undef)
%6 = tail call i32 @mpz_init(i32 undef)
br label %7
7: ; preds = %19, %2
%8 = tail call i32 @mpz_sub_ui(i32 undef, i32 undef, i32 1)
%9 = tail call i32 @mpz_mul(i32 undef, i32 undef, i32 undef)
%10 = tail call i32 @mpz_mul_ui(i32 undef, i32 undef, i32 8)
%11 = tail call i32 @mpz_add_ui(i32 undef, i32 undef, i32 4)
%12 = tail call i32 @mpz_sqrtrem(i32 undef, i32 undef, i32 undef)
%13 = tail call i64 @mpz_cmp_ui(i32 undef, i32 0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %7
%16 = tail call i32 @mpz_add_ui(i32 undef, i32 undef, i32 2)
%17 = tail call i32 @mpz_cdiv_q_2exp(i32 undef, i32 undef, i32 2)
%18 = tail call i32 @gmp_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 undef)
ret i32 0
19: ; preds = %7
%20 = tail call i32 @mpz_add_ui(i32 undef, i32 undef, i32 1)
br label %7
}