#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*/ matrixCopy(double **, double **, int);
int /*<<< orphan*/ matrixMultiplication(double **, double **, double **, int);
double matrixNorm(double **, double **, int);
void matrixCalculation(double **ma, double **mb, double **resultm, int dim,
                       double *norm, int count) {
  if (count == 0)
    matrixCopy(ma, mb, dim);
  matrixMultiplication(ma, mb, resultm, dim);
  *norm = matrixNorm(resultm, mb, dim);
  matrixCopy(resultm, mb, dim);
}


x86 assembly (clang, -O0):
<matrixCalculation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1169 <matrixCalculation+0x39>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <matrixCopy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1050 <matrixMultiplication@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <matrixNorm@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <matrixCopy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrixCalculation>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%r14
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r12
test   %r9d,%r9d
jne    1158 <matrixCalculation+0x28>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <matrixCopy@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %ebp,%ecx
call   1050 <matrixMultiplication@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <matrixNorm@plt>
movsd  %xmm0,(%r14)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <matrixCopy@plt>

LLVM IR (-O0):
define void @matrixCalculation(double** %0, double** %1, double** %2, i32 %3, double* %4, i32 %5) {
%7 = alloca double**
%8 = alloca double**
%9 = alloca double**
%10 = alloca i32
%11 = alloca double*
%12 = alloca i32
store double** %0, double*** %7
store double** %1, double*** %8
store double** %2, double*** %9
store i32 %3, i32* %10
store double* %4, double** %11
store i32 %5, i32* %12
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %6
%16 = load double**, double*** %7
%17 = load double**, double*** %8
%18 = load i32, i32* %10
%19 = call i32 @matrixCopy(double** %16, double** %17, i32 %18)
br label %20
20: ; preds = %15, %6
%21 = load double**, double*** %7
%22 = load double**, double*** %8
%23 = load double**, double*** %9
%24 = load i32, i32* %10
%25 = call i32 @matrixMultiplication(double** %21, double** %22, double** %23, i32 %24)
%26 = load double**, double*** %9
%27 = load double**, double*** %8
%28 = load i32, i32* %10
%29 = call double @matrixNorm(double** %26, double** %27, i32 %28)
%30 = load double*, double** %11
store double %29, double* %30
%31 = load double**, double*** %9
%32 = load double**, double*** %8
%33 = load i32, i32* %10
%34 = call i32 @matrixCopy(double** %31, double** %32, i32 %33)
ret void
}

LLVM IR (-O2):
define void @matrixCalculation(double** %0, double** %1, double** %2, i32 %3, double* nocapture writeonly %4, i32 %5) {
%7 = icmp eq i32 %5, 0
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @matrixCopy(double** %0, double** %1, i32 %3)
br label %10
10: ; preds = %8, %6
%11 = tail call i32 @matrixMultiplication(double** %0, double** %1, double** %2, i32 %3)
%12 = tail call double @matrixNorm(double** %2, double** %1, i32 %3)
store double %12, double* %4
%13 = tail call i32 @matrixCopy(double** %2, double** %1, i32 %3)
ret void
}