#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*/ deallocate(double **, int);
double **hadamardProduct(double **, int, int, double **, int, int);
scalar_t__ malloc(int);
double **sigmoidDerivate(double **matrix, int row, int column) {
  double **helpResult = (double **)malloc(row * sizeof(double *));
  for (int i = 0; i < row; i++) {
    helpResult[i] = (double *)malloc(column * sizeof(double));
    for (int j = 0; j < column; j++) {
      helpResult[i][j] = 1 - matrix[i][j];
    }
  }
  double **result =
      hadamardProduct(matrix, row, column, helpResult, row, column);
  deallocate(helpResult, row);
  return result;
}


x86 assembly (clang, -O0):
<sigmoidDerivate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ec <sigmoidDerivate+0xbc>
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d9 <sigmoidDerivate+0xa9>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  0xe4f(%rip),%xmm0
subsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    118d <sigmoidDerivate+0x5d>
jmp    11de <sigmoidDerivate+0xae>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <sigmoidDerivate+0x2c>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0xc(%rbp),%r8d
mov    -0x10(%rbp),%r9d
call   1050 <hadamardProduct@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <deallocate@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigmoidDerivate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,0x8(%rsp)
lea    0x0(,%rbp,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    %rbp,(%rsp)
test   %ebp,%ebp
jle    1356 <sigmoidDerivate+0x226>
lea    0x0(,%rbx,8),%ebp
mov    (%rsp),%eax
mov    %rax,0x30(%rsp)
mov    %ebx,%r14d
mov    %r14d,%eax
and    $0xfffffffc,%eax
mov    %rax,0x28(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x20(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x18(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x10(%rsp)
mov    %r14d,%r12d
and    $0x3,%r12d
xor    %r13d,%r13d
jmp    11bf <sigmoidDerivate+0x8f>
add    $0x1,%r13
cmp    0x30(%rsp),%r13
je     1356 <sigmoidDerivate+0x226>
mov    %ebp,%edi
call   1040 <malloc@plt>
movapd 0xe32(%rip),%xmm4
movsd  0xe3a(%rip),%xmm3
mov    %rax,(%r15,%r13,8)
test   %ebx,%ebx
jle    11b0 <sigmoidDerivate+0x80>
mov    0x8(%rsp),%rcx
mov    (%rcx,%r13,8),%rcx
cmp    $0x4,%ebx
jb     1206 <sigmoidDerivate+0xd6>
lea    (%rcx,%r14,8),%rdx
cmp    %rdx,%rax
jae    129c <sigmoidDerivate+0x16c>
lea    (%rax,%r14,8),%rdx
cmp    %rdx,%rcx
jae    129c <sigmoidDerivate+0x16c>
xor    %edx,%edx
mov    %rdx,%rsi
not    %rsi
add    %r14,%rsi
test   %r12,%r12
je     1238 <sigmoidDerivate+0x108>
mov    %r12,%rdi
nopl   0x0(%rax)
movapd %xmm3,%xmm0
subsd  (%rcx,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rdi
jne    1220 <sigmoidDerivate+0xf0>
cmp    $0x3,%rsi
jb     11b0 <sigmoidDerivate+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movapd %xmm3,%xmm0
subsd  (%rcx,%rdx,8),%xmm0
movsd  %xmm0,(%rax,%rdx,8)
movapd %xmm3,%xmm0
subsd  0x8(%rcx,%rdx,8),%xmm0
movsd  %xmm0,0x8(%rax,%rdx,8)
movapd %xmm3,%xmm0
subsd  0x10(%rcx,%rdx,8),%xmm0
movsd  %xmm0,0x10(%rax,%rdx,8)
movapd %xmm3,%xmm0
subsd  0x18(%rcx,%rdx,8),%xmm0
movsd  %xmm0,0x18(%rax,%rdx,8)
add    $0x4,%rdx
cmp    %rdx,%r14
jne    1250 <sigmoidDerivate+0x120>
jmp    11b0 <sigmoidDerivate+0x80>
cmpq   $0x0,0x20(%rsp)
je     134b <sigmoidDerivate+0x21b>
mov    0x10(%rsp),%rsi
xor    %edx,%edx
nop
movupd (%rcx,%rdx,8),%xmm0
movupd 0x10(%rcx,%rdx,8),%xmm1
movapd %xmm4,%xmm2
subpd  %xmm0,%xmm2
movapd %xmm4,%xmm0
subpd  %xmm1,%xmm0
movupd %xmm2,(%rax,%rdx,8)
movupd %xmm0,0x10(%rax,%rdx,8)
movupd 0x20(%rcx,%rdx,8),%xmm0
movupd 0x30(%rcx,%rdx,8),%xmm1
movapd %xmm4,%xmm2
subpd  %xmm0,%xmm2
movapd %xmm4,%xmm0
subpd  %xmm1,%xmm0
movupd %xmm2,0x20(%rax,%rdx,8)
movupd %xmm0,0x30(%rax,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rsi
jne    12b0 <sigmoidDerivate+0x180>
testb  $0x1,0x18(%rsp)
je     1335 <sigmoidDerivate+0x205>
movupd (%rcx,%rdx,8),%xmm0
movupd 0x10(%rcx,%rdx,8),%xmm1
movapd %xmm4,%xmm2
subpd  %xmm0,%xmm2
movapd %xmm4,%xmm0
subpd  %xmm1,%xmm0
movupd %xmm2,(%rax,%rdx,8)
movupd %xmm0,0x10(%rax,%rdx,8)
mov    0x28(%rsp),%rsi
mov    %rsi,%rdx
cmp    %r14,%rsi
je     11b0 <sigmoidDerivate+0x80>
jmp    1208 <sigmoidDerivate+0xd8>
xor    %edx,%edx
testb  $0x1,0x18(%rsp)
jne    130f <sigmoidDerivate+0x1df>
jmp    1335 <sigmoidDerivate+0x205>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rbp
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r15,%rcx
mov    %ebp,%r8d
mov    %ebx,%r9d
call   1050 <hadamardProduct@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <deallocate@plt>
mov    %rbx,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double** @sigmoidDerivate(double** %0, i32 %1, i32 %2) {
%4 = alloca double**
%5 = alloca i32
%6 = alloca i32
%7 = alloca double**
%8 = alloca i32
%9 = alloca i32
%10 = alloca double**
store double** %0, double*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = mul i64 %12, 8
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to double**
store double** %16, double*** %7
store i32 0, i32* %8
br label %17
17: ; preds = %59, %3
%18 = load i32, i32* %8
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %62
21: ; preds = %17
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 8
%25 = trunc i64 %24 to i32
%26 = call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to double*
%28 = load double**, double*** %7
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double*, double** %28, i64 %30
store double* %27, double** %31
store i32 0, i32* %9
br label %32
32: ; preds = %55, %21
%33 = load i32, i32* %9
%34 = load i32, i32* %6
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %58
36: ; preds = %32
%37 = load double**, double*** %4
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double*, double** %37, i64 %39
%41 = load double*, double** %40
%42 = load i32, i32* %9
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
%45 = load double, double* %44
%46 = fsub double 1.000000e+00, %45
%47 = load double**, double*** %7
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double*, double** %47, i64 %49
%51 = load double*, double** %50
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
store double %46, double* %54
br label %55
55: ; preds = %36
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %32
58: ; preds = %32
br label %59
59: ; preds = %58
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
br label %17
62: ; preds = %17
%63 = load double**, double*** %4
%64 = load i32, i32* %5
%65 = load i32, i32* %6
%66 = load double**, double*** %7
%67 = load i32, i32* %5
%68 = load i32, i32* %6
%69 = call double** @hadamardProduct(double** %63, i32 %64, i32 %65, double** %66, i32 %67, i32 %68)
store double** %69, double*** %10
%70 = load double**, double*** %7
%71 = load i32, i32* %5
%72 = call i32 @deallocate(double** %70, i32 %71)
%73 = load double**, double*** %10
ret double** %73
}

LLVM IR (-O2):
define double** @sigmoidDerivate(double** %0, i32 %1, i32 %2) {
%4 = shl i32 %1, 3
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to double**
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %26
8: ; preds = %3
%9 = shl i32 %2, 3
%10 = icmp sgt i32 %2, 0
%11 = zext i32 %1 to i64
%12 = zext i32 %2 to i64
%13 = and i64 %12, 4294967292
%14 = add nsw i64 %13, -4
%15 = lshr exact i64 %14, 2
%16 = add nuw nsw i64 %15, 1
%17 = icmp ult i32 %2, 4
%18 = and i64 %12, 4294967292
%19 = and i64 %16, 1
%20 = icmp eq i64 %14, 0
%21 = and i64 %16, 9223372036854775806
%22 = icmp eq i64 %19, 0
%23 = icmp eq i64 %18, %12
%24 = and i64 %12, 3
%25 = icmp eq i64 %24, 0
br label %29
26: ; preds = %110, %3
%27 = tail call double** @hadamardProduct(double** %0, i32 %1, i32 %2, double** %6, i32 %1, i32 %2)
%28 = tail call i32 @deallocate(double** %6, i32 %1)
ret double** %27
29: ; preds = %8, %110
%30 = phi i64 [ 0, %8 ], [ %111, %110 ]
%31 = tail call i64 @malloc(i32 %9)
%32 = inttoptr i64 %31 to double*
%33 = inttoptr i64 %31 to i8*
%34 = getelementptr inbounds double*, double** %6, i64 %30
store double* %32, double** %34
br i1 %10, label %35, label %110
35: ; preds = %29
%36 = getelementptr inbounds double*, double** %0, i64 %30
%37 = load double*, double** %36
br i1 %17, label %93, label %38
38: ; preds = %35
%39 = getelementptr double, double* %32, i64 %12
%40 = getelementptr double, double* %37, i64 %12
%41 = bitcast double* %40 to i8*
%42 = icmp ult i8* %33, %41
%43 = icmp ult double* %37, %39
%44 = and i1 %42, %43
br i1 %44, label %93, label %45
45: ; preds = %38
br i1 %20, label %77, label %46
46: ; preds = %45, %46
%47 = phi i64 [ %74, %46 ], [ 0, %45 ]
%48 = phi i64 [ %75, %46 ], [ 0, %45 ]
%49 = getelementptr inbounds double, double* %37, i64 %47
%50 = bitcast double* %49 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = getelementptr inbounds double, double* %49, i64 2
%53 = bitcast double* %52 to <2 x double>*
%54 = load <2 x double>, <2 x double>* %53
%55 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %51
%56 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %54
%57 = getelementptr inbounds double, double* %32, i64 %47
%58 = bitcast double* %57 to <2 x double>*
store <2 x double> %55, <2 x double>* %58
%59 = getelementptr inbounds double, double* %57, i64 2
%60 = bitcast double* %59 to <2 x double>*
store <2 x double> %56, <2 x double>* %60
%61 = or i64 %47, 4
%62 = getelementptr inbounds double, double* %37, i64 %61
%63 = bitcast double* %62 to <2 x double>*
%64 = load <2 x double>, <2 x double>* %63
%65 = getelementptr inbounds double, double* %62, i64 2
%66 = bitcast double* %65 to <2 x double>*
%67 = load <2 x double>, <2 x double>* %66
%68 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %64
%69 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %67
%70 = getelementptr inbounds double, double* %32, i64 %61
%71 = bitcast double* %70 to <2 x double>*
store <2 x double> %68, <2 x double>* %71
%72 = getelementptr inbounds double, double* %70, i64 2
%73 = bitcast double* %72 to <2 x double>*
store <2 x double> %69, <2 x double>* %73
%74 = add nuw i64 %47, 8
%75 = add i64 %48, 2
%76 = icmp eq i64 %75, %21
br i1 %76, label %77, label %46
77: ; preds = %46, %45
%78 = phi i64 [ 0, %45 ], [ %74, %46 ]
br i1 %22, label %92, label %79
79: ; preds = %77
%80 = getelementptr inbounds double, double* %37, i64 %78
%81 = bitcast double* %80 to <2 x double>*
%82 = load <2 x double>, <2 x double>* %81
%83 = getelementptr inbounds double, double* %80, i64 2
%84 = bitcast double* %83 to <2 x double>*
%85 = load <2 x double>, <2 x double>* %84
%86 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %82
%87 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %85
%88 = getelementptr inbounds double, double* %32, i64 %78
%89 = bitcast double* %88 to <2 x double>*
store <2 x double> %86, <2 x double>* %89
%90 = getelementptr inbounds double, double* %88, i64 2
%91 = bitcast double* %90 to <2 x double>*
store <2 x double> %87, <2 x double>* %91
br label %92
92: ; preds = %77, %79
br i1 %23, label %110, label %93
93: ; preds = %38, %35, %92
%94 = phi i64 [ 0, %38 ], [ 0, %35 ], [ %18, %92 ]
%95 = xor i64 %94, -1
%96 = add nsw i64 %95, %12
br i1 %25, label %107, label %97
97: ; preds = %93, %97
%98 = phi i64 [ %104, %97 ], [ %94, %93 ]
%99 = phi i64 [ %105, %97 ], [ 0, %93 ]
%100 = getelementptr inbounds double, double* %37, i64 %98
%101 = load double, double* %100
%102 = fsub double 1.000000e+00, %101
%103 = getelementptr inbounds double, double* %32, i64 %98
store double %102, double* %103
%104 = add nuw nsw i64 %98, 1
%105 = add i64 %99, 1
%106 = icmp eq i64 %105, %24
br i1 %106, label %107, label %97
107: ; preds = %97, %93
%108 = phi i64 [ %94, %93 ], [ %104, %97 ]
%109 = icmp ult i64 %96, 3
br i1 %109, label %110, label %113
110: ; preds = %107, %113, %92, %29
%111 = add nuw nsw i64 %30, 1
%112 = icmp eq i64 %111, %11
br i1 %112, label %26, label %29
113: ; preds = %107, %113
%114 = phi i64 [ %134, %113 ], [ %108, %107 ]
%115 = getelementptr inbounds double, double* %37, i64 %114
%116 = load double, double* %115
%117 = fsub double 1.000000e+00, %116
%118 = getelementptr inbounds double, double* %32, i64 %114
store double %117, double* %118
%119 = add nuw nsw i64 %114, 1
%120 = getelementptr inbounds double, double* %37, i64 %119
%121 = load double, double* %120
%122 = fsub double 1.000000e+00, %121
%123 = getelementptr inbounds double, double* %32, i64 %119
store double %122, double* %123
%124 = add nuw nsw i64 %114, 2
%125 = getelementptr inbounds double, double* %37, i64 %124
%126 = load double, double* %125
%127 = fsub double 1.000000e+00, %126
%128 = getelementptr inbounds double, double* %32, i64 %124
store double %127, double* %128
%129 = add nuw nsw i64 %114, 3
%130 = getelementptr inbounds double, double* %37, i64 %129
%131 = load double, double* %130
%132 = fsub double 1.000000e+00, %131
%133 = getelementptr inbounds double, double* %32, i64 %129
store double %132, double* %133
%134 = add nuw nsw i64 %114, 4
%135 = icmp eq i64 %134, %12
br i1 %135, label %110, label %113
}