float *laplaciano(float *input, int width, int height) {
  float *output;
  float **lap;
  output = (float *)malloc(sizeof(float) * width * height);
  {
    int ml;
    lap = (float **)malloc(sizeof(float *) * (3));
    lap[0] = (float *)malloc(sizeof(float) * (3) * (3));
    for (ml = 0; ml < (3); ml++)
      lap[ml] = &(lap[0][ml * (3)]);
  };
  lap[0][0] = 1.0;
  lap[0][1] = 1.0;
  lap[0][2] = 1.0;
  lap[1][0] = 1.0;
  lap[1][1] = -8.0;
  lap[1][2] = 1.0;
  lap[2][0] = 1.0;
  lap[2][1] = 1.0;
  lap[2][2] = 1.0;
  aan_mascara_canal(input, output, width, height, lap);
  {
    free(lap[0]);
    free(lap);
  };
  return output;
}


x86 assembly (clang, -O0):
<laplaciano>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movslq -0xc(%rbp),%rdi
shl    $0x2,%rdi
movslq -0x10(%rbp),%rax
imul   %rax,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x24,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11bc <laplaciano+0x8c>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
imul   $0x3,-0x24(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1184 <laplaciano+0x54>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movss  0xe35(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movss  0xe22(%rip),%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movss  0xe0e(%rip),%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
movss  0xdf9(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
movss  0xde9(%rip),%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
movss  0xdd0(%rip),%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
movss  0xdbb(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
movss  0xda7(%rip),%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
movss  0xd92(%rip),%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    $0x0,%al
call   1050 <aan_mascara_canal@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<laplaciano>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r12
movslq %esi,%r13
movslq %edx,%r15
mov    %r13,%rdi
imul   %r15,%rdi
shl    $0x2,%rdi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    $0x24,%edi
call   1040 <malloc@plt>
mov    %rax,(%rbx)
lea    0xc(%rax),%rcx
mov    %rcx,0x8(%rbx)
lea    0x18(%rax),%rcx
mov    %rcx,0x10(%rbx)
movaps 0xe7a(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe80(%rip),%xmm0
movups %xmm0,0x10(%rax)
movl   $0x3f800000,0x20(%rax)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
mov    %r15d,%ecx
mov    %rbx,%r8
xor    %eax,%eax
call   1050 <aan_mascara_canal@plt>
mov    (%rbx),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float* @laplaciano(float* %0, i32 %1, i32 %2) {
%4 = alloca float*
%5 = alloca i32
%6 = alloca i32
%7 = alloca float*
%8 = alloca float**
%9 = alloca i32
store float* %0, float** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = mul i64 4, %11
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = mul i64 %12, %14
%16 = call i8* @malloc(i64 %15)
%17 = bitcast i8* %16 to float*
store float* %17, float** %7
%18 = call i8* @malloc(i64 24)
%19 = bitcast i8* %18 to float**
store float** %19, float*** %8
%20 = call i8* @malloc(i64 36)
%21 = bitcast i8* %20 to float*
%22 = load float**, float*** %8
%23 = getelementptr inbounds float*, float** %22, i64 0
store float* %21, float** %23
store i32 0, i32* %9
br label %24
24: ; preds = %39, %3
%25 = load i32, i32* %9
%26 = icmp slt i32 %25, 3
br i1 %26, label %27, label %42
27: ; preds = %24
%28 = load float**, float*** %8
%29 = getelementptr inbounds float*, float** %28, i64 0
%30 = load float*, float** %29
%31 = load i32, i32* %9
%32 = mul nsw i32 %31, 3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds float, float* %30, i64 %33
%35 = load float**, float*** %8
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds float*, float** %35, i64 %37
store float* %34, float** %38
br label %39
39: ; preds = %27
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %24
42: ; preds = %24
%43 = load float**, float*** %8
%44 = getelementptr inbounds float*, float** %43, i64 0
%45 = load float*, float** %44
%46 = getelementptr inbounds float, float* %45, i64 0
store float 1.000000e+00, float* %46
%47 = load float**, float*** %8
%48 = getelementptr inbounds float*, float** %47, i64 0
%49 = load float*, float** %48
%50 = getelementptr inbounds float, float* %49, i64 1
store float 1.000000e+00, float* %50
%51 = load float**, float*** %8
%52 = getelementptr inbounds float*, float** %51, i64 0
%53 = load float*, float** %52
%54 = getelementptr inbounds float, float* %53, i64 2
store float 1.000000e+00, float* %54
%55 = load float**, float*** %8
%56 = getelementptr inbounds float*, float** %55, i64 1
%57 = load float*, float** %56
%58 = getelementptr inbounds float, float* %57, i64 0
store float 1.000000e+00, float* %58
%59 = load float**, float*** %8
%60 = getelementptr inbounds float*, float** %59, i64 1
%61 = load float*, float** %60
%62 = getelementptr inbounds float, float* %61, i64 1
store float -8.000000e+00, float* %62
%63 = load float**, float*** %8
%64 = getelementptr inbounds float*, float** %63, i64 1
%65 = load float*, float** %64
%66 = getelementptr inbounds float, float* %65, i64 2
store float 1.000000e+00, float* %66
%67 = load float**, float*** %8
%68 = getelementptr inbounds float*, float** %67, i64 2
%69 = load float*, float** %68
%70 = getelementptr inbounds float, float* %69, i64 0
store float 1.000000e+00, float* %70
%71 = load float**, float*** %8
%72 = getelementptr inbounds float*, float** %71, i64 2
%73 = load float*, float** %72
%74 = getelementptr inbounds float, float* %73, i64 1
store float 1.000000e+00, float* %74
%75 = load float**, float*** %8
%76 = getelementptr inbounds float*, float** %75, i64 2
%77 = load float*, float** %76
%78 = getelementptr inbounds float, float* %77, i64 2
store float 1.000000e+00, float* %78
%79 = load float*, float** %4
%80 = load float*, float** %7
%81 = load i32, i32* %5
%82 = load i32, i32* %6
%83 = load float**, float*** %8
%84 = call i32 (float*, float*, i32, i32, float**, ...) bitcast (i32 (...)* @aan_mascara_canal to i32 (float*, float*, i32, i32, float**, ...)*)(float* %79, float* %80, i32 %81, i32 %82, float** %83)
%85 = load float**, float*** %8
%86 = getelementptr inbounds float*, float** %85, i64 0
%87 = load float*, float** %86
%88 = bitcast float* %87 to i8*
%89 = load float**, float*** %8
%90 = bitcast float** %89 to i8*
%91 = load float*, float** %7
ret float* %91
}

LLVM IR (-O2):
define float* @laplaciano(float* %0, i32 %1, i32 %2) {
%4 = sext i32 %1 to i64
%5 = shl nsw i64 %4, 2
%6 = sext i32 %2 to i64
%7 = mul i64 %5, %6
%8 = tail call i8* @malloc(i64 %7)
%9 = tail call dereferenceable_or_null(24) i8* @malloc(i64 24)
%10 = bitcast i8* %9 to float**
%11 = tail call dereferenceable_or_null(36) i8* @malloc(i64 36)
%12 = bitcast i8* %9 to i8**
%13 = bitcast i8* %11 to float*
%14 = bitcast i8* %9 to i8**
store i8* %11, i8** %14
%15 = getelementptr inbounds float, float* %13, i64 3
%16 = getelementptr inbounds float*, float** %10, i64 1
store float* %15, float** %16
%17 = getelementptr inbounds float, float* %13, i64 6
%18 = getelementptr inbounds float*, float** %10, i64 2
store float* %17, float** %18
%19 = bitcast i8* %8 to float*
%20 = bitcast i8* %11 to <4 x float>*
store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, <4 x float>* %20
%21 = getelementptr inbounds float, float* %13, i64 4
%22 = bitcast float* %21 to <4 x float>*
store <4 x float> <float -8.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, <4 x float>* %22
%23 = getelementptr inbounds float, float* %13, i64 8
store float 1.000000e+00, float* %23
%24 = tail call i32 (float*, float*, i32, i32, float**, ...) bitcast (i32 (...)* @aan_mascara_canal to i32 (float*, float*, i32, i32, float**, ...)*)(float* %0, float* %19, i32 %1, i32 %2, float** %10)
%25 = load i8*, i8** %12
tail call void @free(i8* %25)
tail call void @free(i8* %9)
ret float* %19
}