int main() {
  int tab[8][8], pecas[7] = {0}, i, j;
  char peca[7][8] = {"Peão",   "torre",  "Rei", "bispo",
                     "rainha", "cavalo", "vago"};
  for (i = 0; i < 8; i++) {
    printf("menu: 1-peão 2-torre 3-rei 4-bispo 5-rainha 6-cavalo 7-vago\n");
    for (j = 0; j < 8; j++) {
      do {
        printf("entre com qual peça ou se esta vago a posição [%d][%d]: ",
               i + 1, j + 1);
        scanf("%d", &tab[i][j]);
        pecas[tab[i][j] - 1]++;
        if (tab[i][j] < 1 || tab[i][j] > 7)
          printf("codigo invalido\n");
      } while (tab[i][j] < 1 || tab[i][j] > 7);
    }
  }
  for (i = 0; i < 7; i++)
    printf("%s: %d\n", peca[i], pecas[i]);
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x1c,%edx
call   1050 <memset@plt>
lea    -0x170(%rbp),%rdi
lea    0xe7d(%rip),%rsi
mov    $0x38,%edx
call   1060 <memcpy@plt>
movl   $0x0,-0x134(%rbp)
cmpl   $0x8,-0x134(%rbp)
jge    134a <main+0x1fa>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x138(%rbp)
cmpl   $0x8,-0x138(%rbp)
jge    1331 <main+0x1e1>
jmp    11ce <main+0x7e>
mov    -0x134(%rbp),%esi
add    $0x1,%esi
mov    -0x138(%rbp),%edx
add    $0x1,%edx
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x134(%rbp),%rax
lea    -0x110(%rbp),%rsi
shl    $0x5,%rax
add    %rax,%rsi
movslq -0x138(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
movslq -0x134(%rbp),%rcx
lea    -0x110(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x138(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
sub    $0x1,%eax
cltq
mov    -0x130(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x130(%rbp,%rax,4)
movslq -0x134(%rbp),%rcx
lea    -0x110(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x138(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jl     12a0 <main+0x150>
movslq -0x134(%rbp),%rcx
lea    -0x110(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x138(%rbp),%rcx
cmpl   $0x7,(%rax,%rcx,4)
jle    12ae <main+0x15e>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b3 <main+0x163>
movslq -0x134(%rbp),%rax
lea    -0x110(%rbp),%rcx
shl    $0x5,%rax
add    %rax,%rcx
movslq -0x138(%rbp),%rdx
mov    $0x1,%al
cmpl   $0x1,(%rcx,%rdx,4)
mov    %al,-0x171(%rbp)
jl     130a <main+0x1ba>
movslq -0x134(%rbp),%rcx
lea    -0x110(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x138(%rbp),%rcx
cmpl   $0x7,(%rax,%rcx,4)
setg   %al
mov    %al,-0x171(%rbp)
mov    -0x171(%rbp),%al
test   $0x1,%al
jne    11ce <main+0x7e>
jmp    131d <main+0x1cd>
mov    -0x138(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x138(%rbp)
jmp    11bc <main+0x6c>
jmp    1336 <main+0x1e6>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    1197 <main+0x47>
movl   $0x0,-0x134(%rbp)
cmpl   $0x7,-0x134(%rbp)
jge    13a6 <main+0x256>
movslq -0x134(%rbp),%rax
lea    -0x170(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
movslq -0x134(%rbp),%rax
mov    -0x130(%rbp,%rax,4),%edx
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    1354 <main+0x204>
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1030 <system@plt>
xor    %eax,%eax
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x178,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0xc(%rsp)
movaps %xmm0,(%rsp)
mov    0xecc(%rip),%rax
mov    %rax,0x60(%rsp)
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe94(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe78(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0xea4(%rip),%r15
lea    0xed9(%rip),%r13
lea    0xf20(%rip),%r12
xor    %r14d,%r14d
jmp    11bd <main+0x7d>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%r14
cmp    $0x8,%rbx
je     1250 <main+0x110>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0x1(%r14),%rbx
xor    %ebp,%ebp
mov    %r14,0x28(%rsp)
jmp    11eb <main+0xab>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x8,%rbp
mov    0x28(%rsp),%r14
je     11b0 <main+0x70>
mov    %r14,%rax
shl    $0x5,%rax
add    %rsp,%rax
add    $0x70,%rax
lea    (%rax,%rbp,4),%r14
add    $0x1,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movslq (%r14),%rax
addl   $0x1,-0x4(%rsp,%rax,4)
add    $0xfffffff8,%eax
cmp    $0xfffffff8,%eax
ja     11e0 <main+0xa0>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    (%r14),%eax
add    $0xfffffff8,%eax
cmp    $0xfffffff9,%eax
jb     1210 <main+0xd0>
jmp    11e0 <main+0xa0>
mov    (%rsp),%edx
lea    0xe1d(%rip),%rbx
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x38(%rsp),%rsi
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x40(%rsp),%rsi
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x48(%rsp),%rsi
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x50(%rsp),%rsi
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x58(%rsp),%rsi
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x60(%rsp),%rsi
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd9d(%rip),%rdi
xor    %eax,%eax
call   1040 <system@plt>
xor    %eax,%eax
add    $0x178,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.peca = [7 x [8 x i8]] [[8 x i8] c"Pe\C3\A3o\00\00\00", [8 x i8] c"torre\00\00\00", [8 x i8] c"Rei\00\00\00\00\00", [8 x i8] c"bispo\00\00\00", [8 x i8] c"rainha\00\00", [8 x i8] c"cavalo\00\00", [8 x i8] c"vago\00\00\00\00"]
@.str = [62 x i8] c"menu: 1-pe\C3\A3o 2-torre 3-rei 4-bispo 5-rainha 6-cavalo 7-vago\0A\00"
@.str.1 = [60 x i8] c"entre com qual pe\C3\A7a ou se esta vago a posi\C3\A7\C3\A3o [%d][%d]: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [17 x i8] c"codigo invalido\0A\00"
@.str.4 = [8 x i8] c"%s: %d\0A\00"
@.str.5 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x [8 x i32]]
%3 = alloca [7 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [7 x [8 x i8]]
store i32 0, i32* %1
%7 = bitcast [7 x i32]* %3 to i8*
%8 = bitcast [7 x [8 x i8]]* %6 to i8*
store i32 0, i32* %4
br label %9
9: ; preds = %88, %0
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 8
br i1 %11, label %12, label %91
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %14
14: ; preds = %84, %12
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 8
br i1 %16, label %17, label %87
17: ; preds = %14
br label %18
18: ; preds = %81, %17
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %22)
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %2, i64 0, i64 %25
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [8 x i32], [8 x i32]* %26, i64 0, i64 %28
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %29)
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %2, i64 0, i64 %32
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [8 x i32], [8 x i32]* %33, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = sub nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = add nsw i32 %41, 1
store i32 %42, i32* %40
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %2, i64 0, i64 %44
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [8 x i32], [8 x i32]* %45, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = icmp slt i32 %49, 1
br i1 %50, label %60, label %51
51: ; preds = %18
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %2, i64 0, i64 %53
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [8 x i32], [8 x i32]* %54, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = icmp sgt i32 %58, 7
br i1 %59, label %60, label %62
60: ; preds = %51, %18
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %62
62: ; preds = %60, %51
br label %63
63: ; preds = %62
%64 = load i32, i32* %4
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %2, i64 0, i64 %65
%67 = load i32, i32* %5
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [8 x i32], [8 x i32]* %66, i64 0, i64 %68
%70 = load i32, i32* %69
%71 = icmp slt i32 %70, 1
br i1 %71, label %81, label %72
72: ; preds = %63
%73 = load i32, i32* %4
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %2, i64 0, i64 %74
%76 = load i32, i32* %5
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [8 x i32], [8 x i32]* %75, i64 0, i64 %77
%79 = load i32, i32* %78
%80 = icmp sgt i32 %79, 7
br label %81
81: ; preds = %72, %63
%82 = phi i1 [ true, %63 ], [ %80, %72 ]
br i1 %82, label %18, label %83
83: ; preds = %81
br label %84
84: ; preds = %83
%85 = load i32, i32* %5
%86 = add nsw i32 %85, 1
store i32 %86, i32* %5
br label %14
87: ; preds = %14
br label %88
88: ; preds = %87
%89 = load i32, i32* %4
%90 = add nsw i32 %89, 1
store i32 %90, i32* %4
br label %9
91: ; preds = %9
store i32 0, i32* %4
br label %92
92: ; preds = %105, %91
%93 = load i32, i32* %4
%94 = icmp slt i32 %93, 7
br i1 %94, label %95, label %108
95: ; preds = %92
%96 = load i32, i32* %4
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [7 x [8 x i8]], [7 x [8 x i8]]* %6, i64 0, i64 %97
%99 = getelementptr inbounds [8 x i8], [8 x i8]* %98, i64 0, i64 0
%100 = load i32, i32* %4
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 %101
%103 = load i32, i32* %102
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %99, i32 %103)
br label %105
105: ; preds = %95
%106 = load i32, i32* %4
%107 = add nsw i32 %106, 1
store i32 %107, i32* %4
br label %92
108: ; preds = %92
%109 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.peca = [7 x [8 x i8]] [[8 x i8] c"Pe\C3\A3o\00\00\00", [8 x i8] c"torre\00\00\00", [8 x i8] c"Rei\00\00\00\00\00", [8 x i8] c"bispo\00\00\00", [8 x i8] c"rainha\00\00", [8 x i8] c"cavalo\00\00", [8 x i8] c"vago\00\00\00\00"]
@.str.1 = [60 x i8] c"entre com qual pe\C3\A7a ou se esta vago a posi\C3\A7\C3\A3o [%d][%d]: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [8 x i8] c"%s: %d\0A\00"
@.str.5 = [6 x i8] c"pause\00"
@str = [61 x i8] c"menu: 1-pe\C3\A3o 2-torre 3-rei 4-bispo 5-rainha 6-cavalo 7-vago\00"
@str.6 = [16 x i8] c"codigo invalido\00"
define i32 @main() {
%1 = alloca [8 x [8 x i32]]
%2 = alloca [7 x i32]
%3 = alloca [7 x [8 x i8]]
%4 = bitcast [8 x [8 x i32]]* %1 to i8*
%5 = bitcast [7 x i32]* %2 to i8*
%6 = getelementptr inbounds [7 x [8 x i8]], [7 x [8 x i8]]* %3, i64 0, i64 0, i64 0
br label %7
7: ; preds = %0, %35
%8 = phi i64 [ 0, %0 ], [ %10, %35 ]
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%10 = add nuw nsw i64 %8, 1
%11 = trunc i64 %10 to i32
br label %14
12: ; preds = %19, %30
%13 = icmp eq i64 %16, 8
br i1 %13, label %35, label %14
14: ; preds = %7, %12
%15 = phi i64 [ 0, %7 ], [ %16, %12 ]
%16 = add nuw nsw i64 %15, 1
%17 = getelementptr inbounds [8 x [8 x i32]], [8 x [8 x i32]]* %1, i64 0, i64 %8, i64 %15
%18 = trunc i64 %16 to i32
br label %19
19: ; preds = %14, %30
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %18)
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %17)
%22 = load i32, i32* %17
%23 = add nsw i32 %22, -1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
store i32 %27, i32* %25
%28 = add i32 %22, -8
%29 = icmp ult i32 %28, -7
br i1 %29, label %30, label %12
30: ; preds = %19
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0))
%32 = load i32, i32* %17
%33 = add i32 %32, -8
%34 = icmp ult i32 %33, -7
br i1 %34, label %19, label %12
35: ; preds = %12
%36 = icmp eq i64 %10, 8
br i1 %36, label %37, label %7
37: ; preds = %35
%38 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 0
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %6, i32 %39)
%41 = getelementptr inbounds [7 x [8 x i8]], [7 x [8 x i8]]* %3, i64 0, i64 1, i64 0
%42 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 1
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %41, i32 %43)
%45 = getelementptr inbounds [7 x [8 x i8]], [7 x [8 x i8]]* %3, i64 0, i64 2, i64 0
%46 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 2
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %45, i32 %47)
%49 = getelementptr inbounds [7 x [8 x i8]], [7 x [8 x i8]]* %3, i64 0, i64 3, i64 0
%50 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 3
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %49, i32 %51)
%53 = getelementptr inbounds [7 x [8 x i8]], [7 x [8 x i8]]* %3, i64 0, i64 4, i64 0
%54 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 4
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %53, i32 %55)
%57 = getelementptr inbounds [7 x [8 x i8]], [7 x [8 x i8]]* %3, i64 0, i64 5, i64 0
%58 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 5
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %57, i32 %59)
%61 = getelementptr inbounds [7 x [8 x i8]], [7 x [8 x i8]]* %3, i64 0, i64 6, i64 0
%62 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 6
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %61, i32 %63)
%65 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}