#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 jacobi(int, int, double **, double **);
double **leer_ind(int);
double **leer_matriz(int);
double **leer_round_robin(int);
double pow(int, int);
int main(void) {
  int ncol = 10, i, j, cont;
  int col1, col2, colmin, colmax;
  double paro;
  double **matrizA = leer_matriz(ncol);
  double **matrizI = leer_ind(ncol);
  double **matrizR = leer_round_robin(ncol);
  while (paro < pow(10, -8)) {
    for (i = 0; i < 9; i++) {
      for (j = 0; j < 10; j = j + 2) {
        col1 = matrizR[i][j];
        col2 = matrizR[i][j + 1];
        if (col1 < col2) {
          colmin = col1;
          colmax = col2;
        } else {
          colmin = col2;
          colmax = col1;
        }
        paro = jacobi(colmin, colmax, matrizA, matrizI);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <leer_matriz@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <leer_ind@plt>
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <leer_round_robin@plt>
mov    %rax,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    $0xa,%edi
mov    $0xfffffff8,%esi
call   1070 <pow@plt>
movsd  -0x50(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1270 <main+0x120>
movl   $0x0,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
jge    126b <main+0x11b>
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    1258 <main+0x108>
mov    -0x48(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%eax
mov    %eax,-0x18(%rbp)
mov    -0x48(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cvttsd2si (%rax,%rcx,8),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1226 <main+0xd6>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1232 <main+0xe2>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
call   1040 <jacobi@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    11ca <main+0x7a>
jmp    125d <main+0x10d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b9 <main+0x69>
jmp    118a <main+0x3a>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xa,%edi
call   1030 <leer_matriz@plt>
mov    $0xa,%edi
call   1040 <leer_ind@plt>
mov    $0xa,%edi
call   1050 <leer_round_robin@plt>
mov    $0xa,%edi
mov    $0xfffffff8,%esi
call   1060 <pow@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double**
%12 = alloca double**
%13 = alloca double**
store i32 0, i32* %1
store i32 10, i32* %2
%14 = load i32, i32* %2
%15 = call double** @leer_matriz(i32 %14)
store double** %15, double*** %11
%16 = load i32, i32* %2
%17 = call double** @leer_ind(i32 %16)
store double** %17, double*** %12
%18 = load i32, i32* %2
%19 = call double** @leer_round_robin(i32 %18)
store double** %19, double*** %13
br label %20
20: ; preds = %76, %0
%21 = load double, double* %10
%22 = call double @pow(i32 10, i32 -8)
%23 = fcmp olt double %21, %22
br i1 %23, label %24, label %77
24: ; preds = %20
store i32 0, i32* %3
br label %25
25: ; preds = %73, %24
%26 = load i32, i32* %3
%27 = icmp slt i32 %26, 9
br i1 %27, label %28, label %76
28: ; preds = %25
store i32 0, i32* %4
br label %29
29: ; preds = %69, %28
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 10
br i1 %31, label %32, label %72
32: ; preds = %29
%33 = load double**, double*** %13
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double*, double** %33, i64 %35
%37 = load double*, double** %36
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = fptosi double %41 to i32
store i32 %42, i32* %6
%43 = load double**, double*** %13
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double*, double** %43, i64 %45
%47 = load double*, double** %46
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %47, i64 %50
%52 = load double, double* %51
%53 = fptosi double %52 to i32
store i32 %53, i32* %7
%54 = load i32, i32* %6
%55 = load i32, i32* %7
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %60
57: ; preds = %32
%58 = load i32, i32* %6
store i32 %58, i32* %8
%59 = load i32, i32* %7
store i32 %59, i32* %9
br label %63
60: ; preds = %32
%61 = load i32, i32* %7
store i32 %61, i32* %8
%62 = load i32, i32* %6
store i32 %62, i32* %9
br label %63
63: ; preds = %60, %57
%64 = load i32, i32* %8
%65 = load i32, i32* %9
%66 = load double**, double*** %11
%67 = load double**, double*** %12
%68 = call double @jacobi(i32 %64, i32 %65, double** %66, double** %67)
store double %68, double* %10
br label %69
69: ; preds = %63
%70 = load i32, i32* %4
%71 = add nsw i32 %70, 2
store i32 %71, i32* %4
br label %29
72: ; preds = %29
br label %73
73: ; preds = %72
%74 = load i32, i32* %3
%75 = add nsw i32 %74, 1
store i32 %75, i32* %3
br label %25
76: ; preds = %25
br label %20
77: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call double** @leer_matriz(i32 10)
%2 = tail call double** @leer_ind(i32 10)
%3 = tail call double** @leer_round_robin(i32 10)
%4 = tail call double @pow(i32 10, i32 -8)
ret i32 0
}