#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 maxIndex(double *, int, int);
int /*<<< orphan*/ switchCol(double **, int *, int, int, int);
void permuta(double A[1000][1000], double sigma[1000], int ordem[1000],
             int index, int n, int m) {
  int i, j, k;
  double aux;
  double max = sigma[index];
  k = maxIndex(sigma, index, m);
  if (k == index)
    return;
  switchCol(A, ordem, index, k, n);
}


x86 assembly (clang, -O0):
<permuta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1040 <maxIndex@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1174 <permuta+0x54>
jmp    118b <permuta+0x6b>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1030 <switchCol@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<permuta>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %ecx,%esi
mov    %r9d,%edx
call   1040 <maxIndex@plt>
cmp    %ebp,%eax
jne    114e <permuta+0x2e>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
mov    %r14d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <switchCol@plt>

LLVM IR (-O0):
define void @permuta([1000 x double]* %0, double* %1, i32* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca [1000 x double]*
%8 = alloca double*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca double
store [1000 x double]* %0, [1000 x double]** %7
store double* %1, double** %8
store i32* %2, i32** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%18 = load double*, double** %8
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
store double %22, double* %17
%23 = load double*, double** %8
%24 = load i32, i32* %10
%25 = load i32, i32* %12
%26 = call i32 @maxIndex(double* %23, i32 %24, i32 %25)
store i32 %26, i32* %15
%27 = load i32, i32* %15
%28 = load i32, i32* %10
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %31
30: ; preds = %6
br label %39
31: ; preds = %6
%32 = load [1000 x double]*, [1000 x double]** %7
%33 = bitcast [1000 x double]* %32 to double**
%34 = load i32*, i32** %9
%35 = load i32, i32* %10
%36 = load i32, i32* %15
%37 = load i32, i32* %11
%38 = call i32 @switchCol(double** %33, i32* %34, i32 %35, i32 %36, i32 %37)
br label %39
39: ; preds = %31, %30
ret void
}

LLVM IR (-O2):
define void @permuta([1000 x double]* %0, double* %1, i32* %2, i32 %3, i32 %4, i32 %5) {
%7 = tail call i32 @maxIndex(double* %1, i32 %3, i32 %5)
%8 = icmp eq i32 %7, %3
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = bitcast [1000 x double]* %0 to double**
%11 = tail call i32 @switchCol(double** %10, i32* %2, i32 %3, i32 %7, i32 %4)
br label %12
12: ; preds = %6, %9
ret void
}