#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int teste_permutacao(int **, int, int);
int main(int argc, char const *argv[]) {
  int m, n, cont, cont2, i, j, aux = 1;
  int A[100][100];
  printf("Digite a quantidade de linhas da matriz A:\n");
  scanf("%d", &m);
  printf("Digite a quantidade de colunas da matriz A:\n");
  scanf("%d", &n);
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      scanf("%d", &A[i][j]);
    }
  }
  if (teste_permutacao(A, m, n) == 1) {
    printf("é permutação!");
  } else {
    printf("não é permutação!");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x2c(%rbp)
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11fb <main+0xcb>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11e8 <main+0xb8>
movslq -0x24(%rbp),%rax
lea    -0x9c70(%rbp),%rsi
imul   $0x190,%rax,%rax
add    %rax,%rsi
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe57(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a2 <main+0x72>
jmp    11ed <main+0xbd>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118f <main+0x5f>
lea    -0x9c70(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <teste_permutacao@plt>
cmp    $0x1,%eax
jne    1227 <main+0xf7>
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
jmp    1233 <main+0x103>
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x9c70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c50,%rsp
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9d(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
test   %esi,%esi
jle    11f3 <main+0xb3>
lea    0x10(%rsp),%r15
xor    %r12d,%r12d
lea    0xe5c(%rip),%r14
jmp    11c3 <main+0x83>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r12
movslq %esi,%rax
add    $0x190,%r15
cmp    %rax,%r12
jge    11f3 <main+0xb3>
test   %edx,%edx
jle    11b0 <main+0x70>
mov    %r15,%r13
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rdx
add    $0x4,%r13
cmp    %rdx,%rbx
jl     11d0 <main+0x90>
mov    0xc(%rsp),%esi
jmp    11b0 <main+0x70>
lea    0x10(%rsp),%rdi
call   1050 <teste_permutacao@plt>
cmp    $0x1,%eax
lea    0xe01(%rip),%rax
lea    0xdf5(%rip),%rdi
cmove  %rax,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x9c50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Digite a quantidade de linhas da matriz A:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [45 x i8] c"Digite a quantidade de colunas da matriz A:\0A\00"
@.str.3 = [17 x i8] c"\C3\A9 permuta\C3\A7\C3\A3o!\00"
@.str.4 = [22 x i8] c"n\C3\A3o \C3\A9 permuta\C3\A7\C3\A3o!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [100 x [100 x i32]]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %12
%14 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%16 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
store i32 0, i32* %10
br label %18
18: ; preds = %39, %2
%19 = load i32, i32* %10
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %42
22: ; preds = %18
store i32 0, i32* %11
br label %23
23: ; preds = %35, %22
%24 = load i32, i32* %11
%25 = load i32, i32* %7
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %38
27: ; preds = %23
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %13, i64 0, i64 %29
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [100 x i32], [100 x i32]* %30, i64 0, i64 %32
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %33)
br label %35
35: ; preds = %27
%36 = load i32, i32* %11
%37 = add nsw i32 %36, 1
store i32 %37, i32* %11
br label %23
38: ; preds = %23
br label %39
39: ; preds = %38
%40 = load i32, i32* %10
%41 = add nsw i32 %40, 1
store i32 %41, i32* %10
br label %18
42: ; preds = %18
%43 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %13, i64 0, i64 0
%44 = bitcast [100 x i32]* %43 to i32**
%45 = load i32, i32* %6
%46 = load i32, i32* %7
%47 = call i32 @teste_permutacao(i32** %44, i32 %45, i32 %46)
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %51
49: ; preds = %42
%50 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %53
51: ; preds = %42
%52 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %53
53: ; preds = %51, %49
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [17 x i8] c"\C3\A9 permuta\C3\A7\C3\A3o!\00"
@.str.4 = [22 x i8] c"n\C3\A3o \C3\A9 permuta\C3\A7\C3\A3o!\00"
@str = [43 x i8] c"Digite a quantidade de linhas da matriz A:\00"
@str.5 = [44 x i8] c"Digite a quantidade de colunas da matriz A:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x [100 x i32]]
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast [100 x [100 x i32]]* %5 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.5, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%13 = load i32, i32* %3
%14 = icmp sgt i32 %13, 0
%15 = load i32, i32* %4
br i1 %14, label %16, label %37
16: ; preds = %2, %31
%17 = phi i32 [ %32, %31 ], [ %13, %2 ]
%18 = phi i32 [ %33, %31 ], [ %15, %2 ]
%19 = phi i64 [ %34, %31 ], [ 0, %2 ]
%20 = icmp sgt i32 %18, 0
br i1 %20, label %21, label %31
21: ; preds = %16, %21
%22 = phi i64 [ %25, %21 ], [ 0, %16 ]
%23 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %5, i64 0, i64 %19, i64 %22
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = add nuw nsw i64 %22, 1
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %21, label %29
29: ; preds = %21
%30 = load i32, i32* %3
br label %31
31: ; preds = %29, %16
%32 = phi i32 [ %30, %29 ], [ %17, %16 ]
%33 = phi i32 [ %26, %29 ], [ %18, %16 ]
%34 = add nuw nsw i64 %19, 1
%35 = sext i32 %32 to i64
%36 = icmp slt i64 %34, %35
br i1 %36, label %16, label %37
37: ; preds = %31, %2
%38 = phi i32 [ %15, %2 ], [ %33, %31 ]
%39 = phi i32 [ %13, %2 ], [ %32, %31 ]
%40 = bitcast [100 x [100 x i32]]* %5 to i32**
%41 = call i32 @teste_permutacao(i32** %40, i32 %39, i32 %38)
%42 = icmp eq i32 %41, 1
%43 = select i1 %42, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0)
%44 = call i32 @printf(i8* dereferenceable(1) %43)
ret i32 0
}