#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*/ fatoracao_lu(double **, int, double **, double **,
                                double **);
double **matriz_nula(int, int);
double **matriz_quadrada_nula(int);
double **produto(double **, double **, int, int, int, int);
int /*<<< orphan*/ substituicao_ascendente(double **, double **, int,
                                           double **);
int /*<<< orphan*/ substituicao_descendente(double **, double **, int,
                                            double **);
void solucao_linear(double **A, int dim, double **B, double **P, double **X) {
  double **L, **U;
  double **Y;
  double **PB;
  L = matriz_quadrada_nula(dim);
  U = matriz_quadrada_nula(dim);
  Y = matriz_nula(dim, 1);
  PB = matriz_nula(dim, 1);
  fatoracao_lu(A, dim, L, U, P);
  PB = produto(P, B, dim, dim, dim, 1);
  substituicao_ascendente(L, PB, dim, Y);
  substituicao_descendente(U, Y, dim, X);
}


x86 assembly (clang, -O0):
<solucao_linear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <matriz_quadrada_nula@plt>
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <matriz_quadrada_nula@plt>
mov    %rax,-0x38(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1,%esi
call   1040 <matriz_nula@plt>
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1,%esi
call   1040 <matriz_nula@plt>
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1050 <fatoracao_lu@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    $0x1,%r9d
call   1060 <produto@plt>
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x40(%rbp),%rcx
call   1080 <substituicao_ascendente@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x28(%rbp),%rcx
call   1070 <substituicao_descendente@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solucao_linear>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x10(%rsp)
mov    %rcx,%rbx
mov    %rdx,0x8(%rsp)
mov    %esi,%ebp
mov    %rdi,%r12
mov    %esi,%edi
call   1030 <matriz_quadrada_nula@plt>
mov    %rax,%r13
mov    %ebp,%edi
call   1030 <matriz_quadrada_nula@plt>
mov    %rax,%r15
mov    %ebp,%edi
mov    $0x1,%esi
call   1040 <matriz_nula@plt>
mov    %rax,%r14
mov    %ebp,%edi
mov    $0x1,%esi
call   1040 <matriz_nula@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %rbx,%r8
call   1050 <fatoracao_lu@plt>
mov    %rbx,%rdi
mov    0x8(%rsp),%rsi
mov    %ebp,%edx
mov    %ebp,%ecx
mov    %ebp,%r8d
mov    $0x1,%r9d
call   1060 <produto@plt>
mov    %r13,%rdi
mov    %rax,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   1080 <substituicao_ascendente@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    0x10(%rsp),%rcx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <substituicao_descendente@plt>

LLVM IR (-O0):
define void @solucao_linear(double** %0, i32 %1, double** %2, double** %3, double** %4) {
%6 = alloca double**
%7 = alloca i32
%8 = alloca double**
%9 = alloca double**
%10 = alloca double**
%11 = alloca double**
%12 = alloca double**
%13 = alloca double**
%14 = alloca double**
store double** %0, double*** %6
store i32 %1, i32* %7
store double** %2, double*** %8
store double** %3, double*** %9
store double** %4, double*** %10
%15 = load i32, i32* %7
%16 = call double** @matriz_quadrada_nula(i32 %15)
store double** %16, double*** %11
%17 = load i32, i32* %7
%18 = call double** @matriz_quadrada_nula(i32 %17)
store double** %18, double*** %12
%19 = load i32, i32* %7
%20 = call double** @matriz_nula(i32 %19, i32 1)
store double** %20, double*** %13
%21 = load i32, i32* %7
%22 = call double** @matriz_nula(i32 %21, i32 1)
store double** %22, double*** %14
%23 = load double**, double*** %6
%24 = load i32, i32* %7
%25 = load double**, double*** %11
%26 = load double**, double*** %12
%27 = load double**, double*** %9
%28 = call i32 @fatoracao_lu(double** %23, i32 %24, double** %25, double** %26, double** %27)
%29 = load double**, double*** %9
%30 = load double**, double*** %8
%31 = load i32, i32* %7
%32 = load i32, i32* %7
%33 = load i32, i32* %7
%34 = call double** @produto(double** %29, double** %30, i32 %31, i32 %32, i32 %33, i32 1)
store double** %34, double*** %14
%35 = load double**, double*** %11
%36 = load double**, double*** %14
%37 = load i32, i32* %7
%38 = load double**, double*** %13
%39 = call i32 @substituicao_ascendente(double** %35, double** %36, i32 %37, double** %38)
%40 = load double**, double*** %12
%41 = load double**, double*** %13
%42 = load i32, i32* %7
%43 = load double**, double*** %10
%44 = call i32 @substituicao_descendente(double** %40, double** %41, i32 %42, double** %43)
ret void
}

LLVM IR (-O2):
define void @solucao_linear(double** %0, i32 %1, double** %2, double** %3, double** %4) {
%6 = tail call double** @matriz_quadrada_nula(i32 %1)
%7 = tail call double** @matriz_quadrada_nula(i32 %1)
%8 = tail call double** @matriz_nula(i32 %1, i32 1)
%9 = tail call double** @matriz_nula(i32 %1, i32 1)
%10 = tail call i32 @fatoracao_lu(double** %0, i32 %1, double** %6, double** %7, double** %3)
%11 = tail call double** @produto(double** %3, double** %2, i32 %1, i32 %1, i32 %1, i32 1)
%12 = tail call i32 @substituicao_ascendente(double** %6, double** %11, i32 %1, double** %8)
%13 = tail call i32 @substituicao_descendente(double** %7, double** %8, i32 %1, double** %4)
ret void
}