#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 */
double M_PI;
float cos(int);
scalar_t__ malloc(int);
float sin(int);
void generate_filter_bank_coefficients(float ***Mr, float ***Mi) {
  float **matrix_r = (float **)malloc(8 * sizeof(float *));
  float **matrix_i = (float **)malloc(8 * sizeof(float *));
  for (unsigned int i = 0; i < 8; i++) {
    matrix_r[i] = (float *)malloc(16 * sizeof(float));
    matrix_i[i] = (float *)malloc(16 * sizeof(float));
    for (unsigned int j = 0; j < 16; j++) {
      matrix_r[i][j] = cos((2 * i + 1) * (j - 4) * (M_PI / 16.0));
      matrix_i[i][j] = sin((2 * i + 1) * (j - 4) * (M_PI / 16.0));
    }
  }
  *Mr = matrix_r;
  *Mi = matrix_i;
}


x86 assembly (clang, -O0):
<generate_filter_bank_coefficients>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x40,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x40,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x8,-0x24(%rbp)
jae    126b <generate_filter_bank_coefficients+0x13b>
mov    $0x40,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    $0x40,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x28(%rbp)
cmpl   $0x10,-0x28(%rbp)
jae    1258 <generate_filter_bank_coefficients+0x128>
mov    -0x24(%rbp),%ecx
mov    %ecx,%eax
lea    0x1(%rax,%rax,1),%eax
mov    -0x28(%rbp),%ecx
add    $0xfffffffc,%ecx
imul   %ecx,%eax
cvtsi2sd %rax,%xmm0
mov    0x2e1c(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe28(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <cos@plt>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x24(%rbp),%ecx
mov    %ecx,%eax
lea    0x1(%rax,%rax,1),%eax
mov    -0x28(%rbp),%ecx
add    $0xfffffffc,%ecx
imul   %ecx,%eax
cvtsi2sd %rax,%xmm0
mov    0x2dce(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xdda(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a4 <generate_filter_bank_coefficients+0x74>
jmp    125d <generate_filter_bank_coefficients+0x12d>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1163 <generate_filter_bank_coefficients+0x33>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_filter_bank_coefficients>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,0x18(%rsp)
mov    %rdi,0x10(%rsp)
mov    $0x40,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
mov    $0x40,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    $0xfffffffc,%r13d
mov    $0x1,%eax
xor    %r14d,%r14d
mov    %eax,0x8(%rsp)
mov    $0x40,%edi
call   1040 <malloc@plt>
mov    %rax,(%r12,%r14,8)
mov    $0x40,%edi
call   1040 <malloc@plt>
mov    %rax,(%r15,%r14,8)
mov    %r13d,0xc(%rsp)
mov    %r12,%rbx
xor    %r12d,%r12d
mov    0x2e46(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13d,%eax
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
movsd  %xmm2,0x20(%rsp)
movsd  0x0(%rbp),%xmm0
movsd  0xe32(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <cos@plt>
mov    (%rbx,%r14,8),%rax
movss  %xmm0,(%rax,%r12,4)
movsd  0x0(%rbp),%xmm0
mulsd  0xe0a(%rip),%xmm0
mulsd  0x20(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
mov    (%r15,%r14,8),%rax
movss  %xmm0,(%rax,%r12,4)
add    $0x1,%r12
add    0x8(%rsp),%r13d
cmp    $0x10,%r12
jne    11b0 <generate_filter_bank_coefficients+0x80>
add    $0x1,%r14
mov    0xc(%rsp),%r13d
add    $0xfffffff8,%r13d
mov    0x8(%rsp),%eax
add    $0x2,%eax
cmp    $0x8,%r14
mov    %rbx,%r12
jne    1170 <generate_filter_bank_coefficients+0x40>
mov    0x10(%rsp),%rax
mov    %r12,(%rax)
mov    0x18(%rsp),%rax
mov    %r15,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @generate_filter_bank_coefficients(float*** %0, float*** %1) {
%3 = alloca float***
%4 = alloca float***
%5 = alloca float**
%6 = alloca float**
%7 = alloca i32
%8 = alloca i32
store float*** %0, float**** %3
store float*** %1, float**** %4
%9 = call i64 @malloc(i32 64)
%10 = inttoptr i64 %9 to float**
store float** %10, float*** %5
%11 = call i64 @malloc(i32 64)
%12 = inttoptr i64 %11 to float**
store float** %12, float*** %6
store i32 0, i32* %7
br label %13
13: ; preds = %77, %2
%14 = load i32, i32* %7
%15 = icmp ult i32 %14, 8
br i1 %15, label %16, label %80
16: ; preds = %13
%17 = call i64 @malloc(i32 64)
%18 = inttoptr i64 %17 to float*
%19 = load float**, float*** %5
%20 = load i32, i32* %7
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds float*, float** %19, i64 %21
store float* %18, float** %22
%23 = call i64 @malloc(i32 64)
%24 = inttoptr i64 %23 to float*
%25 = load float**, float*** %6
%26 = load i32, i32* %7
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds float*, float** %25, i64 %27
store float* %24, float** %28
store i32 0, i32* %8
br label %29
29: ; preds = %73, %16
%30 = load i32, i32* %8
%31 = icmp ult i32 %30, 16
br i1 %31, label %32, label %76
32: ; preds = %29
%33 = load i32, i32* %7
%34 = mul i32 2, %33
%35 = add i32 %34, 1
%36 = load i32, i32* %8
%37 = sub i32 %36, 4
%38 = mul i32 %35, %37
%39 = uitofp i32 %38 to double
%40 = load double, double* @M_PI
%41 = fdiv double %40, 1.600000e+01
%42 = fmul double %39, %41
%43 = fptosi double %42 to i32
%44 = call float @cos(i32 %43)
%45 = load float**, float*** %5
%46 = load i32, i32* %7
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds float*, float** %45, i64 %47
%49 = load float*, float** %48
%50 = load i32, i32* %8
%51 = zext i32 %50 to i64
%52 = getelementptr inbounds float, float* %49, i64 %51
store float %44, float* %52
%53 = load i32, i32* %7
%54 = mul i32 2, %53
%55 = add i32 %54, 1
%56 = load i32, i32* %8
%57 = sub i32 %56, 4
%58 = mul i32 %55, %57
%59 = uitofp i32 %58 to double
%60 = load double, double* @M_PI
%61 = fdiv double %60, 1.600000e+01
%62 = fmul double %59, %61
%63 = fptosi double %62 to i32
%64 = call float @sin(i32 %63)
%65 = load float**, float*** %6
%66 = load i32, i32* %7
%67 = zext i32 %66 to i64
%68 = getelementptr inbounds float*, float** %65, i64 %67
%69 = load float*, float** %68
%70 = load i32, i32* %8
%71 = zext i32 %70 to i64
%72 = getelementptr inbounds float, float* %69, i64 %71
store float %64, float* %72
br label %73
73: ; preds = %32
%74 = load i32, i32* %8
%75 = add i32 %74, 1
store i32 %75, i32* %8
br label %29
76: ; preds = %29
br label %77
77: ; preds = %76
%78 = load i32, i32* %7
%79 = add i32 %78, 1
store i32 %79, i32* %7
br label %13
80: ; preds = %13
%81 = load float**, float*** %5
%82 = load float***, float**** %3
store float** %81, float*** %82
%83 = load float**, float*** %6
%84 = load float***, float**** %4
store float** %83, float*** %84
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @generate_filter_bank_coefficients(float*** nocapture writeonly %0, float*** nocapture writeonly %1) {
%3 = tail call i64 @malloc(i32 64)
%4 = inttoptr i64 %3 to float**
%5 = tail call i64 @malloc(i32 64)
%6 = inttoptr i64 %5 to float**
br label %8
7: ; preds = %18
store float** %4, float*** %0
store float** %6, float*** %1
ret void
8: ; preds = %2, %18
%9 = phi i64 [ 0, %2 ], [ %19, %18 ]
%10 = tail call i64 @malloc(i32 64)
%11 = inttoptr i64 %10 to float*
%12 = getelementptr inbounds float*, float** %4, i64 %9
store float* %11, float** %12
%13 = tail call i64 @malloc(i32 64)
%14 = inttoptr i64 %13 to float*
%15 = getelementptr inbounds float*, float** %6, i64 %9
store float* %14, float** %15
%16 = shl nuw i64 %9, 1
%17 = or i64 %16, 1
br label %21
18: ; preds = %21
%19 = add nuw nsw i64 %9, 1
%20 = icmp eq i64 %19, 8
br i1 %20, label %7, label %8
21: ; preds = %8, %21
%22 = phi i64 [ 0, %8 ], [ %41, %21 ]
%23 = add nsw i64 %22, -4
%24 = mul nsw i64 %23, %17
%25 = trunc i64 %24 to i32
%26 = uitofp i32 %25 to double
%27 = load double, double* @M_PI
%28 = fmul double %27, 6.250000e-02
%29 = fmul double %28, %26
%30 = fptosi double %29 to i32
%31 = tail call float @cos(i32 %30)
%32 = load float*, float** %12
%33 = getelementptr inbounds float, float* %32, i64 %22
store float %31, float* %33
%34 = load double, double* @M_PI
%35 = fmul double %34, 6.250000e-02
%36 = fmul double %35, %26
%37 = fptosi double %36 to i32
%38 = tail call float @sin(i32 %37)
%39 = load float*, float** %15
%40 = getelementptr inbounds float, float* %39, i64 %22
store float %38, float* %40
%41 = add nuw nsw i64 %22, 1
%42 = icmp eq i64 %41, 16
br i1 %42, label %18, label %21
}