#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*/ retorna_maior(int **, int, int *, int *, int *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int x, y, A[3][3], maior = 0, linha, coluna;
  for (y = 0; y < 3; y++) {
    for (x = 0; x < 3; x++) {
      scanf("%d", &A[y][x]);
    }
  }
  printf("Elem\tLinha\tColuna\n");
  x = 3 * 3;
  while (x) {
    retorna_maior(A, 3, &maior, &linha, &coluna);
    printf("%d\t%d\t%d\n", maior, linha, coluna);
    A[linha][coluna] = -1;
    maior = 0;
    x--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    11af <main+0x7f>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    119c <main+0x6c>
movslq -0xc(%rbp),%rax
lea    -0x30(%rbp),%rsi
imul   $0xc,%rax,%rax
add    %rax,%rsi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe77(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115e <main+0x2e>
jmp    11a1 <main+0x71>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <main+0x1d>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x9,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     122e <main+0xfe>
lea    -0x30(%rbp),%rdi
mov    $0x3,%esi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x3c(%rbp),%r8
call   1030 <retorna_maior@plt>
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x3c(%rbp),%ecx
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x38(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x3c(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
movl   $0x0,-0x34(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    11c4 <main+0x94>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movl   $0x0,0x4(%rsp)
lea    0xea3(%rip),%r14
lea    0x10(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x20(%rsp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x24(%rsp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x28(%rsp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x2c(%rsp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x30(%rsp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0xe31(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffff7,%ebp
lea    0x4(%rsp),%r14
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%r13
lea    0xe07(%rip),%rbx
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0x3,%esi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1030 <retorna_maior@plt>
mov    0x4(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0xc(%rsp),%rax
movslq 0x8(%rsp),%rcx
lea    (%rax,%rax,2),%rax
lea    (%rsp,%rax,4),%rax
add    $0x10,%rax
movl   $0xffffffff,(%rax,%rcx,4)
movl   $0x0,0x4(%rsp)
inc    %ebp
jne    1200 <main+0xc0>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [19 x i8] c"Elem\09Linha\09Coluna\0A\00"
@.str.2 = [10 x i8] c"%d\09%d\09%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x [3 x i32]]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %3
br label %8
8: ; preds = %27, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %30
11: ; preds = %8
store i32 0, i32* %2
br label %12
12: ; preds = %23, %11
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %17
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %18, i64 0, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %15
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %12
26: ; preds = %12
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %8
30: ; preds = %8
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
store i32 9, i32* %2
br label %32
32: ; preds = %35, %30
%33 = load i32, i32* %2
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %51
35: ; preds = %32
%36 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 0
%37 = bitcast [3 x i32]* %36 to i32**
%38 = call i32 @retorna_maior(i32** %37, i32 3, i32* %5, i32* %6, i32* %7)
%39 = load i32, i32* %5
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %40, i32 %41)
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %44
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [3 x i32], [3 x i32]* %45, i64 0, i64 %47
store i32 -1, i32* %48
store i32 0, i32* %5
%49 = load i32, i32* %2
%50 = add nsw i32 %49, -1
store i32 %50, i32* %2
br label %32
51: ; preds = %32
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"%d\09%d\09%d\0A\00"
@str = [18 x i8] c"Elem\09Linha\09Coluna\00"
define i32 @main() {
%1 = alloca [3 x [3 x i32]]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [3 x [3 x i32]]* %1 to i8*
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0, i64 1
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0, i64 2
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%15 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 1, i64 0
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%17 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 1, i64 1
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
%19 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 1, i64 2
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %19)
%21 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 2, i64 0
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
%23 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 2, i64 1
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %23)
%25 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 2, i64 2
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %25)
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%28 = bitcast [3 x [3 x i32]]* %1 to i32**
br label %29
29: ; preds = %0, %29
%30 = phi i32 [ 9, %0 ], [ %41, %29 ]
%31 = call i32 @retorna_maior(i32** %28, i32 3, i32* %2, i32* %3, i32* %4)
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %32, i32 %33, i32 %34)
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %37, i64 %39
store i32 -1, i32* %40
store i32 0, i32* %2
%41 = add nsw i32 %30, -1
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %29
43: ; preds = %29
ret i32 0
}