#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 i, j, mat[3][3], vet[6] = {0};
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      do {
        printf("entre com o peso em tonaladas segido do codigo >=1 e <=6: ");
        scanf("%d", &mat[i][j]);
        vet[mat[i][j] % 10 - 1] += (mat[i][j] / 10);
      } while (mat[i][j] % 10 < 1 || mat[i][j] % 10 > 6 || mat[i][j] < 0);
    }
  }
  printf("%d tonaladas de cobre\n", vet[0]);
  printf("%d tonaladas de carvão\n", vet[1]);
  printf("%d tonaladas de chumbo\n", vet[2]);
  printf("%d tonaladas de ferro\n", vet[3]);
  printf("%d tonaladas de aluminio\n", vet[4]);
  printf("%d tonaladas de niquel\n", vet[5]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    129c <main+0x16c>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    1289 <main+0x159>
jmp    1176 <main+0x46>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x8(%rbp),%rax
lea    -0x30(%rbp),%rsi
imul   $0xc,%rax,%rax
add    %rax,%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe96(%rip),%rdi
call   1050 <scanf@plt>
movslq -0x8(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
movslq -0x8(%rbp),%rdx
lea    -0x30(%rbp),%rax
imul   $0xc,%rdx,%rdx
add    %rdx,%rax
movslq -0xc(%rbp),%rdx
mov    (%rax,%rdx,4),%eax
mov    $0xa,%esi
cltd
idiv   %esi
sub    $0x1,%edx
movslq %edx,%rax
add    -0x50(%rbp,%rax,4),%ecx
mov    %ecx,-0x50(%rbp,%rax,4)
movslq -0x8(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0x1,%al
cmp    $0x1,%edx
mov    %al,-0x51(%rbp)
jl     126b <main+0x13b>
movslq -0x8(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0x1,%al
cmp    $0x6,%edx
mov    %al,-0x51(%rbp)
jg     126b <main+0x13b>
movslq -0x8(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
setl   %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    1176 <main+0x46>
jmp    127b <main+0x14b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1167 <main+0x37>
jmp    128e <main+0x15e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1156 <main+0x26>
mov    -0x50(%rbp),%esi
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4c(%rbp),%esi
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%esi
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x44(%rbp),%esi
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%esi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xebc(%rip),%r14
lea    0xef0(%rip),%r15
xor    %r12d,%r12d
xchg   %ax,%ax
lea    (%r12,%r12,2),%r13
lea    (%rsp,%r13,4),%rbx
add    $0x20,%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movslq (%rbx),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %eax,%esi
sub    %edx,%esi
movslq %esi,%rsi
add    %ecx,-0x4(%rsp,%rsi,4)
neg    %edx
lea    (%rax,%rdx,1),%ecx
add    $0xfffffff9,%ecx
cmp    $0xfffffffa,%ecx
jb     1160 <main+0x40>
test   %eax,%eax
js     1160 <main+0x40>
lea    (%rsp,%r13,4),%rbx
add    $0x24,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movslq (%rbx),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %eax,%esi
sub    %edx,%esi
movslq %esi,%rsi
add    %ecx,-0x4(%rsp,%rsi,4)
neg    %edx
lea    (%rax,%rdx,1),%ecx
add    $0xfffffff9,%ecx
cmp    $0xfffffffa,%ecx
jb     11c0 <main+0xa0>
test   %eax,%eax
js     11c0 <main+0xa0>
lea    (%rsp,%r13,4),%rbx
add    $0x28,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movslq (%rbx),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %eax,%esi
sub    %edx,%esi
movslq %esi,%rsi
add    %ecx,-0x4(%rsp,%rsi,4)
neg    %edx
lea    (%rax,%rdx,1),%ecx
add    $0xfffffff9,%ecx
cmp    $0xfffffffa,%ecx
jb     1220 <main+0x100>
test   %eax,%eax
js     1220 <main+0x100>
add    $0x1,%r12
cmp    $0x3,%r12
jne    1150 <main+0x30>
mov    (%rsp),%esi
lea    0xdb8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xdbd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xdc4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xdca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xdcf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xdd7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [59 x i8] c"entre com o peso em tonaladas segido do codigo >=1 e <=6: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"%d tonaladas de cobre\0A\00"
@.str.3 = [25 x i8] c"%d tonaladas de carv\C3\A3o\0A\00"
@.str.4 = [24 x i8] c"%d tonaladas de chumbo\0A\00"
@.str.5 = [23 x i8] c"%d tonaladas de ferro\0A\00"
@.str.6 = [26 x i8] c"%d tonaladas de aluminio\0A\00"
@.str.7 = [24 x i8] c"%d tonaladas de niquel\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x [3 x i32]]
%5 = alloca [6 x i32]
store i32 0, i32* %1
%6 = bitcast [6 x i32]* %5 to i8*
store i32 0, i32* %2
br label %7
7: ; preds = %81, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %84
10: ; preds = %7
store i32 0, i32* %3
br label %11
11: ; preds = %77, %10
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %80
14: ; preds = %11
br label %15
15: ; preds = %74, %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %18
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %19, i64 0, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %25
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [3 x i32], [3 x i32]* %26, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = sdiv i32 %30, 10
%32 = load i32, i32* %2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %33
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [3 x i32], [3 x i32]* %34, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = srem i32 %38, 10
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = add nsw i32 %43, %31
store i32 %44, i32* %42
br label %45
45: ; preds = %15
%46 = load i32, i32* %2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %47
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [3 x i32], [3 x i32]* %48, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = srem i32 %52, 10
%54 = icmp slt i32 %53, 1
br i1 %54, label %74, label %55
55: ; preds = %45
%56 = load i32, i32* %2
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %57
%59 = load i32, i32* %3
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [3 x i32], [3 x i32]* %58, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = srem i32 %62, 10
%64 = icmp sgt i32 %63, 6
br i1 %64, label %74, label %65
65: ; preds = %55
%66 = load i32, i32* %2
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %67
%69 = load i32, i32* %3
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [3 x i32], [3 x i32]* %68, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = icmp slt i32 %72, 0
br label %74
74: ; preds = %65, %55, %45
%75 = phi i1 [ true, %55 ], [ true, %45 ], [ %73, %65 ]
br i1 %75, label %15, label %76
76: ; preds = %74
br label %77
77: ; preds = %76
%78 = load i32, i32* %3
%79 = add nsw i32 %78, 1
store i32 %79, i32* %3
br label %11
80: ; preds = %11
br label %81
81: ; preds = %80
%82 = load i32, i32* %2
%83 = add nsw i32 %82, 1
store i32 %83, i32* %2
br label %7
84: ; preds = %7
%85 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
%86 = load i32, i32* %85
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %86)
%88 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 1
%89 = load i32, i32* %88
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %89)
%91 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 2
%92 = load i32, i32* %91
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %92)
%94 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 3
%95 = load i32, i32* %94
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %95)
%97 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 4
%98 = load i32, i32* %97
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %98)
%100 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 5
%101 = load i32, i32* %100
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %101)
ret i32 0
}

LLVM IR (-O2):
@.str = [59 x i8] c"entre com o peso em tonaladas segido do codigo >=1 e <=6: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"%d tonaladas de cobre\0A\00"
@.str.3 = [25 x i8] c"%d tonaladas de carv\C3\A3o\0A\00"
@.str.4 = [24 x i8] c"%d tonaladas de chumbo\0A\00"
@.str.5 = [23 x i8] c"%d tonaladas de ferro\0A\00"
@.str.6 = [26 x i8] c"%d tonaladas de aluminio\0A\00"
@.str.7 = [24 x i8] c"%d tonaladas de niquel\0A\00"
define i32 @main() {
%1 = alloca [3 x [3 x i32]]
%2 = alloca [6 x i32]
%3 = bitcast [3 x [3 x i32]]* %1 to i8*
%4 = bitcast [6 x i32]* %2 to i8*
br label %5
5: ; preds = %0, %57
%6 = phi i64 [ 0, %0 ], [ %58, %57 ]
%7 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %6, i64 0
br label %8
8: ; preds = %5, %8
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 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* %7)
%11 = load i32, i32* %7
%12 = sdiv i32 %11, 10
%13 = srem i32 %11, 10
%14 = add nsw i32 %13, -1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = add nsw i32 %17, %12
store i32 %18, i32* %16
%19 = add nsw i32 %13, -7
%20 = icmp ult i32 %19, -6
%21 = icmp slt i32 %11, 0
%22 = select i1 %20, i1 true, i1 %21
br i1 %22, label %8, label %23
23: ; preds = %8
%24 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %6, i64 1
br label %25
25: ; preds = %25, %23
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %24)
%28 = load i32, i32* %24
%29 = sdiv i32 %28, 10
%30 = srem i32 %28, 10
%31 = add nsw i32 %30, -1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = add nsw i32 %34, %29
store i32 %35, i32* %33
%36 = add nsw i32 %30, -7
%37 = icmp ult i32 %36, -6
%38 = icmp slt i32 %28, 0
%39 = select i1 %37, i1 true, i1 %38
br i1 %39, label %25, label %40
40: ; preds = %25
%41 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 %6, i64 2
br label %42
42: ; preds = %42, %40
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%44 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %41)
%45 = load i32, i32* %41
%46 = sdiv i32 %45, 10
%47 = srem i32 %45, 10
%48 = add nsw i32 %47, -1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = add nsw i32 %51, %46
store i32 %52, i32* %50
%53 = add nsw i32 %47, -7
%54 = icmp ult i32 %53, -6
%55 = icmp slt i32 %45, 0
%56 = select i1 %54, i1 true, i1 %55
br i1 %56, label %42, label %57
57: ; preds = %42
%58 = add nuw nsw i64 %6, 1
%59 = icmp eq i64 %58, 3
br i1 %59, label %60, label %5
60: ; preds = %57
%61 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%62 = load i32, i32* %61
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %62)
%64 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 1
%65 = load i32, i32* %64
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %65)
%67 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 2
%68 = load i32, i32* %67
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %68)
%70 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 3
%71 = load i32, i32* %70
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %71)
%73 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 4
%74 = load i32, i32* %73
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %74)
%76 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 5
%77 = load i32, i32* %76
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %77)
ret i32 0
}