#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 *, double);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  double M[12][12], soma = 0, cont_n = 0;
  int i, j, L;
  char T;
  scanf(" %c", &T);
  for (i = 0; i < 12; i++) {
    for (j = 0; j < 12; j++) {
      scanf(" %lf", &M[i][j]);
      if (i < 6) {
        if (i > j && j < 5) {
          soma += M[i][j];
          cont_n++;
        }
      } else if (i > 5) {
        if (j < 11 - i && j < 5) {
          soma += M[i][j];
          cont_n++;
        }
      }
    }
  }
  switch (T) {
  case 'S':
    printf("%0.1lf\n", soma);
    break;
  case 'M':
    printf("%0.1lf\n", soma / cont_n);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4c0,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x498(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x4a0(%rbp)
ff
lea    0xeb9(%rip),%rdi
lea    -0x4ad(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x4a4(%rbp)
cmpl   $0xc,-0x4a4(%rbp)
jge    12ee <main+0x1ce>
movl   $0x0,-0x4a8(%rbp)
cmpl   $0xc,-0x4a8(%rbp)
jge    12d5 <main+0x1b5>
movslq -0x4a4(%rbp),%rax
lea    -0x490(%rbp),%rsi
imul   $0x60,%rax,%rax
add    %rax,%rsi
movslq -0x4a8(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x6,-0x4a4(%rbp)
jge    1236 <main+0x116>
mov    -0x4a4(%rbp),%eax
cmp    -0x4a8(%rbp),%eax
jle    1231 <main+0x111>
cmpl   $0x5,-0x4a8(%rbp)
jge    1231 <main+0x111>
movslq -0x4a4(%rbp),%rcx
lea    -0x490(%rbp),%rax
imul   $0x60,%rcx,%rcx
add    %rcx,%rax
movslq -0x4a8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x498(%rbp),%xmm0
ff
movsd  %xmm0,-0x498(%rbp)
ff
movsd  0xddf(%rip),%xmm0
addsd  -0x4a0(%rbp),%xmm0
ff
movsd  %xmm0,-0x4a0(%rbp)
ff
jmp    12bc <main+0x19c>
cmpl   $0x5,-0x4a4(%rbp)
jle    12b7 <main+0x197>
mov    -0x4a8(%rbp),%eax
mov    $0xb,%ecx
sub    -0x4a4(%rbp),%ecx
cmp    %ecx,%eax
jge    12b2 <main+0x192>
cmpl   $0x5,-0x4a8(%rbp)
jge    12b2 <main+0x192>
movslq -0x4a4(%rbp),%rcx
lea    -0x490(%rbp),%rax
imul   $0x60,%rcx,%rcx
add    %rcx,%rax
movslq -0x4a8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x498(%rbp),%xmm0
ff
movsd  %xmm0,-0x498(%rbp)
ff
movsd  0xd5e(%rip),%xmm0
addsd  -0x4a0(%rbp),%xmm0
ff
movsd  %xmm0,-0x4a0(%rbp)
ff
jmp    12b7 <main+0x197>
jmp    12bc <main+0x19c>
jmp    12c1 <main+0x1a1>
mov    -0x4a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4a8(%rbp)
jmp    117e <main+0x5e>
jmp    12da <main+0x1ba>
mov    -0x4a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4a4(%rbp)
jmp    1167 <main+0x47>
movsbl -0x4ad(%rbp),%eax
mov    %eax,-0x4b4(%rbp)
sub    $0x4d,%eax
je     1336 <main+0x216>
jmp    1309 <main+0x1e9>
mov    -0x4b4(%rbp),%eax
sub    $0x53,%eax
jne    1352 <main+0x232>
jmp    131d <main+0x1fd>
movsd  -0x498(%rbp),%xmm0
ff
lea    0xce5(%rip),%rdi
call   1030 <printf@plt>
jmp    1352 <main+0x232>
movsd  -0x498(%rbp),%xmm0
ff
divsd  -0x4a0(%rbp),%xmm0
ff
lea    0xcc4(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x4c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4a8,%rsp
lea    0xed0(%rip),%rdi
lea    0xf(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
xorpd  %xmm0,%xmm0
lea    0x20(%rsp),%r15
lea    0xeb8(%rip),%r14
xor    %r13d,%r13d
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x10(%rsp)
jmp    1182 <main+0x62>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r13
add    $0x60,%r15
cmp    $0xc,%r13
je     1213 <main+0xf3>
mov    $0xb,%r12d
sub    %r13,%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    11c8 <main+0xa8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addsd  (%r15,%rbp,8),%xmm0
movsd  0x10(%rsp),%xmm1
addsd  0xe4c(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
add    $0x1,%rbp
add    $0x8,%rbx
cmp    $0xc,%rbp
je     1170 <main+0x50>
movsd  %xmm0,0x18(%rsp)
lea    (%r15,%rbx,1),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    $0x5,%r13
ja     1200 <main+0xe0>
cmp    %rbp,%r13
movsd  0x18(%rsp),%xmm0
jbe    11ba <main+0x9a>
cmp    $0x5,%rbp
jb     11a0 <main+0x80>
jmp    11ba <main+0x9a>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %r12,%rbp
movsd  0x18(%rsp),%xmm0
jae    11ba <main+0x9a>
cmp    $0x4,%rbp
jbe    11a0 <main+0x80>
jmp    11ba <main+0x9a>
movsbl 0xf(%rsp),%eax
cmp    $0x53,%eax
je     1228 <main+0x108>
cmp    $0x4d,%eax
jne    1234 <main+0x114>
divsd  0x10(%rsp),%xmm0
lea    0xde2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x4a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c" %c\00"
@.str.1 = [5 x i8] c" %lf\00"
@.str.2 = [8 x i8] c"%0.1lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [12 x [12 x double]]
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %1
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %4
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
store i32 0, i32* %5
br label %10
10: ; preds = %77, %0
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 12
br i1 %12, label %13, label %80
13: ; preds = %10
store i32 0, i32* %6
br label %14
14: ; preds = %73, %13
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 12
br i1 %16, label %17, label %76
17: ; preds = %14
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [12 x [12 x double]], [12 x [12 x double]]* %2, i64 0, i64 %19
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [12 x double], [12 x double]* %20, i64 0, i64 %22
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %23)
%25 = load i32, i32* %5
%26 = icmp slt i32 %25, 6
br i1 %26, label %27, label %47
27: ; preds = %17
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = icmp sgt i32 %28, %29
br i1 %30, label %31, label %46
31: ; preds = %27
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 5
br i1 %33, label %34, label %46
34: ; preds = %31
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [12 x [12 x double]], [12 x [12 x double]]* %2, i64 0, i64 %36
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [12 x double], [12 x double]* %37, i64 0, i64 %39
%41 = load double, double* %40
%42 = load double, double* %3
%43 = fadd double %42, %41
store double %43, double* %3
%44 = load double, double* %4
%45 = fadd double %44, 1.000000e+00
store double %45, double* %4
br label %46
46: ; preds = %34, %31, %27
br label %72
47: ; preds = %17
%48 = load i32, i32* %5
%49 = icmp sgt i32 %48, 5
br i1 %49, label %50, label %71
50: ; preds = %47
%51 = load i32, i32* %6
%52 = load i32, i32* %5
%53 = sub nsw i32 11, %52
%54 = icmp slt i32 %51, %53
br i1 %54, label %55, label %70
55: ; preds = %50
%56 = load i32, i32* %6
%57 = icmp slt i32 %56, 5
br i1 %57, label %58, label %70
58: ; preds = %55
%59 = load i32, i32* %5
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [12 x [12 x double]], [12 x [12 x double]]* %2, i64 0, i64 %60
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [12 x double], [12 x double]* %61, i64 0, i64 %63
%65 = load double, double* %64
%66 = load double, double* %3
%67 = fadd double %66, %65
store double %67, double* %3
%68 = load double, double* %4
%69 = fadd double %68, 1.000000e+00
store double %69, double* %4
br label %70
70: ; preds = %58, %55, %50
br label %71
71: ; preds = %70, %47
br label %72
72: ; preds = %71, %46
br label %73
73: ; preds = %72
%74 = load i32, i32* %6
%75 = add nsw i32 %74, 1
store i32 %75, i32* %6
br label %14
76: ; preds = %14
br label %77
77: ; preds = %76
%78 = load i32, i32* %5
%79 = add nsw i32 %78, 1
store i32 %79, i32* %5
br label %10
80: ; preds = %10
%81 = load i8, i8* %8
%82 = sext i8 %81 to i32
switch i32 %82, label %91 [
i32 83, label %83
i32 77, label %86
]
83: ; preds = %80
%84 = load double, double* %3
%85 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %84)
br label %91
86: ; preds = %80
%87 = load double, double* %3
%88 = load double, double* %4
%89 = fdiv double %87, %88
%90 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %89)
br label %91
91: ; preds = %80, %86, %83
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c" %c\00"
@.str.1 = [5 x i8] c" %lf\00"
@.str.2 = [8 x i8] c"%0.1lf\0A\00"
define i32 @main() {
%1 = alloca [12 x [12 x double]]
%2 = alloca i8
%3 = bitcast [12 x [12 x double]]* %1 to i8*
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %5
5: ; preds = %0, %34
%6 = phi i64 [ 0, %0 ], [ %35, %34 ]
%7 = phi double [ 0.000000e+00, %0 ], [ %31, %34 ]
%8 = phi double [ 0.000000e+00, %0 ], [ %30, %34 ]
%9 = icmp ult i64 %6, 6
%10 = sub nuw nsw i64 11, %6
br label %11
11: ; preds = %5, %29
%12 = phi i64 [ 0, %5 ], [ %32, %29 ]
%13 = phi double [ %7, %5 ], [ %31, %29 ]
%14 = phi double [ %8, %5 ], [ %30, %29 ]
%15 = getelementptr inbounds [12 x [12 x double]], [12 x [12 x double]]* %1, i64 0, i64 %6, i64 %12
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %15)
br i1 %9, label %17, label %21
17: ; preds = %11
%18 = icmp ugt i64 %6, %12
%19 = icmp ult i64 %12, 5
%20 = and i1 %18, %19
br i1 %20, label %25, label %29
21: ; preds = %11
%22 = icmp ult i64 %12, %10
%23 = icmp ult i64 %12, 5
%24 = and i1 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %21, %17
%26 = load double, double* %15
%27 = fadd double %13, %26
%28 = fadd double %14, 1.000000e+00
br label %29
29: ; preds = %25, %17, %21
%30 = phi double [ %14, %17 ], [ %14, %21 ], [ %28, %25 ]
%31 = phi double [ %13, %17 ], [ %13, %21 ], [ %27, %25 ]
%32 = add nuw nsw i64 %12, 1
%33 = icmp eq i64 %32, 12
br i1 %33, label %34, label %11
34: ; preds = %29
%35 = add nuw nsw i64 %6, 1
%36 = icmp eq i64 %35, 12
br i1 %36, label %37, label %5
37: ; preds = %34
%38 = load i8, i8* %2
%39 = sext i8 %38 to i32
switch i32 %39, label %45 [
i32 83, label %42
i32 77, label %40
]
40: ; preds = %37
%41 = fdiv double %31, %30
br label %42
42: ; preds = %37, %40
%43 = phi double [ %41, %40 ], [ %31, %37 ]
%44 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %43)
br label %45
45: ; preds = %42, %37
ret i32 0
}