#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() {
  float M[3][3];
  double sum = 0.0;
  unsigned short L;
  char op;
  scanf("%hu", &L);
  scanf("%*c%c", &op);
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      scanf(" %f", &M[i][j]);
  for (int i = 0; i < 3; i++)
    sum += M[i][L];
  if (op == 'M')
    sum /= 3;
  printf("%.1lf\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x3a(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xebc(%rip),%rdi
lea    -0x3b(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x40(%rbp)
cmpl   $0x3,-0x40(%rbp)
jge    11c6 <main+0xa6>
movl   $0x0,-0x44(%rbp)
cmpl   $0x3,-0x44(%rbp)
jge    11b3 <main+0x93>
movslq -0x40(%rbp),%rax
lea    -0x30(%rbp),%rsi
imul   $0xc,%rax,%rax
add    %rax,%rsi
movslq -0x44(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1173 <main+0x53>
jmp    11b8 <main+0x98>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1162 <main+0x42>
movl   $0x0,-0x48(%rbp)
cmpl   $0x3,-0x48(%rbp)
jge    120b <main+0xeb>
movslq -0x48(%rbp),%rcx
lea    -0x30(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movzwl -0x3a(%rbp),%ecx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11cd <main+0xad>
movsbl -0x3b(%rbp),%eax
cmp    $0x4d,%eax
jne    122e <main+0x10e>
movsd  -0x38(%rbp),%xmm0
movsd  0xddb(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    0xddc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xedc(%rip),%rdi
lea    0xe(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xecd(%rip),%rdi
lea    0xd(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xec0(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x24(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x28(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x2c(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
movzwl 0xe(%rsp),%eax
movss  0x10(%rsp,%rax,4),%xmm0
movss  0x1c(%rsp,%rax,4),%xmm1
cvtss2sd %xmm0,%xmm0
xorpd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
cvtss2sd %xmm1,%xmm1
addsd  %xmm2,%xmm1
movss  0x28(%rsp,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cmpb   $0x4d,0xd(%rsp)
jne    121b <main+0xfb>
divsd  0xde5(%rip),%xmm0
lea    0xdf4(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%hu\00"
@.str.1 = [6 x i8] c"%*c%c\00"
@.str.2 = [4 x i8] c" %f\00"
@.str.3 = [7 x i8] c"%.1lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x [3 x float]]
%3 = alloca double
%4 = alloca i16
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %3
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i16* %4)
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5)
store i32 0, i32* %6
br label %11
11: ; preds = %30, %0
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %33
14: ; preds = %11
store i32 0, i32* %7
br label %15
15: ; preds = %26, %14
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %29
18: ; preds = %15
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %2, i64 0, i64 %20
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x float], [3 x float]* %21, i64 0, i64 %23
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %15
29: ; preds = %15
br label %30
30: ; preds = %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %11
33: ; preds = %11
store i32 0, i32* %8
br label %34
34: ; preds = %48, %33
%35 = load i32, i32* %8
%36 = icmp slt i32 %35, 3
br i1 %36, label %37, label %51
37: ; preds = %34
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %2, i64 0, i64 %39
%41 = load i16, i16* %4
%42 = zext i16 %41 to i64
%43 = getelementptr inbounds [3 x float], [3 x float]* %40, i64 0, i64 %42
%44 = load float, float* %43
%45 = fpext float %44 to double
%46 = load double, double* %3
%47 = fadd double %46, %45
store double %47, double* %3
br label %48
48: ; preds = %37
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %34
51: ; preds = %34
%52 = load i8, i8* %5
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 77
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = load double, double* %3
%57 = fdiv double %56, 3.000000e+00
store double %57, double* %3
br label %58
58: ; preds = %55, %51
%59 = load double, double* %3
%60 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %59)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%hu\00"
@.str.1 = [6 x i8] c"%*c%c\00"
@.str.2 = [4 x i8] c" %f\00"
@.str.3 = [7 x i8] c"%.1lf\0A\00"
define i32 @main() {
%1 = alloca [3 x [3 x float]]
%2 = alloca i16
%3 = alloca i8
%4 = bitcast [3 x [3 x float]]* %1 to i8*
%5 = bitcast i16* %2 to i8*
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i16* %2)
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%8 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %1, i64 0, i64 0, i64 0
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %8)
%10 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %1, i64 0, i64 0, i64 1
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %10)
%12 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %1, i64 0, i64 0, i64 2
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %12)
%14 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %1, i64 0, i64 1, i64 0
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %14)
%16 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %1, i64 0, i64 1, i64 1
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %16)
%18 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %1, i64 0, i64 1, i64 2
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %18)
%20 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %1, i64 0, i64 2, i64 0
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %20)
%22 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %1, i64 0, i64 2, i64 1
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %22)
%24 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %1, i64 0, i64 2, i64 2
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %24)
%26 = load i16, i16* %2
%27 = zext i16 %26 to i64
%28 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %1, i64 0, i64 0, i64 %27
%29 = load float, float* %28
%30 = fpext float %29 to double
%31 = fadd double %30, 0.000000e+00
%32 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %1, i64 0, i64 1, i64 %27
%33 = load float, float* %32
%34 = fpext float %33 to double
%35 = fadd double %31, %34
%36 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %1, i64 0, i64 2, i64 %27
%37 = load float, float* %36
%38 = fpext float %37 to double
%39 = fadd double %35, %38
%40 = load i8, i8* %3
%41 = icmp eq i8 %40, 77
%42 = fdiv double %39, 3.000000e+00
%43 = select i1 %41, double %42, double %39
%44 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %43)
ret i32 0
}