#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
char *strdup(char *);
char **fizz_buzz(int n, int *returnSize) {
  int i;
  char **vec = NULL;
  char buf[5];
  vec = (char **)malloc(sizeof(char *) * n);
  for (i = 1; i <= n; i++) {
    if ((i % 3 != 0) && (i % 5 != 0)) {
      snprintf(buf, sizeof(buf) - 1, "%d", i);
      vec[i - 1] = strdup(buf);
    } else if (i % 3 == 0) {
      if (i % 5 == 0) {
        vec[i - 1] = strdup("FizzBuzz");
      } else {
        vec[i - 1] = strdup("Fizz");
      }
    } else {
      vec[i - 1] = strdup("Buzz");
    }
  }
  *returnSize = n;
  return vec;
}


x86 assembly (clang, -O0):
<fizz_buzz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1279 <fizz_buzz+0x149>
mov    -0x14(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11cf <fizz_buzz+0x9f>
mov    -0x14(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11cf <fizz_buzz+0x9f>
lea    -0x25(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x4,%esi
lea    0xe58(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x25(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    1266 <fizz_buzz+0x136>
mov    -0x14(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1241 <fizz_buzz+0x111>
mov    -0x14(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    121c <fizz_buzz+0xec>
lea    0xe05(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    123c <fizz_buzz+0x10c>
lea    0xde9(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    1261 <fizz_buzz+0x131>
lea    0xdbf(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    1266 <fizz_buzz+0x136>
jmp    126b <fizz_buzz+0x13b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1161 <fizz_buzz+0x31>
mov    -0x4(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fizz_buzz>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x8(%rsp)
mov    %edi,%ebx
lea    0x0(,%rbx,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r12
mov    %rbx,(%rsp)
test   %ebx,%ebx
jle    11f8 <fizz_buzz+0xc8>
mov    (%rsp),%rax
lea    0x1(%rax),%r13d
mov    $0x1,%ebx
mov    $0xcccccccd,%r15d
mov    $0xaaaaaaab,%ebp
lea    0x13(%rsp),%r14
jmp    11ac <fizz_buzz+0x7c>
nop
mov    %r14,%rdi
mov    $0x4,%esi
lea    0xe71(%rip),%rdx
mov    %ebx,%ecx
call   1030 <snprintf@plt>
mov    %r14,%rdi
call   1050 <strdup@plt>
mov    %rax,-0x8(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
je     11f8 <fizz_buzz+0xc8>
mov    %ebx,%eax
mov    %rax,%rcx
imul   %r15,%rcx
shr    $0x22,%rcx
lea    (%rcx,%rcx,4),%ecx
imul   %rbp,%rax
shr    $0x21,%rax
lea    (%rax,%rax,2),%edx
mov    %ebx,%eax
sub    %ecx,%eax
mov    %ebx,%ecx
sub    %edx,%ecx
je     11d5 <fizz_buzz+0xa5>
test   %eax,%eax
jne    1180 <fizz_buzz+0x50>
test   %ecx,%ecx
je     11e2 <fizz_buzz+0xb2>
lea    0xe27(%rip),%rdi
jmp    1199 <fizz_buzz+0x69>
test   %eax,%eax
je     11ef <fizz_buzz+0xbf>
lea    0xe1f(%rip),%rdi
jmp    1199 <fizz_buzz+0x69>
lea    0xe0d(%rip),%rdi
jmp    1199 <fizz_buzz+0x69>
mov    0x8(%rsp),%rax
mov    (%rsp),%rcx
mov    %ecx,(%rax)
mov    %r12,%rax
add    $0x18,%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 = [9 x i8] c"FizzBuzz\00"
@.str.2 = [5 x i8] c"Fizz\00"
@.str.3 = [5 x i8] c"Buzz\00"
define i8** @fizz_buzz(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca [5 x i8]
store i32 %0, i32* %3
store i32* %1, i32** %4
store i8** null, i8*** %6
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = mul i64 8, %9
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i8**
store i8** %13, i8*** %6
store i32 1, i32* %5
br label %14
14: ; preds = %69, %2
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %72
18: ; preds = %14
%19 = load i32, i32* %5
%20 = srem i32 %19, 3
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %37
22: ; preds = %18
%23 = load i32, i32* %5
%24 = srem i32 %23, 5
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %22
%27 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%28 = load i32, i32* %5
%29 = call i32 @snprintf(i8* %27, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%31 = call i8* @strdup(i8* %30)
%32 = load i8**, i8*** %6
%33 = load i32, i32* %5
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %32, i64 %35
store i8* %31, i8** %36
br label %68
37: ; preds = %22, %18
%38 = load i32, i32* %5
%39 = srem i32 %38, 3
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %60
41: ; preds = %37
%42 = load i32, i32* %5
%43 = srem i32 %42, 5
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %52
45: ; preds = %41
%46 = call i8* @strdup(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%47 = load i8**, i8*** %6
%48 = load i32, i32* %5
%49 = sub nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %47, i64 %50
store i8* %46, i8** %51
br label %59
52: ; preds = %41
%53 = call i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%54 = load i8**, i8*** %6
%55 = load i32, i32* %5
%56 = sub nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %54, i64 %57
store i8* %53, i8** %58
br label %59
59: ; preds = %52, %45
br label %67
60: ; preds = %37
%61 = call i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%62 = load i8**, i8*** %6
%63 = load i32, i32* %5
%64 = sub nsw i32 %63, 1
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %62, i64 %65
store i8* %61, i8** %66
br label %67
67: ; preds = %60, %59
br label %68
68: ; preds = %67, %26
br label %69
69: ; preds = %68
%70 = load i32, i32* %5
%71 = add nsw i32 %70, 1
store i32 %71, i32* %5
br label %14
72: ; preds = %14
%73 = load i32, i32* %3
%74 = load i32*, i32** %4
store i32 %73, i32* %74
%75 = load i8**, i8*** %6
ret i8** %75
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"FizzBuzz\00"
@.str.2 = [5 x i8] c"Fizz\00"
@.str.3 = [5 x i8] c"Buzz\00"
define i8** @fizz_buzz(i32 %0, i32* nocapture writeonly %1) {
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%5 = shl i32 %0, 3
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8**
%8 = icmp slt i32 %0, 1
br i1 %8, label %37, label %9
9: ; preds = %2
%10 = add nuw i32 %0, 1
%11 = zext i32 %10 to i64
br label %12
12: ; preds = %9, %31
%13 = phi i64 [ 1, %9 ], [ %35, %31 ]
%14 = trunc i64 %13 to i32
%15 = urem i32 %14, 3
%16 = icmp eq i32 %15, 0
%17 = urem i32 %14, 5
%18 = icmp eq i32 %17, 0
%19 = or i1 %16, %18
br i1 %19, label %23, label %20
20: ; preds = %12
%21 = call i32 @snprintf(i8* %4, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %14)
%22 = call i8* @strdup(i8* %4)
br label %31
23: ; preds = %12
br i1 %16, label %24, label %29
24: ; preds = %23
br i1 %18, label %25, label %27
25: ; preds = %24
%26 = call dereferenceable_or_null(9) i8* @strdup(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %31
27: ; preds = %24
%28 = call dereferenceable_or_null(5) i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %31
29: ; preds = %23
%30 = call dereferenceable_or_null(5) i8* @strdup(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %20, %25, %27, %29
%32 = phi i8* [ %22, %20 ], [ %26, %25 ], [ %28, %27 ], [ %30, %29 ]
%33 = add nsw i64 %13, -1
%34 = getelementptr inbounds i8*, i8** %7, i64 %33
store i8* %32, i8** %34
%35 = add nuw nsw i64 %13, 1
%36 = icmp eq i64 %35, %11
br i1 %36, label %37, label %12
37: ; preds = %31, %2
store i32 %0, i32* %1
ret i8** %7
}