#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 main() {
  int mat[3][3], i, j;
  printf("Matriz Quadrada 3x3:\n\n");
  for (i = 0; i < 3; i++)
    for (j = 0; j < 3; j++) {
      printf("mat[%d][%d] = ", i + 1, j + 1);
      scanf("%i", &mat[i][j]);
    }
  printf("Mostrando a Diagonal Prncipal:\n\n");
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      if (i == j)
        printf("%5d %3c", mat[i][j], ' ');
      else
        printf("    -   ");
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    11c0 <main+0xa0>
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    11ad <main+0x8d>
mov    -0x34(%rbp),%esi
add    $0x1,%esi
mov    -0x38(%rbp),%edx
add    $0x1,%edx
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x34(%rbp),%rax
lea    -0x30(%rbp),%rsi
imul   $0xc,%rax,%rax
add    %rax,%rsi
movslq -0x38(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe8c(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1155 <main+0x35>
jmp    11b2 <main+0x92>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1144 <main+0x24>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    1267 <main+0x147>
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    124b <main+0x12b>
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
jne    122a <main+0x10a>
movslq -0x34(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe31(%rip),%rdi
mov    $0x20,%edx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1238 <main+0x118>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123d <main+0x11d>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11e6 <main+0xc6>
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11d5 <main+0xb5>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xed5(%rip),%rdi
call   1040 <puts@plt>
lea    0xea6(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9a(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xdaa(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%esi
lea    0xd74(%rip),%r14
mov    %r14,%rdi
mov    $0x20,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd66(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %r14,%rdi
mov    $0x20,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp),%esi
mov    %r14,%rdi
mov    $0x20,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Matriz Quadrada 3x3:\0A\0A\00"
@.str.1 = [15 x i8] c"mat[%d][%d] = \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [33 x i8] c"Mostrando a Diagonal Prncipal:\0A\0A\00"
@.str.4 = [8 x i8] c"%5d %3c\00"
@.str.5 = [9 x i8] c" - \00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x [3 x i32]]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %6
6: ; preds = %30, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %33
9: ; preds = %6
store i32 0, i32* %4
br label %10
10: ; preds = %26, %9
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %29
13: ; preds = %10
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %17)
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 %20
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %21, i64 0, i64 %23
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %24)
br label %26
26: ; preds = %13
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %10
29: ; preds = %10
br label %30
30: ; preds = %29
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %6
33: ; preds = %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %35
35: ; preds = %63, %33
%36 = load i32, i32* %3
%37 = icmp slt i32 %36, 3
br i1 %37, label %38, label %66
38: ; preds = %35
store i32 0, i32* %4
br label %39
39: ; preds = %58, %38
%40 = load i32, i32* %4
%41 = icmp slt i32 %40, 3
br i1 %41, label %42, label %61
42: ; preds = %39
%43 = load i32, i32* %3
%44 = load i32, i32* %4
%45 = icmp eq i32 %43, %44
br i1 %45, label %46, label %55
46: ; preds = %42
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 %48
%50 = load i32, i32* %4
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [3 x i32], [3 x i32]* %49, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %53, i32 32)
br label %57
55: ; preds = %42
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %57
57: ; preds = %55, %46
br label %58
58: ; preds = %57
%59 = load i32, i32* %4
%60 = add nsw i32 %59, 1
store i32 %60, i32* %4
br label %39
61: ; preds = %39
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %63
63: ; preds = %61
%64 = load i32, i32* %3
%65 = add nsw i32 %64, 1
store i32 %65, i32* %3
br label %35
66: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"mat[%d][%d] = \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.4 = [8 x i8] c"%5d %3c\00"
@.str.5 = [9 x i8] c" - \00"
@str = [22 x i8] c"Matriz Quadrada 3x3:\0A\00"
@str.7 = [32 x i8] c"Mostrando a Diagonal Prncipal:\0A\00"
define i32 @main() {
%1 = alloca [3 x [3 x i32]]
%2 = bitcast [3 x [3 x i32]]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 1)
%5 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 2)
%8 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0, i64 1
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 3)
%11 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0, i64 2
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 1)
%14 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 1, i64 0
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 2)
%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.2, i64 0, i64 0), i32* %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 3)
%20 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 1, i64 2
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 1)
%23 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 2, i64 0
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 2)
%26 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 2, i64 1
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 3)
%29 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 2, i64 2
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %29)
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
%32 = load i32, i32* %5
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %32, i32 32)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%36 = call i32 @putchar(i32 10)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%38 = load i32, i32* %17
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %38, i32 32)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%41 = call i32 @putchar(i32 10)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%44 = load i32, i32* %29
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %44, i32 32)
%46 = call i32 @putchar(i32 10)
ret i32 0
}