#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 */
double **createIdentity(int);
int /*<<< orphan*/ deallocateSpace(double **, int);
scalar_t__ fabs(double);
double Deviation_from_identity(double **matrix, int size) {
  double **identity = createIdentity(size);
  double sum = 0;
  int i, j;
  for (i = 0; i < size; i++) {
    for (j = 0; j < size; j++) {
      sum += fabs(matrix[i][j] - identity[i][j]);
    }
  }
  deallocateSpace(identity, size);
  deallocateSpace(matrix, size);
  return sum;
}


x86 assembly (clang, -O0):
<Deviation_from_identity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <createIdentity@plt>
mov    %rax,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d8 <Deviation_from_identity+0xa8>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c5 <Deviation_from_identity+0x95>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
call   1050 <fabs@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    116d <Deviation_from_identity+0x3d>
jmp    11ca <Deviation_from_identity+0x9a>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115a <Deviation_from_identity+0x2a>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <deallocateSpace@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <deallocateSpace@plt>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Deviation_from_identity>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
mov    %rdi,%r13
mov    %esi,%edi
call   1030 <createIdentity@plt>
mov    %rax,%rbp
test   %r14d,%r14d
jle    1272 <Deviation_from_identity+0x142>
mov    %r14d,%r12d
mov    %r12,0x10(%rsp)
and    $0xfffffffe,%r12d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %ebx,%ebx
jmp    1192 <Deviation_from_identity+0x62>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    0x10(%rsp),%rbx
mov    %r15d,%r14d
je     127c <Deviation_from_identity+0x14c>
mov    %r14d,%r15d
cmp    $0x1,%r14d
jne    11b0 <Deviation_from_identity+0x80>
xor    %r14d,%r14d
movsd  0x8(%rsp),%xmm0
jmp    1229 <Deviation_from_identity+0xf9>
nopl   0x0(%rax)
xor    %r14d,%r14d
movsd  0x8(%rsp),%xmm0
nopl   0x0(%rax)
movsd  %xmm0,0x8(%rsp)
mov    0x0(%r13,%rbx,8),%rax
movsd  (%rax,%r14,8),%xmm0
mov    0x0(%rbp,%rbx,8),%rax
subsd  (%rax,%r14,8),%xmm0
call   1050 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x0(%r13,%rbx,8),%rax
movsd  0x8(%rax,%r14,8),%xmm0
mov    0x0(%rbp,%rbx,8),%rax
subsd  0x8(%rax,%r14,8),%xmm0
call   1050 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x2,%r14
cmp    %r14,%r12
jne    11c0 <Deviation_from_identity+0x90>
movsd  %xmm0,0x8(%rsp)
testb  $0x1,0x10(%rsp)
je     1180 <Deviation_from_identity+0x50>
mov    0x0(%r13,%rbx,8),%rax
movsd  (%rax,%r14,8),%xmm0
mov    0x0(%rbp,%rbx,8),%rax
subsd  (%rax,%r14,8),%xmm0
call   1050 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
jmp    1180 <Deviation_from_identity+0x50>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbp,%rdi
mov    %r14d,%esi
call   1040 <deallocateSpace@plt>
mov    %r13,%rdi
mov    %r14d,%esi
call   1040 <deallocateSpace@plt>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @Deviation_from_identity(double** %0, i32 %1) {
%3 = alloca double**
%4 = alloca i32
%5 = alloca double**
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
store double** %0, double*** %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = call double** @createIdentity(i32 %9)
store double** %10, double*** %5
store double 0.000000e+00, double* %6
store i32 0, i32* %7
br label %11
11: ; preds = %48, %2
%12 = load i32, i32* %7
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %51
15: ; preds = %11
store i32 0, i32* %8
br label %16
16: ; preds = %44, %15
%17 = load i32, i32* %8
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %47
20: ; preds = %16
%21 = load double**, double*** %3
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double*, double** %21, i64 %23
%25 = load double*, double** %24
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = load double**, double*** %5
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double*, double** %30, i64 %32
%34 = load double*, double** %33
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = fsub double %29, %38
%40 = call i64 @fabs(double %39)
%41 = sitofp i64 %40 to double
%42 = load double, double* %6
%43 = fadd double %42, %41
store double %43, double* %6
br label %44
44: ; preds = %20
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %16
47: ; preds = %16
br label %48
48: ; preds = %47
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %11
51: ; preds = %11
%52 = load double**, double*** %5
%53 = load i32, i32* %4
%54 = call i32 @deallocateSpace(double** %52, i32 %53)
%55 = load double**, double*** %3
%56 = load i32, i32* %4
%57 = call i32 @deallocateSpace(double** %55, i32 %56)
%58 = load double, double* %6
ret double %58
}

LLVM IR (-O2):
define double @Deviation_from_identity(double** %0, i32 %1) {
%3 = tail call double** @createIdentity(i32 %1)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %63
5: ; preds = %2
%6 = zext i32 %1 to i64
%7 = and i64 %6, 1
%8 = icmp eq i32 %1, 1
%9 = and i64 %6, 4294967294
%10 = icmp eq i64 %7, 0
br label %11
11: ; preds = %59, %5
%12 = phi i64 [ 0, %5 ], [ %61, %59 ]
%13 = phi double [ 0.000000e+00, %5 ], [ %60, %59 ]
%14 = getelementptr inbounds double*, double** %0, i64 %12
%15 = getelementptr inbounds double*, double** %3, i64 %12
br i1 %8, label %44, label %16
16: ; preds = %11, %16
%17 = phi i64 [ %41, %16 ], [ 0, %11 ]
%18 = phi double [ %40, %16 ], [ %13, %11 ]
%19 = phi i64 [ %42, %16 ], [ 0, %11 ]
%20 = load double*, double** %14
%21 = getelementptr inbounds double, double* %20, i64 %17
%22 = load double, double* %21
%23 = load double*, double** %15
%24 = getelementptr inbounds double, double* %23, i64 %17
%25 = load double, double* %24
%26 = fsub double %22, %25
%27 = tail call i64 @fabs(double %26)
%28 = sitofp i64 %27 to double
%29 = fadd double %18, %28
%30 = or i64 %17, 1
%31 = load double*, double** %14
%32 = getelementptr inbounds double, double* %31, i64 %30
%33 = load double, double* %32
%34 = load double*, double** %15
%35 = getelementptr inbounds double, double* %34, i64 %30
%36 = load double, double* %35
%37 = fsub double %33, %36
%38 = tail call i64 @fabs(double %37)
%39 = sitofp i64 %38 to double
%40 = fadd double %29, %39
%41 = add nuw nsw i64 %17, 2
%42 = add i64 %19, 2
%43 = icmp eq i64 %42, %9
br i1 %43, label %44, label %16
44: ; preds = %16, %11
%45 = phi double [ undef, %11 ], [ %40, %16 ]
%46 = phi i64 [ 0, %11 ], [ %41, %16 ]
%47 = phi double [ %13, %11 ], [ %40, %16 ]
br i1 %10, label %59, label %48
48: ; preds = %44
%49 = load double*, double** %14
%50 = getelementptr inbounds double, double* %49, i64 %46
%51 = load double, double* %50
%52 = load double*, double** %15
%53 = getelementptr inbounds double, double* %52, i64 %46
%54 = load double, double* %53
%55 = fsub double %51, %54
%56 = tail call i64 @fabs(double %55)
%57 = sitofp i64 %56 to double
%58 = fadd double %47, %57
br label %59
59: ; preds = %44, %48
%60 = phi double [ %45, %44 ], [ %58, %48 ]
%61 = add nuw nsw i64 %12, 1
%62 = icmp eq i64 %61, %6
br i1 %62, label %63, label %11
63: ; preds = %59, %2
%64 = phi double [ 0.000000e+00, %2 ], [ %60, %59 ]
%65 = tail call i32 @deallocateSpace(double** %3, i32 %1)
%66 = tail call i32 @deallocateSpace(double** %0, i32 %1)
ret double %64
}