#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*/ _mm_free(float *);
scalar_t__ _mm_malloc(int const, int);
int compare(float *, float *, int const);
int /*<<< orphan*/ gaussian_blur(float *, float *, int const, int const, float,
                                 int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  const int w = 20;
  const int h = 20;
  int i;
  float *src = (float *)_mm_malloc(w * h * sizeof(float), 16);
  float *dst1 = (float *)_mm_malloc(w * h * sizeof(float), 16);
  float *dst2 = (float *)_mm_malloc(w * h * sizeof(float), 16);
  for (i = 0; i < w * h; i++) {
    src[i] = i;
  }
  gaussian_blur(src, dst1, w, h, 1.0f, 1);
  gaussian_blur(src, dst2, w, h, 1.0f, 4);
  int error = compare(dst1, dst2, w * h);
  printf("error %d\n", error);
  _mm_free(src);
  _mm_free(dst1);
  _mm_free(dst2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x14,-0x14(%rbp)
movl   $0x14,-0x18(%rbp)
mov    $0x640,%edi
mov    $0x10,%esi
call   1060 <_mm_malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x640,%edi
mov    $0x10,%esi
call   1060 <_mm_malloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x640,%edi
mov    $0x10,%esi
call   1060 <_mm_malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x190,-0x1c(%rbp)
jge    11e1 <main+0x91>
cvtsi2ssl -0x1c(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b4 <main+0x64>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x14,%ecx
movss  0xe0a(%rip),%xmm0
mov    $0x1,%r8d
mov    %ecx,%edx
call   1040 <gaussian_blur@plt>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    $0x14,%ecx
movss  0xde8(%rip),%xmm0
mov    $0x4,%r8d
mov    %ecx,%edx
call   1040 <gaussian_blur@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    $0x190,%edx
call   1050 <compare@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%esi
lea    0xdc0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1070 <_mm_free@plt>
mov    -0x30(%rbp),%rdi
call   1070 <_mm_free@plt>
mov    -0x38(%rbp),%rdi
call   1070 <_mm_free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x640,%edi
mov    $0x10,%esi
call   1060 <_mm_malloc@plt>
mov    %rax,%rbx
mov    $0x640,%edi
mov    $0x10,%esi
call   1060 <_mm_malloc@plt>
mov    %rax,%r14
mov    $0x640,%edi
mov    $0x10,%esi
call   1060 <_mm_malloc@plt>
mov    %rax,%r15
movdqa 0xe6d(%rip),%xmm0
mov    $0xc,%eax
movdqa 0xe70(%rip),%xmm1
movdqa 0xe78(%rip),%xmm2
movdqa 0xe80(%rip),%xmm3
movdqa 0xe88(%rip),%xmm4
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm5
paddd  %xmm1,%xmm5
cvtdq2ps %xmm0,%xmm6
cvtdq2ps %xmm5,%xmm5
movups %xmm6,-0x30(%rbx,%rax,4)
movups %xmm5,-0x20(%rbx,%rax,4)
movdqa %xmm0,%xmm5
paddd  %xmm2,%xmm5
movdqa %xmm0,%xmm6
paddd  %xmm3,%xmm6
cvtdq2ps %xmm5,%xmm5
cvtdq2ps %xmm6,%xmm6
movups %xmm5,-0x10(%rbx,%rax,4)
movups %xmm6,(%rbx,%rax,4)
paddd  %xmm4,%xmm0
add    $0x10,%rax
cmp    $0x19c,%rax
jne    11c0 <main+0x70>
movss  0xe41(%rip),%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x14,%edx
mov    $0x14,%ecx
mov    $0x1,%r8d
call   1040 <gaussian_blur@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x14,%edx
mov    $0x14,%ecx
movss  0xe0e(%rip),%xmm0
mov    $0x4,%r8d
call   1040 <gaussian_blur@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x190,%edx
call   1050 <compare@plt>
lea    0xdf0(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <_mm_free@plt>
mov    %r14,%rdi
call   1070 <_mm_free@plt>
mov    %r15,%rdi
call   1070 <_mm_free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"error %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float*
%10 = alloca float*
%11 = alloca float*
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 20, i32* %6
store i32 20, i32* %7
%13 = call i64 @_mm_malloc(i32 1600, i32 16)
%14 = inttoptr i64 %13 to float*
store float* %14, float** %9
%15 = call i64 @_mm_malloc(i32 1600, i32 16)
%16 = inttoptr i64 %15 to float*
store float* %16, float** %10
%17 = call i64 @_mm_malloc(i32 1600, i32 16)
%18 = inttoptr i64 %17 to float*
store float* %18, float** %11
store i32 0, i32* %8
br label %19
19: ; preds = %29, %2
%20 = load i32, i32* %8
%21 = icmp slt i32 %20, 400
br i1 %21, label %22, label %32
22: ; preds = %19
%23 = load i32, i32* %8
%24 = sitofp i32 %23 to float
%25 = load float*, float** %9
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds float, float* %25, i64 %27
store float %24, float* %28
br label %29
29: ; preds = %22
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %19
32: ; preds = %19
%33 = load float*, float** %9
%34 = load float*, float** %10
%35 = call i32 @gaussian_blur(float* %33, float* %34, i32 20, i32 20, float 1.000000e+00, i32 1)
%36 = load float*, float** %9
%37 = load float*, float** %11
%38 = call i32 @gaussian_blur(float* %36, float* %37, i32 20, i32 20, float 1.000000e+00, i32 4)
%39 = load float*, float** %10
%40 = load float*, float** %11
%41 = call i32 @compare(float* %39, float* %40, i32 400)
store i32 %41, i32* %12
%42 = load i32, i32* %12
%43 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = load float*, float** %9
%45 = call i32 @_mm_free(float* %44)
%46 = load float*, float** %10
%47 = call i32 @_mm_free(float* %46)
%48 = load float*, float** %11
%49 = call i32 @_mm_free(float* %48)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"error %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @_mm_malloc(i32 1600, i32 16)
%4 = inttoptr i64 %3 to float*
%5 = tail call i64 @_mm_malloc(i32 1600, i32 16)
%6 = tail call i64 @_mm_malloc(i32 1600, i32 16)
br label %7
7: ; preds = %7, %2
%8 = phi i64 [ 0, %2 ], [ %26, %7 ]
%9 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %2 ], [ %27, %7 ]
%10 = add <4 x i32> %9, <i32 4, i32 4, i32 4, i32 4>
%11 = sitofp <4 x i32> %9 to <4 x float>
%12 = sitofp <4 x i32> %10 to <4 x float>
%13 = getelementptr inbounds float, float* %4, i64 %8
%14 = bitcast float* %13 to <4 x float>*
store <4 x float> %11, <4 x float>* %14
%15 = getelementptr inbounds float, float* %13, i64 4
%16 = bitcast float* %15 to <4 x float>*
store <4 x float> %12, <4 x float>* %16
%17 = or i64 %8, 8
%18 = add <4 x i32> %9, <i32 8, i32 8, i32 8, i32 8>
%19 = add <4 x i32> %9, <i32 12, i32 12, i32 12, i32 12>
%20 = sitofp <4 x i32> %18 to <4 x float>
%21 = sitofp <4 x i32> %19 to <4 x float>
%22 = getelementptr inbounds float, float* %4, i64 %17
%23 = bitcast float* %22 to <4 x float>*
store <4 x float> %20, <4 x float>* %23
%24 = getelementptr inbounds float, float* %22, i64 4
%25 = bitcast float* %24 to <4 x float>*
store <4 x float> %21, <4 x float>* %25
%26 = add nuw nsw i64 %8, 16
%27 = add <4 x i32> %9, <i32 16, i32 16, i32 16, i32 16>
%28 = icmp eq i64 %26, 400
br i1 %28, label %29, label %7
29: ; preds = %7
%30 = inttoptr i64 %5 to float*
%31 = inttoptr i64 %6 to float*
%32 = tail call i32 @gaussian_blur(float* %4, float* %30, i32 20, i32 20, float 1.000000e+00, i32 1)
%33 = tail call i32 @gaussian_blur(float* %4, float* %31, i32 20, i32 20, float 1.000000e+00, i32 4)
%34 = tail call i32 @compare(float* %30, float* %31, i32 400)
%35 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = tail call i32 @_mm_free(float* %4)
%37 = tail call i32 @_mm_free(float* %30)
%38 = tail call i32 @_mm_free(float* %31)
ret i32 0
}