void fizz_buzz(i) {
  int fizz_buzzed = 0;
  if (i % 3 == 0) {
    fizz();
    fizz_buzzed = 1;
  }
  if (i % 5 == 0) {
    buzz();
    fizz_buzzed = 1;
  }
  if (!fizz_buzzed) {
    printf("%i", i);
  }
  puts("\n");
}


x86 assembly (clang, -O0):
<fizz_buzz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1174 <fizz_buzz+0x34>
mov    $0x0,%al
call   1050 <fizz@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1196 <fizz_buzz+0x56>
mov    $0x0,%al
call   1060 <buzz@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11b1 <fizz_buzz+0x71>
mov    -0x4(%rbp),%esi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fizz_buzz>:
push   %rbx
mov    %edi,%ebx
imul   $0xaaaaaaab,%edi,%eax
add    $0x2aaaaaaa,%eax
cmp    $0x55555554,%eax
jbe    1179 <fizz_buzz+0x39>
imul   $0xcccccccd,%ebx,%eax
add    $0x19999999,%eax
cmp    $0x33333332,%eax
jbe    1192 <fizz_buzz+0x52>
lea    0xe92(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1199 <fizz_buzz+0x59>
xor    %eax,%eax
call   1050 <fizz@plt>
imul   $0xcccccccd,%ebx,%eax
add    $0x19999999,%eax
cmp    $0x33333333,%eax
jae    1199 <fizz_buzz+0x59>
xor    %eax,%eax
call   1060 <buzz@plt>
lea    0xe63(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @fizz_buzz(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = srem i32 %4, 3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 (...) @fizz()
store i32 1, i32* %3
br label %9
9: ; preds = %7, %1
%10 = load i32, i32* %2
%11 = srem i32 %10, 5
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 (...) @buzz()
store i32 1, i32* %3
br label %15
15: ; preds = %13, %9
%16 = load i32, i32* %3
%17 = icmp ne i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %2
%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, %15
%22 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @fizz_buzz(i32 %0) {
%2 = srem i32 %0, 3
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = tail call i32 (...) @fizz()
%6 = srem i32 %0, 5
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %15
8: ; preds = %1
%9 = srem i32 %0, 5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8, %4
%12 = tail call i32 (...) @buzz()
br label %15
13: ; preds = %8
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %15
15: ; preds = %4, %11, %13
%16 = tail call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}