#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*/ exit(int);
void **mul_matrix(char const *, void **, void **, int, int, int, int);
int /*<<< orphan*/ printf(char *);
void *exp_matrix(char const *param_type, int **mat_1, int mat_1_rows,
                 int mat_1_cols, int exp) {
  if (exp <= 0) {
    printf("errore: comportamento non definito per esponente = 0\n");
    exit(1);
  }
  void **mat = mat_1;
  int i;
  for (i = 1; i < exp; i++) {
    mat = mul_matrix(param_type, mat, mat, mat_1_rows, mat_1_cols, mat_1_rows,
                     mat_1_cols);
  }
  return mat;
}


x86 assembly (clang, -O0):
<exp_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     116a <exp_matrix+0x3a>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b9 <exp_matrix+0x89>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x14(%rbp),%r9d
mov    -0x18(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <mul_matrix@plt>
mov    %rax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1179 <exp_matrix+0x49>
mov    -0x28(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exp_matrix>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %r8d,%r8d
jle    118a <exp_matrix+0x5a>
mov    %r8d,%ebx
mov    %rsi,%rax
cmp    $0x1,%r8d
je     117f <exp_matrix+0x4f>
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rdi,%r15
add    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14d,(%rsp)
mov    %r15,%rdi
mov    %rax,%rsi
mov    %rax,%rdx
mov    %ebp,%ecx
mov    %r14d,%r8d
mov    %ebp,%r9d
call   1040 <mul_matrix@plt>
add    $0xffffffff,%ebx
jne    1160 <exp_matrix+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [54 x i8] c"errore: comportamento non definito per esponente = 0\0A\00"
define i8* @exp_matrix(i8* %0, i32** %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8**
%12 = alloca i32
store i8* %0, i8** %6
store i32** %1, i32*** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = load i32, i32* %10
%14 = icmp sle i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %5
%16 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %5
%19 = load i32**, i32*** %7
%20 = bitcast i32** %19 to i8**
store i8** %20, i8*** %11
store i32 1, i32* %12
br label %21
21: ; preds = %34, %18
%22 = load i32, i32* %12
%23 = load i32, i32* %10
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %37
25: ; preds = %21
%26 = load i8*, i8** %6
%27 = load i8**, i8*** %11
%28 = load i8**, i8*** %11
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = call i8** @mul_matrix(i8* %26, i8** %27, i8** %28, i32 %29, i32 %30, i32 %31, i32 %32)
store i8** %33, i8*** %11
br label %34
34: ; preds = %25
%35 = load i32, i32* %12
%36 = add nsw i32 %35, 1
store i32 %36, i32* %12
br label %21
37: ; preds = %21
%38 = load i8**, i8*** %11
%39 = bitcast i8** %38 to i8*
ret i8* %39
}

LLVM IR (-O2):
@str = [53 x i8] c"errore: comportamento non definito per esponente = 0\00"
define i8* @exp_matrix(i8* %0, i32** %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp slt i32 %4, 1
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %5
%11 = bitcast i32** %1 to i8**
%12 = icmp eq i32 %4, 1
br i1 %12, label %19, label %13
13: ; preds = %10, %13
%14 = phi i32 [ %17, %13 ], [ 1, %10 ]
%15 = phi i8** [ %16, %13 ], [ %11, %10 ]
%16 = tail call i8** @mul_matrix(i8* %0, i8** %15, i8** %15, i32 %2, i32 %3, i32 %2, i32 %3)
%17 = add nuw nsw i32 %14, 1
%18 = icmp eq i32 %17, %4
br i1 %18, label %19, label %13
19: ; preds = %13, %10
%20 = phi i8** [ %11, %10 ], [ %16, %13 ]
%21 = bitcast i8** %20 to i8*
ret i8* %21
}