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

/* Variables and functions */
scalar_t__ is_prime_mr(size_t);
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  int lastFibNumber = 1;
  int currFibNumber = 2;
  int numPrimesFound = 1;
  int nextFibNumber;
  while (numPrimesFound < 7) {
    nextFibNumber = lastFibNumber + currFibNumber;
    if (is_prime_mr((size_t)nextFibNumber)) {
      numPrimesFound += 1;
    }
    lastFibNumber = currFibNumber;
    currFibNumber = nextFibNumber;
  }
  printf("The %dth fibonacci prime is: %d \n", 7, currFibNumber);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x7,-0x10(%rbp)
jge    1184 <main+0x64>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rdi
call   1030 <is_prime_mr@plt>
cmp    $0x0,%rax
je     1173 <main+0x53>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1144 <main+0x24>
mov    -0xc(%rbp),%edx
lea    0xe72(%rip),%rdi
mov    $0x7,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x2,%ebx
mov    $0x1,%eax
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%r14d
mov    %eax,%ebx
add    %r14d,%ebx
movslq %ebx,%rdi
call   1030 <is_prime_mr@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
mov    %r14d,%eax
cmp    $0x7,%ebp
jb     1140 <main+0x20>
lea    0xe9a(%rip),%rdi
mov    $0x7,%esi
mov    %ebx,%edx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"The %dth fibonacci prime is: %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 2, i32* %3
store i32 1, i32* %4
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 7
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = add nsw i32 %10, %11
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = call i64 @is_prime_mr(i64 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %9
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %20
20: ; preds = %17, %9
%21 = load i32, i32* %3
store i32 %21, i32* %2
%22 = load i32, i32* %5
store i32 %22, i32* %3
br label %6
23: ; preds = %6
%24 = load i32, i32* %3
%25 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 7, i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"The %dth fibonacci prime is: %d \0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 1, %0 ], [ %4, %1 ]
%3 = phi i32 [ 1, %0 ], [ %10, %1 ]
%4 = phi i32 [ 2, %0 ], [ %5, %1 ]
%5 = add nsw i32 %2, %4
%6 = sext i32 %5 to i64
%7 = tail call i64 @is_prime_mr(i64 %6)
%8 = icmp ne i64 %7, 0
%9 = zext i1 %8 to i32
%10 = add nuw nsw i32 %3, %9
%11 = icmp ult i32 %10, 7
br i1 %11, label %1, label %12
12: ; preds = %1
%13 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 7, i32 %5)
ret i32 0
}