#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 fizzbuzz2(int n) {
  int m3 = 3, m5 = 5;
  for (int i = 1; i <= n; i++) {
    if (i != m3 && i != m5)
      printf("%d", i);
    if (i == m3) {
      printf("fizz");
      m3 += 3;
    }
    if (i == m5) {
      printf("buzz");
      m5 += 5;
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<fizzbuzz2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11c7 <fizzbuzz2+0xb7>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     1165 <fizzbuzz2+0x55>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1165 <fizzbuzz2+0x55>
mov    -0x10(%rbp),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1188 <fizzbuzz2+0x78>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11ab <fizzbuzz2+0x9b>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0xc(%rbp)
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1130 <fizzbuzz2+0x20>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fizzbuzz2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11c5 <fizzbuzz2+0xa5>
mov    %edi,%r13d
neg    %r13d
mov    $0x3,%r14d
mov    $0x5,%r15d
mov    $0x4,%ebx
lea    0xeaf(%rip),%r12
jmp    117d <fizzbuzz2+0x5d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    (%rbx,%r13,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x4,%eax
je     11c5 <fizzbuzz2+0xa5>
lea    -0x3(%rbx),%ebp
cmp    %r14d,%ebp
je     1196 <fizzbuzz2+0x76>
cmp    %r15d,%ebp
je     1196 <fizzbuzz2+0x76>
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r14d,%ebp
jne    11ac <fizzbuzz2+0x8c>
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%r14d
cmp    %r15d,%ebp
jne    1160 <fizzbuzz2+0x40>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x2(%rbx),%r15d
jmp    1160 <fizzbuzz2+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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