#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 */
int isPrime(long long);
int /*<<< orphan*/ printf(char *, ...);
void fibonacci(unsigned long long n) {
  long long a = 0, b = 1, c = 0;
  printf("%llu\n", a);
  printf("%llu\n", b);
  for (long long i = 2; i < (n + 1); i++) {
    c = a + b;
    a = b;
    b = c;
    if (c % 3 == 0 && c % 5 == 0) {
      printf("FizzBuzz\n");
    } else if (c % 3 == 0) {
      printf("Buzz\n");
    } else if (c % 5 == 0) {
      printf("Fizz\n");
    } else if (isPrime(c) == 1) {
      printf("BuzzFizz\n");
    } else {
      printf("%llu\n", c);
    }
  }
}


x86 assembly (clang, -O0):
<fibonacci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x1,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x2,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jae    1296 <fibonacci+0x176>
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    $0x3,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    11e4 <fibonacci+0xc4>
mov    -0x20(%rbp),%rax
mov    $0x5,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    11e4 <fibonacci+0xc4>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1280 <fibonacci+0x160>
mov    -0x20(%rbp),%rax
mov    $0x3,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    120f <fibonacci+0xef>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127b <fibonacci+0x15b>
mov    -0x20(%rbp),%rax
mov    $0x5,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    123a <fibonacci+0x11a>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1276 <fibonacci+0x156>
mov    -0x20(%rbp),%rdi
call   1040 <isPrime@plt>
cmp    $0x1,%eax
jne    125f <fibonacci+0x13f>
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1271 <fibonacci+0x151>
mov    -0x20(%rbp),%rsi
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1276 <fibonacci+0x156>
jmp    127b <fibonacci+0x15b>
jmp    1280 <fibonacci+0x160>
jmp    1285 <fibonacci+0x165>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1170 <fibonacci+0x50>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fibonacci>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xebb(%rip),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
mov    $0x1,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x2(%r14),%rax
cmp    $0xfffffffffffffffc,%rax
ja     1253 <fibonacci+0x123>
add    $0xffffffffffffffff,%r14
movabs $0x5555555555555556,%rbp
55 55 55
movabs $0x6666666666666667,%r13
66 66 66
lea    0xe7d(%rip),%r15
xor    %r12d,%r12d
jmp    11b2 <fibonacci+0x82>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <puts@plt>
add    $0xffffffffffffffff,%r14
je     1253 <fibonacci+0x123>
mov    %r12,%rax
mov    %rbx,%r12
mov    %rax,%rbx
add    %r12,%rbx
mov    %rbx,%rax
imul   %rbp
mov    %rdx,%rax
shr    $0x3f,%rax
add    %rdx,%rax
lea    (%rax,%rax,2),%rax
mov    %rbx,%rcx
sub    %rax,%rcx
mov    %rbx,%rax
imul   %r13
mov    %rdx,%rax
shr    $0x3f,%rax
sar    %rdx
add    %rax,%rdx
lea    (%rdx,%rdx,4),%rdx
mov    %rbx,%rax
sub    %rdx,%rax
mov    %rcx,%rdx
or     %rax,%rdx
je     11a0 <fibonacci+0x70>
test   %rcx,%rcx
je     1220 <fibonacci+0xf0>
test   %rax,%rax
je     122c <fibonacci+0xfc>
mov    %rbx,%rdi
call   1050 <isPrime@plt>
cmp    $0x1,%eax
jne    1238 <fibonacci+0x108>
lea    0xdeb(%rip),%rdi
jmp    11a3 <fibonacci+0x73>
nopl   (%rax)
lea    0xdec(%rip),%rdi
jmp    11a3 <fibonacci+0x73>
lea    0xdd7(%rip),%rdi
jmp    11a3 <fibonacci+0x73>
lea    0xdc1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffffffffffff,%r14
jne    11b2 <fibonacci+0x82>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%llu\0A\00"
@.str.1 = [10 x i8] c"FizzBuzz\0A\00"
@.str.2 = [6 x i8] c"Buzz\0A\00"
@.str.3 = [6 x i8] c"Fizz\0A\00"
@.str.4 = [10 x i8] c"BuzzFizz\0A\00"
define void @fibonacci(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %2
store i64 0, i64* %3
store i64 1, i64* %4
store i64 0, i64* %5
%7 = load i64, i64* %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %7)
%9 = load i64, i64* %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %9)
store i64 2, i64* %6
br label %11
11: ; preds = %56, %1
%12 = load i64, i64* %6
%13 = load i64, i64* %2
%14 = add i64 %13, 1
%15 = icmp ult i64 %12, %14
br i1 %15, label %16, label %59
16: ; preds = %11
%17 = load i64, i64* %3
%18 = load i64, i64* %4
%19 = add nsw i64 %17, %18
store i64 %19, i64* %5
%20 = load i64, i64* %4
store i64 %20, i64* %3
%21 = load i64, i64* %5
store i64 %21, i64* %4
%22 = load i64, i64* %5
%23 = srem i64 %22, 3
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %16
%26 = load i64, i64* %5
%27 = srem i64 %26, 5
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %55
31: ; preds = %25, %16
%32 = load i64, i64* %5
%33 = srem i64 %32, 3
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %54
37: ; preds = %31
%38 = load i64, i64* %5
%39 = srem i64 %38, 5
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %53
43: ; preds = %37
%44 = load i64, i64* %5
%45 = call i32 @isPrime(i64 %44)
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %52
49: ; preds = %43
%50 = load i64, i64* %5
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %50)
br label %52
52: ; preds = %49, %47
br label %53
53: ; preds = %52, %41
br label %54
54: ; preds = %53, %35
br label %55
55: ; preds = %54, %29
br label %56
56: ; preds = %55
%57 = load i64, i64* %6
%58 = add nsw i64 %57, 1
store i64 %58, i64* %6
br label %11
59: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%llu\0A\00"
@str = [9 x i8] c"BuzzFizz\00"
@str.5 = [5 x i8] c"Fizz\00"
@str.6 = [5 x i8] c"Buzz\00"
@str.7 = [9 x i8] c"FizzBuzz\00"
define void @fibonacci(i64 %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 0)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 1)
%4 = add i64 %0, -2
%5 = icmp ult i64 %4, -3
br i1 %5, label %7, label %6
6: ; preds = %33, %1
ret void
7: ; preds = %1, %33
%8 = phi i64 [ %34, %33 ], [ 2, %1 ]
%9 = phi i64 [ %11, %33 ], [ 1, %1 ]
%10 = phi i64 [ %9, %33 ], [ 0, %1 ]
%11 = add nsw i64 %9, %10
%12 = srem i64 %11, 3
%13 = srem i64 %11, 5
%14 = icmp eq i64 %13, 0
%15 = or i64 %12, %13
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %7
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0))
br label %33
19: ; preds = %7
%20 = icmp eq i64 %12, 0
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.6, i64 0, i64 0))
br label %33
23: ; preds = %19
br i1 %14, label %24, label %26
24: ; preds = %23
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.5, i64 0, i64 0))
br label %33
26: ; preds = %23
%27 = tail call i32 @isPrime(i64 %11)
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %33
31: ; preds = %26
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %11)
br label %33
33: ; preds = %17, %24, %31, %29, %21
%34 = add nuw i64 %8, 1
%35 = icmp eq i64 %8, %0
br i1 %35, label %6, label %7
}