#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 calculaUSigmaGama(double **, double *, double *, double, int, int, int);
int /*<<< orphan*/ input(int, char **, double **, double *, int *, int *);
int permuta(double **, double *, int *, int, int, int);
int /*<<< orphan*/ printMAT(double **, int, int);
int /*<<< orphan*/ printVET(double *, int);
int /*<<< orphan*/ produtoQA(double **, double *, double *, double, int, int,
                             int);
double sigmaArray(double **, double *, int, int);
int /*<<< orphan*/ sigmaRecalc(double **, double *, int, int, int);
int /*<<< orphan*/ solution(double **, double *, int *, double, int, int, int);
int /*<<< orphan*/ use(int);
int main(int argc, char *argv[]) {
  double A[1000][1000], b[1000];
  double sigma[1000], u[1000];
  double max, gama;
  int permutacao[1000];
  int m, n;
  int rank;
  int stop;
  use(argc);
  input(argc, argv, A, b, &n, &m);
  printMAT(A, n, m);
  printVET(b, n);
  max = sigmaArray(A, sigma, n, m);
  for (rank = 0; rank < m; rank++) {
    stop = permuta(A, sigma, permutacao, rank, n, m);
    if (stop == 1)
      break;
    gama = calculaUSigmaGama(A, sigma, u, max, rank, n, m);
    produtoQA(A, b, u, gama, rank, n, m);
    sigmaRecalc(A, sigma, rank, n, m);
  }
  solution(A, b, permutacao, max, rank, n, m);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7a7f90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1080 <use@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x7a1210(%rbp),%rdx
lea    -0x7a3150(%rbp),%rcx
lea    -0x7a7f88(%rbp),%r8
lea    -0x7a7f84(%rbp),%r9
call   1040 <input@plt>
lea    -0x7a1210(%rbp),%rdi
mov    -0x7a7f88(%rbp),%esi
mov    -0x7a7f84(%rbp),%edx
call   10b0 <printMAT@plt>
lea    -0x7a3150(%rbp),%rdi
mov    -0x7a7f88(%rbp),%esi
call   1070 <printVET@plt>
lea    -0x7a1210(%rbp),%rdi
lea    -0x7a5090(%rbp),%rsi
mov    -0x7a7f88(%rbp),%edx
mov    -0x7a7f84(%rbp),%ecx
call   1090 <sigmaArray@plt>
movsd  %xmm0,-0x7a6fd8(%rbp)
ff
movl   $0x0,-0x7a7f8c(%rbp)
mov    -0x7a7f8c(%rbp),%eax
cmp    -0x7a7f84(%rbp),%eax
jge    134a <main+0x1aa>
lea    -0x7a1210(%rbp),%rdi
lea    -0x7a5090(%rbp),%rsi
lea    -0x7a7f80(%rbp),%rdx
mov    -0x7a7f8c(%rbp),%ecx
mov    -0x7a7f88(%rbp),%r8d
mov    -0x7a7f84(%rbp),%r9d
call   1060 <permuta@plt>
mov    %eax,-0x7a7f90(%rbp)
cmpl   $0x1,-0x7a7f90(%rbp)
jne    129c <main+0xfc>
jmp    134a <main+0x1aa>
lea    -0x7a1210(%rbp),%rdi
lea    -0x7a5090(%rbp),%rsi
lea    -0x7a6fd0(%rbp),%rdx
movsd  -0x7a6fd8(%rbp),%xmm0
ff
mov    -0x7a7f8c(%rbp),%ecx
mov    -0x7a7f88(%rbp),%r8d
mov    -0x7a7f84(%rbp),%r9d
call   10a0 <calculaUSigmaGama@plt>
movsd  %xmm0,-0x7a6fe0(%rbp)
ff
lea    -0x7a1210(%rbp),%rdi
lea    -0x7a3150(%rbp),%rsi
lea    -0x7a6fd0(%rbp),%rdx
movsd  -0x7a6fe0(%rbp),%xmm0
ff
mov    -0x7a7f8c(%rbp),%ecx
mov    -0x7a7f88(%rbp),%r8d
mov    -0x7a7f84(%rbp),%r9d
call   1030 <produtoQA@plt>
lea    -0x7a1210(%rbp),%rdi
lea    -0x7a5090(%rbp),%rsi
mov    -0x7a7f8c(%rbp),%edx
mov    -0x7a7f88(%rbp),%ecx
mov    -0x7a7f84(%rbp),%r8d
call   10c0 <sigmaRecalc@plt>
mov    -0x7a7f8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a7f8c(%rbp)
jmp    1244 <main+0xa4>
lea    -0x7a1210(%rbp),%rdi
lea    -0x7a3150(%rbp),%rsi
lea    -0x7a7f80(%rbp),%rdx
movsd  -0x7a6fd8(%rbp),%xmm0
ff
mov    -0x7a7f8c(%rbp),%ecx
mov    -0x7a7f88(%rbp),%r8d
mov    -0x7a7f84(%rbp),%r9d
call   1050 <solution@plt>
xor    %eax,%eax
add    $0x7a7f90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7a7f78,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
call   1080 <use@plt>
lea    0x6d70(%rsp),%r14
lea    0xfb0(%rsp),%r15
mov    %rsp,%r8
lea    0x4(%rsp),%r9
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1040 <input@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    %r14,%rdi
call   10b0 <printMAT@plt>
mov    (%rsp),%esi
mov    %r15,%rdi
call   1070 <printVET@plt>
mov    (%rsp),%edx
mov    0x4(%rsp),%ecx
lea    0x2ef0(%rsp),%rsi
mov    %r14,%rdi
call   1090 <sigmaArray@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x4(%rsp),%r9d
xor    %ebx,%ebx
test   %r9d,%r9d
jle    12ca <main+0x12a>
lea    0x6d70(%rsp),%r14
lea    0x2ef0(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0x4e30(%rsp),%r13
lea    0xfb0(%rsp),%rbp
nop
mov    (%rsp),%r8d
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %ebx,%ecx
call   1060 <permuta@plt>
cmp    $0x1,%eax
je     12c5 <main+0x125>
mov    (%rsp),%r8d
mov    0x4(%rsp),%r9d
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
movsd  0x8(%rsp),%xmm0
mov    %ebx,%ecx
call   10a0 <calculaUSigmaGama@plt>
mov    (%rsp),%r8d
mov    0x4(%rsp),%r9d
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %ebx,%ecx
call   1030 <produtoQA@plt>
mov    (%rsp),%ecx
mov    0x4(%rsp),%r8d
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   10c0 <sigmaRecalc@plt>
add    $0x1,%ebx
mov    0x4(%rsp),%r9d
cmp    %r9d,%ebx
jl     1250 <main+0xb0>
jmp    12ca <main+0x12a>
mov    0x4(%rsp),%r9d
mov    (%rsp),%r8d
lea    0x6d70(%rsp),%rdi
lea    0xfb0(%rsp),%rsi
lea    0x10(%rsp),%rdx
movsd  0x8(%rsp),%xmm0
mov    %ebx,%ecx
call   1050 <solution@plt>
xor    %eax,%eax
add    $0x7a7f78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x [1000 x double]]
%7 = alloca [1000 x double]
%8 = alloca [1000 x double]
%9 = alloca [1000 x double]
%10 = alloca double
%11 = alloca double
%12 = alloca [1000 x i32]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = call i32 @use(i32 %17)
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 0
%22 = bitcast [1000 x double]* %21 to double**
%23 = getelementptr inbounds [1000 x double], [1000 x double]* %7, i64 0, i64 0
%24 = call i32 @input(i32 %19, i8** %20, double** %22, double* %23, i32* %14, i32* %13)
%25 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 0
%26 = bitcast [1000 x double]* %25 to double**
%27 = load i32, i32* %14
%28 = load i32, i32* %13
%29 = call i32 @printMAT(double** %26, i32 %27, i32 %28)
%30 = getelementptr inbounds [1000 x double], [1000 x double]* %7, i64 0, i64 0
%31 = load i32, i32* %14
%32 = call i32 @printVET(double* %30, i32 %31)
%33 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 0
%34 = bitcast [1000 x double]* %33 to double**
%35 = getelementptr inbounds [1000 x double], [1000 x double]* %8, i64 0, i64 0
%36 = load i32, i32* %14
%37 = load i32, i32* %13
%38 = call double @sigmaArray(double** %34, double* %35, i32 %36, i32 %37)
store double %38, double* %10
store i32 0, i32* %15
br label %39
39: ; preds = %81, %2
%40 = load i32, i32* %15
%41 = load i32, i32* %13
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %84
43: ; preds = %39
%44 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 0
%45 = bitcast [1000 x double]* %44 to double**
%46 = getelementptr inbounds [1000 x double], [1000 x double]* %8, i64 0, i64 0
%47 = getelementptr inbounds [1000 x i32], [1000 x i32]* %12, i64 0, i64 0
%48 = load i32, i32* %15
%49 = load i32, i32* %14
%50 = load i32, i32* %13
%51 = call i32 @permuta(double** %45, double* %46, i32* %47, i32 %48, i32 %49, i32 %50)
store i32 %51, i32* %16
%52 = load i32, i32* %16
%53 = icmp eq i32 %52, 1
br i1 %53, label %54, label %55
54: ; preds = %43
br label %84
55: ; preds = %43
%56 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 0
%57 = bitcast [1000 x double]* %56 to double**
%58 = getelementptr inbounds [1000 x double], [1000 x double]* %8, i64 0, i64 0
%59 = getelementptr inbounds [1000 x double], [1000 x double]* %9, i64 0, i64 0
%60 = load double, double* %10
%61 = load i32, i32* %15
%62 = load i32, i32* %14
%63 = load i32, i32* %13
%64 = call double @calculaUSigmaGama(double** %57, double* %58, double* %59, double %60, i32 %61, i32 %62, i32 %63)
store double %64, double* %11
%65 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 0
%66 = bitcast [1000 x double]* %65 to double**
%67 = getelementptr inbounds [1000 x double], [1000 x double]* %7, i64 0, i64 0
%68 = getelementptr inbounds [1000 x double], [1000 x double]* %9, i64 0, i64 0
%69 = load double, double* %11
%70 = load i32, i32* %15
%71 = load i32, i32* %14
%72 = load i32, i32* %13
%73 = call i32 @produtoQA(double** %66, double* %67, double* %68, double %69, i32 %70, i32 %71, i32 %72)
%74 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 0
%75 = bitcast [1000 x double]* %74 to double**
%76 = getelementptr inbounds [1000 x double], [1000 x double]* %8, i64 0, i64 0
%77 = load i32, i32* %15
%78 = load i32, i32* %14
%79 = load i32, i32* %13
%80 = call i32 @sigmaRecalc(double** %75, double* %76, i32 %77, i32 %78, i32 %79)
br label %81
81: ; preds = %55
%82 = load i32, i32* %15
%83 = add nsw i32 %82, 1
store i32 %83, i32* %15
br label %39
84: ; preds = %54, %39
%85 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 0
%86 = bitcast [1000 x double]* %85 to double**
%87 = getelementptr inbounds [1000 x double], [1000 x double]* %7, i64 0, i64 0
%88 = getelementptr inbounds [1000 x i32], [1000 x i32]* %12, i64 0, i64 0
%89 = load double, double* %10
%90 = load i32, i32* %15
%91 = load i32, i32* %14
%92 = load i32, i32* %13
%93 = call i32 @solution(double** %86, double* %87, i32* %88, double %89, i32 %90, i32 %91, i32 %92)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [1000 x [1000 x double]]
%4 = alloca [1000 x double]
%5 = alloca [1000 x double]
%6 = alloca [1000 x double]
%7 = alloca [1000 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = bitcast [1000 x [1000 x double]]* %3 to i8*
%11 = bitcast [1000 x double]* %4 to i8*
%12 = bitcast [1000 x double]* %5 to i8*
%13 = bitcast [1000 x double]* %6 to i8*
%14 = bitcast [1000 x i32]* %7 to i8*
%15 = bitcast i32* %8 to i8*
%16 = bitcast i32* %9 to i8*
%17 = tail call i32 @use(i32 %0)
%18 = bitcast [1000 x [1000 x double]]* %3 to double**
%19 = getelementptr inbounds [1000 x double], [1000 x double]* %4, i64 0, i64 0
%20 = call i32 @input(i32 %0, i8** %1, double** %18, double* %19, i32* %9, i32* %8)
%21 = load i32, i32* %9
%22 = load i32, i32* %8
%23 = call i32 @printMAT(double** %18, i32 %21, i32 %22)
%24 = load i32, i32* %9
%25 = call i32 @printVET(double* %19, i32 %24)
%26 = getelementptr inbounds [1000 x double], [1000 x double]* %5, i64 0, i64 0
%27 = load i32, i32* %9
%28 = load i32, i32* %8
%29 = call double @sigmaArray(double** %18, double* %26, i32 %27, i32 %28)
%30 = getelementptr inbounds [1000 x i32], [1000 x i32]* %7, i64 0, i64 0
%31 = load i32, i32* %8
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %56
33: ; preds = %2
%34 = getelementptr inbounds [1000 x double], [1000 x double]* %6, i64 0, i64 0
br label %35
35: ; preds = %33, %43
%36 = phi i32 [ %31, %33 ], [ %54, %43 ]
%37 = phi i32 [ 0, %33 ], [ %53, %43 ]
%38 = load i32, i32* %9
%39 = call i32 @permuta(double** %18, double* %26, i32* %30, i32 %37, i32 %38, i32 %36)
%40 = icmp eq i32 %39, 1
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = load i32, i32* %8
br label %56
43: ; preds = %35
%44 = load i32, i32* %9
%45 = load i32, i32* %8
%46 = call double @calculaUSigmaGama(double** %18, double* %26, double* %34, double %29, i32 %37, i32 %44, i32 %45)
%47 = load i32, i32* %9
%48 = load i32, i32* %8
%49 = call i32 @produtoQA(double** %18, double* %19, double* %34, double %46, i32 %37, i32 %47, i32 %48)
%50 = load i32, i32* %9
%51 = load i32, i32* %8
%52 = call i32 @sigmaRecalc(double** %18, double* %26, i32 %37, i32 %50, i32 %51)
%53 = add nuw nsw i32 %37, 1
%54 = load i32, i32* %8
%55 = icmp slt i32 %53, %54
br i1 %55, label %35, label %56
56: ; preds = %43, %41, %2
%57 = phi i32 [ %31, %2 ], [ %42, %41 ], [ %54, %43 ]
%58 = phi i32 [ 0, %2 ], [ %37, %41 ], [ %53, %43 ]
%59 = load i32, i32* %9
%60 = call i32 @solution(double** %18, double* %19, i32* %30, double %29, i32 %58, i32 %59, i32 %57)
ret i32 0
}