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

/* Variables and functions */
scalar_t__ EOF;
double GetCoefficient(double *, int, int, int, unsigned int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, double *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ memset(double **, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, unsigned int, double);
int main(void) {
  double spectrum[8192];
  FILE *sampleFile;
  int i = 0;
  unsigned int coeff;
  double mfcc_result;
  memset(&spectrum, 0, sizeof(spectrum));
  sampleFile = fopen("sample.dat", "rb");
  while (fscanf(sampleFile, "%lf", &spectrum[i]) != EOF) {
    i++;
  }
  fclose(sampleFile);
  for (coeff = 0; coeff < 13; coeff++) {
    mfcc_result = GetCoefficient(spectrum, 44100, 48, 128, coeff);
    printf("%i %f\n", coeff, mfcc_result);
  }
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10030,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1001c(%rbp)
lea    -0x10010(%rbp),%rdi
xor    %esi,%esi
mov    $0x10000,%edx
call   1060 <memset@plt>
lea    0xe5a(%rip),%rdi
lea    0xe5e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10018(%rbp)
mov    -0x10018(%rbp),%rdi
movslq -0x1001c(%rbp),%rax
lea    -0x10010(%rbp),%rdx
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe32(%rip),%rsi
call   1070 <fscanf@plt>
mov    0x2e00(%rip),%rcx
cmp    (%rcx),%rax
je     1205 <main+0x95>
mov    -0x1001c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1001c(%rbp)
jmp    11b9 <main+0x49>
mov    -0x10018(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x10020(%rbp)
cmpl   $0xd,-0x10020(%rbp)
jae    1280 <main+0x110>
lea    -0x10010(%rbp),%rdi
mov    -0x10020(%rbp),%r8d
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
call   1040 <GetCoefficient@plt>
movsd  %xmm0,-0x10028(%rbp)
ff
mov    -0x10020(%rbp),%esi
movsd  -0x10028(%rbp),%xmm0
ff
lea    0xdab(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10020(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10020(%rbp)
jmp    121b <main+0xab>
mov    $0x0,%al
call   1080 <getchar@plt>
xor    %eax,%eax
add    $0x10030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10008,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10000,%edx
call   1060 <memset@plt>
lea    0xe69(%rip),%rdi
lea    0xe6d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
lea    0xe61(%rip),%r15
mov    0x2e34(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
add    $0x8,%rbx
cmp    (%r12),%rax
jne    11c0 <main+0x50>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
xor    %r8d,%r8d
call   1040 <GetCoefficient@plt>
lea    0xe0e(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
mov    $0x1,%r8d
call   1040 <GetCoefficient@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
mov    $0x2,%r8d
call   1040 <GetCoefficient@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
mov    $0x3,%r8d
call   1040 <GetCoefficient@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
mov    $0x4,%r8d
call   1040 <GetCoefficient@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
mov    $0x5,%r8d
call   1040 <GetCoefficient@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
mov    $0x6,%r8d
call   1040 <GetCoefficient@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
mov    $0x7,%r8d
call   1040 <GetCoefficient@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
mov    $0x8,%r8d
call   1040 <GetCoefficient@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
mov    $0x9,%r8d
call   1040 <GetCoefficient@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
mov    $0xa,%r8d
call   1040 <GetCoefficient@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
mov    $0xb,%r8d
call   1040 <GetCoefficient@plt>
mov    %rbx,%rdi
mov    $0xb,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0xac44,%esi
mov    $0x30,%edx
mov    $0x80,%ecx
mov    $0xc,%r8d
call   1040 <GetCoefficient@plt>
mov    %rbx,%rdi
mov    $0xc,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
xor    %eax,%eax
add    $0x10008,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"sample.dat\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [4 x i8] c"%lf\00"
@EOF = global i64 0
@.str.3 = [7 x i8] c"%i %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8192 x double]
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
store i32 0, i32* %1
store i32 0, i32* %4
%7 = bitcast [8192 x double]* %2 to double**
%8 = call i32 @memset(double** %7, i32 0, i32 65536)
%9 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %3
br label %10
10: ; preds = %18, %0
%11 = load i32*, i32** %3
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [8192 x double], [8192 x double]* %2, i64 0, i64 %13
%15 = call i64 @fscanf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %14)
%16 = load i64, i64* @EOF
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %10
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %10
21: ; preds = %10
%22 = load i32*, i32** %3
%23 = call i32 @fclose(i32* %22)
store i32 0, i32* %5
br label %24
24: ; preds = %34, %21
%25 = load i32, i32* %5
%26 = icmp ult i32 %25, 13
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = getelementptr inbounds [8192 x double], [8192 x double]* %2, i64 0, i64 0
%29 = load i32, i32* %5
%30 = call double @GetCoefficient(double* %28, i32 44100, i32 48, i32 128, i32 %29)
store double %30, double* %6
%31 = load i32, i32* %5
%32 = load double, double* %6
%33 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %31, double %32)
br label %34
34: ; preds = %27
%35 = load i32, i32* %5
%36 = add i32 %35, 1
store i32 %36, i32* %5
br label %24
37: ; preds = %24
%38 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"sample.dat\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [4 x i8] c"%lf\00"
@EOF = global i64 0
@.str.3 = [7 x i8] c"%i %f\0A\00"
define i32 @main() {
%1 = alloca [8192 x double]
%2 = bitcast [8192 x double]* %1 to i8*
%3 = bitcast [8192 x double]* %1 to double**
%4 = call i32 @memset(double** %3, i32 0, i32 65536)
%5 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %6, %0
%7 = phi i64 [ %12, %6 ], [ 0, %0 ]
%8 = getelementptr inbounds [8192 x double], [8192 x double]* %1, i64 0, i64 %7
%9 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %8)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
%12 = add nuw i64 %7, 1
br i1 %11, label %13, label %6
13: ; preds = %6
%14 = call i32 @fclose(i32* %5)
%15 = getelementptr inbounds [8192 x double], [8192 x double]* %1, i64 0, i64 0
%16 = call double @GetCoefficient(double* %15, i32 44100, i32 48, i32 128, i32 0)
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 0, double %16)
%18 = call double @GetCoefficient(double* %15, i32 44100, i32 48, i32 128, i32 1)
%19 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 1, double %18)
%20 = call double @GetCoefficient(double* %15, i32 44100, i32 48, i32 128, i32 2)
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 2, double %20)
%22 = call double @GetCoefficient(double* %15, i32 44100, i32 48, i32 128, i32 3)
%23 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 3, double %22)
%24 = call double @GetCoefficient(double* %15, i32 44100, i32 48, i32 128, i32 4)
%25 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 4, double %24)
%26 = call double @GetCoefficient(double* %15, i32 44100, i32 48, i32 128, i32 5)
%27 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 5, double %26)
%28 = call double @GetCoefficient(double* %15, i32 44100, i32 48, i32 128, i32 6)
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6, double %28)
%30 = call double @GetCoefficient(double* %15, i32 44100, i32 48, i32 128, i32 7)
%31 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 7, double %30)
%32 = call double @GetCoefficient(double* %15, i32 44100, i32 48, i32 128, i32 8)
%33 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 8, double %32)
%34 = call double @GetCoefficient(double* %15, i32 44100, i32 48, i32 128, i32 9)
%35 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 9, double %34)
%36 = call double @GetCoefficient(double* %15, i32 44100, i32 48, i32 128, i32 10)
%37 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 10, double %36)
%38 = call double @GetCoefficient(double* %15, i32 44100, i32 48, i32 128, i32 11)
%39 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 11, double %38)
%40 = call double @GetCoefficient(double* %15, i32 44100, i32 48, i32 128, i32 12)
%41 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 12, double %40)
%42 = call i32 (...) @getchar()
ret i32 0
}