#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 /*<<< orphan*/ printf(char *, ...);
void fizzbuzz(int limit) {
  int i;
  for (i = 0; i < limit; i++) {
    if (i % 3 == 0 && i % 5 == 0) {
      printf("FizzBuzz\n");
    } else if (i % 3 == 0) {
      printf("Fizz\n");
    } else if (i % 5 == 0) {
      printf("Buzz\n");
    } else {
      printf("%d\n", i);
    }
  }
}


x86 assembly (clang, -O0):
<fizzbuzz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e5 <fizzbuzz+0xd5>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1169 <fizzbuzz+0x59>
mov    -0x8(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1169 <fizzbuzz+0x59>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d2 <fizzbuzz+0xc2>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1190 <fizzbuzz+0x80>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cd <fizzbuzz+0xbd>
mov    -0x8(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11b7 <fizzbuzz+0xa7>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c8 <fizzbuzz+0xb8>
mov    -0x8(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cd <fizzbuzz+0xbd>
jmp    11d2 <fizzbuzz+0xc2>
jmp    11d7 <fizzbuzz+0xc7>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <fizzbuzz+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fizzbuzz>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11c2 <fizzbuzz+0xa2>
mov    %edi,%ebx
mov    $0xaaaaaaab,%r12d
mov    $0xcccccccd,%r15d
lea    0xec1(%rip),%r14
lea    0xeb1(%rip),%r13
xor    %ebp,%ebp
jmp    116f <fizzbuzz+0x4f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
je     11c2 <fizzbuzz+0xa2>
mov    %ebp,%eax
mov    %rax,%rcx
imul   %r12,%rcx
shr    $0x21,%rcx
lea    (%rcx,%rcx,2),%edx
imul   %r15,%rax
shr    $0x22,%rax
lea    (%rax,%rax,4),%esi
mov    %ebp,%ecx
sub    %edx,%ecx
mov    %ebp,%eax
sub    %esi,%eax
mov    %ecx,%edx
or     %eax,%edx
je     1160 <fizzbuzz+0x40>
test   %ecx,%ecx
je     11b0 <fizzbuzz+0x90>
test   %eax,%eax
je     11b9 <fizzbuzz+0x99>
mov    %r13,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1168 <fizzbuzz+0x48>
xchg   %ax,%ax
lea    0xe4d(%rip),%rdi
jmp    1163 <fizzbuzz+0x43>
lea    0xe4d(%rip),%rdi
jmp    1163 <fizzbuzz+0x43>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"FizzBuzz\0A\00"
@.str.1 = [6 x i8] c"Fizz\0A\00"
@.str.2 = [6 x i8] c"Buzz\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define void @fizzbuzz(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %36, %1
%5 = load i32, i32* %3
%6 = load i32, i32* %2
%7 = icmp slt i32 %5, %6
br i1 %7, label %8, label %39
8: ; preds = %4
%9 = load i32, i32* %3
%10 = srem i32 %9, 3
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %8
%13 = load i32, i32* %3
%14 = srem i32 %13, 5
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %35
18: ; preds = %12, %8
%19 = load i32, i32* %3
%20 = srem i32 %19, 3
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %34
24: ; preds = %18
%25 = load i32, i32* %3
%26 = srem i32 %25, 5
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %33
30: ; preds = %24
%31 = load i32, i32* %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %28
br label %34
34: ; preds = %33, %22
br label %35
35: ; preds = %34, %16
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %4
39: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str.3 = [4 x i8] c"%d\0A\00"
@str = [5 x i8] c"Buzz\00"
@str.4 = [5 x i8] c"Fizz\00"
@str.5 = [9 x i8] c"FizzBuzz\00"
define void @fizzbuzz(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %24
3: ; preds = %1, %21
%4 = phi i32 [ %22, %21 ], [ 0, %1 ]
%5 = urem i32 %4, 3
%6 = urem i32 %4, 5
%7 = icmp eq i32 %6, 0
%8 = or i32 %5, %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.5, i64 0, i64 0))
br label %21
12: ; preds = %3
%13 = icmp eq i32 %5, 0
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.4, i64 0, i64 0))
br label %21
16: ; preds = %12
br i1 %7, label %17, label %19
17: ; preds = %16
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %21
19: ; preds = %16
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %4)
br label %21
21: ; preds = %10, %17, %19, %14
%22 = add nuw nsw i32 %4, 1
%23 = icmp eq i32 %22, %0
br i1 %23, label %24, label %3
24: ; preds = %21, %1
ret void
}