float *grad_vertical(float *input, int width, int height) {
  float *grad;
  float **u_y;
  grad = (float *)malloc(sizeof(float) * width * height);
  {
    int ml;
    u_y = (float **)malloc(sizeof(float *) * (3));
    u_y[0] = (float *)malloc(sizeof(float) * (3) * (3));
    for (ml = 0; ml < (3); ml++)
      u_y[ml] = &(u_y[0][ml * (3)]);
  };
  u_y[0][0] = 0.25 * -(2.0 - sqrt(2.0));
  u_y[0][1] = 0.25 * -2.0 * (sqrt(2.0) - 1);
  u_y[0][2] = 0.25 * -(2.0 - sqrt(2.0));
  u_y[1][0] = 0;
  u_y[1][1] = 0;
  u_y[1][2] = 0;
  u_y[2][0] = 0.25 * (2.0 - sqrt(2.0));
  u_y[2][1] = 0.25 * 2.0 * (sqrt(2.0) - 1);
  u_y[2][2] = 0.25 * (2.0 - sqrt(2.0));
  aan_mascara_canal(input, grad, width, height, u_y);
  {
    free(u_y[0]);
    free(u_y);
  };
  return grad;
}


x86 assembly (clang, -O0):
<grad_vertical>:
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    11cc <grad_vertical+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    1194 <grad_vertical+0x54>
movsd  0xe34(%rip),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe24(%rip),%xmm0
subsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xdf9(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movss  %xmm0,(%rax)
movsd  0xde6(%rip),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xde6(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xde2(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movss  %xmm0,0x4(%rax)
movsd  0xdae(%rip),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xd9e(%rip),%xmm0
subsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xd73(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movss  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rax)
movsd  0xd30(%rip),%xmm0
call   1060 <sqrt@plt>
movsd  0xd23(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0xd0f(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
movss  %xmm0,(%rax)
movsd  0xcfb(%rip),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xcfb(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xce7(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
movss  %xmm0,0x4(%rax)
movsd  0xcc2(%rip),%xmm0
call   1060 <sqrt@plt>
movsd  0xcb5(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0xca1(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
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):
<grad_vertical>:
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   $0x3e15f61a,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* @grad_vertical(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 = call double @sqrt(double 2.000000e+00)
%44 = fsub double 2.000000e+00, %43
%45 = fneg double %44
%46 = fmul double 2.500000e-01, %45
%47 = fptrunc double %46 to float
%48 = load float**, float*** %8
%49 = getelementptr inbounds float*, float** %48, i64 0
%50 = load float*, float** %49
%51 = getelementptr inbounds float, float* %50, i64 0
store float %47, float* %51
%52 = call double @sqrt(double 2.000000e+00)
%53 = fsub double %52, 1.000000e+00
%54 = fmul double -5.000000e-01, %53
%55 = fptrunc double %54 to float
%56 = load float**, float*** %8
%57 = getelementptr inbounds float*, float** %56, i64 0
%58 = load float*, float** %57
%59 = getelementptr inbounds float, float* %58, i64 1
store float %55, float* %59
%60 = call double @sqrt(double 2.000000e+00)
%61 = fsub double 2.000000e+00, %60
%62 = fneg double %61
%63 = fmul double 2.500000e-01, %62
%64 = fptrunc double %63 to float
%65 = load float**, float*** %8
%66 = getelementptr inbounds float*, float** %65, i64 0
%67 = load float*, float** %66
%68 = getelementptr inbounds float, float* %67, i64 2
store float %64, float* %68
%69 = load float**, float*** %8
%70 = getelementptr inbounds float*, float** %69, i64 1
%71 = load float*, float** %70
%72 = getelementptr inbounds float, float* %71, i64 0
store float 0.000000e+00, float* %72
%73 = load float**, float*** %8
%74 = getelementptr inbounds float*, float** %73, i64 1
%75 = load float*, float** %74
%76 = getelementptr inbounds float, float* %75, i64 1
store float 0.000000e+00, float* %76
%77 = load float**, float*** %8
%78 = getelementptr inbounds float*, float** %77, i64 1
%79 = load float*, float** %78
%80 = getelementptr inbounds float, float* %79, i64 2
store float 0.000000e+00, float* %80
%81 = call double @sqrt(double 2.000000e+00)
%82 = fsub double 2.000000e+00, %81
%83 = fmul double 2.500000e-01, %82
%84 = fptrunc double %83 to float
%85 = load float**, float*** %8
%86 = getelementptr inbounds float*, float** %85, i64 2
%87 = load float*, float** %86
%88 = getelementptr inbounds float, float* %87, i64 0
store float %84, float* %88
%89 = call double @sqrt(double 2.000000e+00)
%90 = fsub double %89, 1.000000e+00
%91 = fmul double 5.000000e-01, %90
%92 = fptrunc double %91 to float
%93 = load float**, float*** %8
%94 = getelementptr inbounds float*, float** %93, i64 2
%95 = load float*, float** %94
%96 = getelementptr inbounds float, float* %95, i64 1
store float %92, float* %96
%97 = call double @sqrt(double 2.000000e+00)
%98 = fsub double 2.000000e+00, %97
%99 = fmul double 2.500000e-01, %98
%100 = fptrunc double %99 to float
%101 = load float**, float*** %8
%102 = getelementptr inbounds float*, float** %101, i64 2
%103 = load float*, float** %102
%104 = getelementptr inbounds float, float* %103, i64 2
store float %100, float* %104
%105 = load float*, float** %4
%106 = load float*, float** %7
%107 = load i32, i32* %5
%108 = load i32, i32* %6
%109 = load float**, float*** %8
%110 = call i32 (float*, float*, i32, i32, float**, ...) bitcast (i32 (...)* @aan_mascara_canal to i32 (float*, float*, i32, i32, float**, ...)*)(float* %105, float* %106, i32 %107, i32 %108, float** %109)
%111 = load float**, float*** %8
%112 = getelementptr inbounds float*, float** %111, i64 0
%113 = load float*, float** %112
%114 = bitcast float* %113 to i8*
%115 = load float**, float*** %8
%116 = bitcast float** %115 to i8*
%117 = load float*, float** %7
ret float* %117
}

LLVM IR (-O2):
define float* @grad_vertical(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 0xBFC2BEC340000000, float 0xBFCA8279A0000000, float 0xBFC2BEC340000000, float 0.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 0.000000e+00, float 0.000000e+00, float 0x3FC2BEC340000000, float 0x3FCA8279A0000000>, <4 x float>* %22
%23 = getelementptr inbounds float, float* %13, i64 8
store float 0x3FC2BEC340000000, 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
}