#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 confere_interpolacao_polinomial(double **, double **, int);
int /*<<< orphan*/ imprime_matriz(double **, int, int, char *);
int /*<<< orphan*/ imprime_polinomio(double **, int, char *);
int /*<<< orphan*/ polinomio_interpolador(double **, double **, int, double **);
int /*<<< orphan*/ printf(char *);
void imprime_teste_interpolacao(double **X, double **Fx, double **Pol,
                                double **Pol_ok, int dim) {
  bool correto;
  printf("\n-------------------\n");
  printf("\nInterpolacao polinomial: \n");
  imprime_matriz(X, dim, 1, "x");
  imprime_matriz(Fx, dim, 1, "f(x)");
  polinomio_interpolador(X, Fx, dim, Pol);
  imprime_matriz(Pol, dim, 1, "Polinomio interpolador - forma matricial");
  imprime_polinomio(Pol, dim, "Polinomio interpolador - forma polinomial");
  correto = confere_interpolacao_polinomial(Pol, Pol_ok, dim);
  if (correto) {
    printf("\nInterpolacao efetuada com sucesso.\n");
  } else {
    printf("\nInterpolacao nao passou nos testes.\n");
  }
  printf("\n-------------------\n");
}


x86 assembly (clang, -O0):
<imprime_teste_interpolacao>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
lea    0xe8d(%rip),%rdi
call   1050 <printf@plt>
lea    0xe97(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    $0x1,%edx
lea    0xe9b(%rip),%rcx
call   1060 <imprime_matriz@plt>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    $0x1,%edx
lea    0xe85(%rip),%rcx
call   1060 <imprime_matriz@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1040 <polinomio_interpolador@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    $0x1,%edx
lea    0xe5e(%rip),%rcx
call   1060 <imprime_matriz@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    0xe74(%rip),%rdx
call   1070 <imprime_polinomio@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <confere_interpolacao_polinomial@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     1221 <imprime_teste_interpolacao+0xd1>
lea    0xe75(%rip),%rdi
call   1050 <printf@plt>
jmp    122d <imprime_teste_interpolacao+0xdd>
lea    0xe89(%rip),%rdi
call   1050 <printf@plt>
lea    0xdcc(%rip),%rdi
call   1050 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imprime_teste_interpolacao>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%ebp
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r13
lea    0xf29(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
lea    0xeda(%rip),%rdi
call   1040 <puts@plt>
lea    0xe74(%rip),%rcx
mov    %r13,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1060 <imprime_matriz@plt>
lea    0xe60(%rip),%rcx
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1060 <imprime_matriz@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1050 <polinomio_interpolador@plt>
lea    0xe3f(%rip),%rcx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1060 <imprime_matriz@plt>
lea    0xe52(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <imprime_polinomio@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1030 <confere_interpolacao_polinomial@plt>
test   %eax,%eax
lea    0xe77(%rip),%rax
lea    0xeaa(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"\0A-------------------\0A\00"
@.str.1 = [28 x i8] c"\0AInterpolacao polinomial: \0A\00"
@.str.2 = [2 x i8] c"x\00"
@.str.3 = [5 x i8] c"f(x)\00"
@.str.4 = [41 x i8] c"Polinomio interpolador - forma matricial\00"
@.str.5 = [42 x i8] c"Polinomio interpolador - forma polinomial\00"
@.str.6 = [37 x i8] c"\0AInterpolacao efetuada com sucesso.\0A\00"
@.str.7 = [38 x i8] c"\0AInterpolacao nao passou nos testes.\0A\00"
define void @imprime_teste_interpolacao(double** %0, double** %1, double** %2, double** %3, i32 %4) {
%6 = alloca double**
%7 = alloca double**
%8 = alloca double**
%9 = alloca double**
%10 = alloca i32
%11 = alloca i32
store double** %0, double*** %6
store double** %1, double*** %7
store double** %2, double*** %8
store double** %3, double*** %9
store i32 %4, i32* %10
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%14 = load double**, double*** %6
%15 = load i32, i32* %10
%16 = call i32 @imprime_matriz(double** %14, i32 %15, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%17 = load double**, double*** %7
%18 = load i32, i32* %10
%19 = call i32 @imprime_matriz(double** %17, i32 %18, i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%20 = load double**, double*** %6
%21 = load double**, double*** %7
%22 = load i32, i32* %10
%23 = load double**, double*** %8
%24 = call i32 @polinomio_interpolador(double** %20, double** %21, i32 %22, double** %23)
%25 = load double**, double*** %8
%26 = load i32, i32* %10
%27 = call i32 @imprime_matriz(double** %25, i32 %26, i32 1, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%28 = load double**, double*** %8
%29 = load i32, i32* %10
%30 = call i32 @imprime_polinomio(double** %28, i32 %29, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%31 = load double**, double*** %8
%32 = load double**, double*** %9
%33 = load i32, i32* %10
%34 = call i32 @confere_interpolacao_polinomial(double** %31, double** %32, i32 %33)
store i32 %34, i32* %11
%35 = load i32, i32* %11
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %5
%38 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
br label %41
39: ; preds = %5
%40 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0))
br label %41
41: ; preds = %39, %37
%42 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [2 x i8] c"x\00"
@.str.3 = [5 x i8] c"f(x)\00"
@.str.4 = [41 x i8] c"Polinomio interpolador - forma matricial\00"
@.str.5 = [42 x i8] c"Polinomio interpolador - forma polinomial\00"
@str.8 = [27 x i8] c"\0AInterpolacao polinomial: \00"
@str.9 = [37 x i8] c"\0AInterpolacao nao passou nos testes.\00"
@str.10 = [21 x i8] c"\0A-------------------\00"
@str.11 = [36 x i8] c"\0AInterpolacao efetuada com sucesso.\00"
define void @imprime_teste_interpolacao(double** %0, double** %1, double** %2, double** %3, i32 %4) {
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.8, i64 0, i64 0))
%8 = tail call i32 @imprime_matriz(double** %0, i32 %4, i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @imprime_matriz(double** %1, i32 %4, i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%10 = tail call i32 @polinomio_interpolador(double** %0, double** %1, i32 %4, double** %2)
%11 = tail call i32 @imprime_matriz(double** %2, i32 %4, i32 1, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%12 = tail call i32 @imprime_polinomio(double** %2, i32 %4, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%13 = tail call i32 @confere_interpolacao_polinomial(double** %2, double** %3, i32 %4)
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @str.9, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @str.11, i64 0, i64 0)
%16 = tail call i32 @puts(i8* dereferenceable(1) %15)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.10, i64 0, i64 0))
ret void
}