#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*/ convolute(unsigned int *, float *, unsigned int *, float *);
int /*<<< orphan*/ convolute_C(unsigned int *, float *, unsigned int *,
                               float *);
int /*<<< orphan*/ exit(int);
void *malloc(int);
int posix_memalign(void **, int, int);
int /*<<< orphan*/ printf(char *);
int main() {
  int N = 10;
  int result;
  unsigned int *A_index_array;
  unsigned int *B_index_array;
  float *A_norm;
  float *B_norm;
  A_index_array = malloc(N * sizeof(unsigned int));
  A_index_array[0] = 1;
  A_index_array[1] = 2;
  A_index_array[2] = 3;
  A_index_array[3] = 4;
  A_norm = malloc(N * sizeof(float));
  A_norm[0] = 0.5;
  A_norm[1] = 0.6;
  A_norm[2] = 0.7;
  A_norm[3] = 0.8;
  result =
      posix_memalign((void **)&B_index_array, 16, N * sizeof(unsigned int));
  if (result != 0) {
    printf("error allocating aligned memory\n");
    exit(1);
  }
  B_index_array[0] = 10;
  B_index_array[1] = 20;
  B_index_array[2] = 30;
  B_index_array[3] = 40;
  result = posix_memalign((void **)&B_norm, 16, N * sizeof(float));
  if (result != 0) {
    printf("error allocating aligned memory\n");
    exit(1);
  }
  B_norm[0] = 1.5;
  B_norm[1] = 1.6;
  B_norm[2] = 1.7;
  B_norm[3] = 1.8;
  B_norm[4] = 1.9;
  B_norm[5] = 1.95;
  convolute(A_index_array, A_norm, B_index_array, B_norm);
  convolute_C(A_index_array, A_norm, B_index_array, B_norm);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0xa,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x2,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x3,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x4,0xc(%rax)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movss  0xe40(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movss  0xe2c(%rip),%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x20(%rbp),%rax
movss  0xe17(%rip),%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
movss  0xe02(%rip),%xmm0
movss  %xmm0,0xc(%rax)
lea    -0x18(%rbp),%rdi
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
mov    $0x10,%esi
call   1080 <posix_memalign@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     123e <main+0xde>
lea    0xdf9(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rax
movl   $0xa,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x14,0x4(%rax)
mov    -0x18(%rbp),%rax
movl   $0x1e,0x8(%rax)
mov    -0x18(%rbp),%rax
movl   $0x28,0xc(%rax)
lea    -0x28(%rbp),%rdi
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
mov    $0x10,%esi
call   1080 <posix_memalign@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     12a4 <main+0x144>
lea    0xd93(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x28(%rbp),%rax
movss  0xd74(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movss  0xd60(%rip),%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x28(%rbp),%rax
movss  0xd4b(%rip),%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x28(%rbp),%rax
movss  0xd36(%rip),%xmm0
movss  %xmm0,0xc(%rax)
mov    -0x28(%rbp),%rax
movss  0xd21(%rip),%xmm0
movss  %xmm0,0x10(%rax)
mov    -0x28(%rbp),%rax
movss  0xd0c(%rip),%xmm0
movss  %xmm0,0x14(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <convolute@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1060 <convolute_C@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
movaps 0xe85(%rip),%xmm0
movups %xmm0,(%rax)
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movaps 0xe7e(%rip),%xmm0
movups %xmm0,(%rax)
lea    0x8(%rsp),%rdi
mov    $0x10,%esi
mov    $0x28,%edx
call   1080 <posix_memalign@plt>
test   %eax,%eax
jne    1220 <main+0xc0>
mov    0x8(%rsp),%rax
movaps 0xe67(%rip),%xmm0
movups %xmm0,(%rax)
lea    0x10(%rsp),%rdi
mov    $0x10,%esi
mov    $0x28,%edx
call   1080 <posix_memalign@plt>
test   %eax,%eax
jne    1220 <main+0xc0>
mov    0x10(%rsp),%rcx
movaps 0xe50(%rip),%xmm0
movups %xmm0,(%rcx)
movabs $0x3ff9999a3ff33333,%rax
99 f9 3f
mov    %rax,0x10(%rcx)
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <convolute@plt>
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <convolute_C@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe19(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"error allocating aligned memory\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca float*
%6 = alloca float*
store i32 10, i32* %1
%7 = load i32, i32* %1
%8 = sext i32 %7 to i64
%9 = mul i64 %8, 4
%10 = trunc i64 %9 to i32
%11 = call i8* @malloc(i32 %10)
%12 = bitcast i8* %11 to i32*
store i32* %12, i32** %3
%13 = load i32*, i32** %3
%14 = getelementptr inbounds i32, i32* %13, i64 0
store i32 1, i32* %14
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i64 1
store i32 2, i32* %16
%17 = load i32*, i32** %3
%18 = getelementptr inbounds i32, i32* %17, i64 2
store i32 3, i32* %18
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i64 3
store i32 4, i32* %20
%21 = load i32, i32* %1
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 4
%24 = trunc i64 %23 to i32
%25 = call i8* @malloc(i32 %24)
%26 = bitcast i8* %25 to float*
store float* %26, float** %5
%27 = load float*, float** %5
%28 = getelementptr inbounds float, float* %27, i64 0
store float 5.000000e-01, float* %28
%29 = load float*, float** %5
%30 = getelementptr inbounds float, float* %29, i64 1
store float 0x3FE3333340000000, float* %30
%31 = load float*, float** %5
%32 = getelementptr inbounds float, float* %31, i64 2
store float 0x3FE6666660000000, float* %32
%33 = load float*, float** %5
%34 = getelementptr inbounds float, float* %33, i64 3
store float 0x3FE99999A0000000, float* %34
%35 = bitcast i32** %4 to i8**
%36 = load i32, i32* %1
%37 = sext i32 %36 to i64
%38 = mul i64 %37, 4
%39 = trunc i64 %38 to i32
%40 = call i32 @posix_memalign(i8** %35, i32 16, i32 %39)
store i32 %40, i32* %2
%41 = load i32, i32* %2
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %0
%44 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %0
%47 = load i32*, i32** %4
%48 = getelementptr inbounds i32, i32* %47, i64 0
store i32 10, i32* %48
%49 = load i32*, i32** %4
%50 = getelementptr inbounds i32, i32* %49, i64 1
store i32 20, i32* %50
%51 = load i32*, i32** %4
%52 = getelementptr inbounds i32, i32* %51, i64 2
store i32 30, i32* %52
%53 = load i32*, i32** %4
%54 = getelementptr inbounds i32, i32* %53, i64 3
store i32 40, i32* %54
%55 = bitcast float** %6 to i8**
%56 = load i32, i32* %1
%57 = sext i32 %56 to i64
%58 = mul i64 %57, 4
%59 = trunc i64 %58 to i32
%60 = call i32 @posix_memalign(i8** %55, i32 16, i32 %59)
store i32 %60, i32* %2
%61 = load i32, i32* %2
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %46
%64 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %46
%67 = load float*, float** %6
%68 = getelementptr inbounds float, float* %67, i64 0
store float 1.500000e+00, float* %68
%69 = load float*, float** %6
%70 = getelementptr inbounds float, float* %69, i64 1
store float 0x3FF99999A0000000, float* %70
%71 = load float*, float** %6
%72 = getelementptr inbounds float, float* %71, i64 2
store float 0x3FFB333340000000, float* %72
%73 = load float*, float** %6
%74 = getelementptr inbounds float, float* %73, i64 3
store float 0x3FFCCCCCC0000000, float* %74
%75 = load float*, float** %6
%76 = getelementptr inbounds float, float* %75, i64 4
store float 0x3FFE666660000000, float* %76
%77 = load float*, float** %6
%78 = getelementptr inbounds float, float* %77, i64 5
store float 0x3FFF333340000000, float* %78
%79 = load i32*, i32** %3
%80 = load float*, float** %5
%81 = load i32*, i32** %4
%82 = load float*, float** %6
%83 = call i32 @convolute(i32* %79, float* %80, i32* %81, float* %82)
%84 = load i32*, i32** %3
%85 = load float*, float** %5
%86 = load i32*, i32** %4
%87 = load float*, float** %6
%88 = call i32 @convolute_C(i32* %84, float* %85, i32* %86, float* %87)
ret i32 0
}

LLVM IR (-O2):
@str.1 = [32 x i8] c"error allocating aligned memory\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca float*
%3 = bitcast i32** %1 to i8*
%4 = bitcast float** %2 to i8*
%5 = tail call dereferenceable_or_null(40) i8* @malloc(i32 40)
%6 = bitcast i8* %5 to i32*
%7 = bitcast i8* %5 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %7
%8 = tail call dereferenceable_or_null(40) i8* @malloc(i32 40)
%9 = bitcast i8* %8 to float*
%10 = bitcast i8* %8 to <4 x float>*
store <4 x float> <float 5.000000e-01, float 0x3FE3333340000000, float 0x3FE6666660000000, float 0x3FE99999A0000000>, <4 x float>* %10
%11 = bitcast i32** %1 to i8**
%12 = call i32 @posix_memalign(i8** %11, i32 16, i32 40)
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.1, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %0
%18 = bitcast i32** %1 to <4 x i32>**
%19 = load <4 x i32>*, <4 x i32>** %18
store <4 x i32> <i32 10, i32 20, i32 30, i32 40>, <4 x i32>* %19
%20 = bitcast float** %2 to i8**
%21 = call i32 @posix_memalign(i8** %20, i32 16, i32 40)
%22 = icmp eq i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %17
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.1, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %17
%27 = load float*, float** %2
%28 = bitcast float* %27 to <4 x float>*
store <4 x float> <float 1.500000e+00, float 0x3FF99999A0000000, float 0x3FFB333340000000, float 0x3FFCCCCCC0000000>, <4 x float>* %28
%29 = getelementptr inbounds float, float* %27, i64 4
store float 0x3FFE666660000000, float* %29
%30 = getelementptr inbounds float, float* %27, i64 5
store float 0x3FFF333340000000, float* %30
%31 = load i32*, i32** %1
%32 = call i32 @convolute(i32* %6, float* %9, i32* %31, float* %27)
%33 = load i32*, i32** %1
%34 = load float*, float** %2
%35 = call i32 @convolute_C(i32* %6, float* %9, i32* %33, float* %34)
ret i32 0
}