#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(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
scalar_t__ mpz_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int mpz_cmp_ui(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_mod_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_set(int /*<<< orphan*/, int /*<<< orphan*/);
int main() {
  mpz_t max;
  mpz_t a;
  mpz_t b;
  mpz_t c;
  mpz_init(c);
  mpz_init_set_ui(a, 1);
  mpz_init_set_ui(b, 2);
  mpz_init_set_ui(max, 4000000);
  mpz_t count;
  mpz_t mod;
  mpz_init(mod);
  mpz_init_set_ui(count, 2);
  while (mpz_cmp(b, max) < 0) {
    mpz_mod_ui(mod, b, 2);
    if (mpz_cmp_ui(mod, 0) == 1) {
      mpz_add(count, count, b);
    }
    gmp_printf("%Zd\n", a);
    mpz_add(c, a, b);
    mpz_set(a, b);
    mpz_set(b, c);
  }
  gmp_printf("%Zd\n%Zd\n", a, b);
  gmp_printf("The count is %Zd\n", count);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0xc(%rbp),%edi
mov    $0x1,%esi
call   1080 <mpz_init_set_ui@plt>
mov    -0x10(%rbp),%edi
mov    $0x2,%esi
call   1080 <mpz_init_set_ui@plt>
mov    -0x8(%rbp),%edi
mov    $0x3d0900,%esi
call   1080 <mpz_init_set_ui@plt>
mov    -0x1c(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x18(%rbp),%edi
mov    $0x2,%esi
call   1080 <mpz_init_set_ui@plt>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1090 <mpz_cmp@plt>
cmp    $0x0,%rax
jge    1253 <main+0xd3>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    $0x2,%edx
call   1040 <mpz_mod_ui@plt>
mov    -0x1c(%rbp),%edi
xor    %esi,%esi
call   1070 <mpz_cmp_ui@plt>
cmp    $0x1,%eax
jne    1219 <main+0x99>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1060 <mpz_add@plt>
mov    -0xc(%rbp),%esi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   10a0 <gmp_printf@plt>
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1060 <mpz_add@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <mpz_set@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <mpz_set@plt>
jmp    11d3 <main+0x53>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   10a0 <gmp_printf@plt>
mov    -0x18(%rbp),%esi
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   10a0 <gmp_printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
call   1050 <mpz_init@plt>
mov    $0x1,%esi
call   1080 <mpz_init_set_ui@plt>
mov    $0x2,%esi
call   1080 <mpz_init_set_ui@plt>
mov    $0x3d0900,%esi
call   1080 <mpz_init_set_ui@plt>
call   1050 <mpz_init@plt>
mov    $0x2,%esi
call   1080 <mpz_init_set_ui@plt>
call   1090 <mpz_cmp@plt>
test   %rax,%rax
js     11dd <main+0x5d>
lea    0xe3c(%rip),%rdi
xor    %eax,%eax
call   10a0 <gmp_printf@plt>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   10a0 <gmp_printf@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe20(%rip),%rbx
jmp    1213 <main+0x93>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %eax,%eax
call   10a0 <gmp_printf@plt>
call   1060 <mpz_add@plt>
call   1030 <mpz_set@plt>
call   1030 <mpz_set@plt>
call   1090 <mpz_cmp@plt>
test   %rax,%rax
jns    11bd <main+0x3d>
mov    $0x2,%edx
call   1040 <mpz_mod_ui@plt>
xor    %esi,%esi
call   1070 <mpz_cmp_ui@plt>
cmp    $0x1,%eax
jne    11f0 <main+0x70>
call   1060 <mpz_add@plt>
jmp    11f0 <main+0x70>

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

LLVM IR (-O2):
@.str = [5 x i8] c"%Zd\0A\00"
@.str.1 = [9 x i8] c"%Zd\0A%Zd\0A\00"
@.str.2 = [18 x i8] c"The count is %Zd\0A\00"
define i32 @main() {
%1 = tail call i32 @mpz_init(i32 undef)
%2 = tail call i32 @mpz_init_set_ui(i32 undef, i32 1)
%3 = tail call i32 @mpz_init_set_ui(i32 undef, i32 2)
%4 = tail call i32 @mpz_init_set_ui(i32 undef, i32 4000000)
%5 = tail call i32 @mpz_init(i32 undef)
%6 = tail call i32 @mpz_init_set_ui(i32 undef, i32 2)
%7 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %0, %15
%10 = tail call i32 @mpz_mod_ui(i32 undef, i32 undef, i32 2)
%11 = tail call i32 @mpz_cmp_ui(i32 undef, i32 0)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 @mpz_add(i32 undef, i32 undef, i32 undef)
br label %15
15: ; preds = %13, %9
%16 = tail call i32 (i8*, i32, ...) @gmp_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 undef)
%17 = tail call i32 @mpz_add(i32 undef, i32 undef, i32 undef)
%18 = tail call i32 @mpz_set(i32 undef, i32 undef)
%19 = tail call i32 @mpz_set(i32 undef, i32 undef)
%20 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%21 = icmp slt i64 %20, 0
br i1 %21, label %9, label %22
22: ; preds = %15, %0
%23 = tail call i32 (i8*, i32, ...) @gmp_printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 undef, i32 undef)
%24 = tail call i32 (i8*, i32, ...) @gmp_printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 undef)
ret i32 0
}