#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *, int *, int *, int *,
                  int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  float sommaColonne[5] = {0};
  float sommaRiga = 0;
  int numeroRighe = 0;
  int n[5];
  int i = 0;
  FILE *fp;
  fp = fopen("testo.txt", "r");
  if (fp == NULL) {
    printf("Errore nell'apertura del file");
    return -1;
  }
  while (fscanf(fp, "%d %d %d %d %d", &n[0], &n[1], &n[2], &n[3], &n[4]) !=
         EOF) {
    numeroRighe++;
    sommaRiga = 0;
    for (i = 0; i < 5; i++) {
      sommaColonne[i] += n[i];
      sommaRiga += n[i];
    }
    printf("Media riga %d\t%6.1f\n", numeroRighe, sommaRiga / 5);
  }
  fclose(fp);
  for (i = 0; i < numeroRighe; i++) {
    printf("Media colonna %d\t%6.1f\n", i + 1, sommaColonne[i] / 5);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x44(%rbp)
lea    0xe78(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    11c1 <main+0x71>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12f6 <main+0x1a6>
jmp    11c6 <main+0x76>
mov    -0x50(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x40(%rbp),%rcx
add    $0x4,%rcx
lea    -0x40(%rbp),%r8
add    $0x8,%r8
lea    -0x40(%rbp),%r9
add    $0xc,%r9
lea    -0x40(%rbp),%rax
add    $0x10,%rax
lea    0xe39(%rip),%rsi
mov    %rax,(%rsp)
call   1060 <fscanf@plt>
mov    0x2de3(%rip),%rcx
cmp    (%rcx),%rax
je     1297 <main+0x147>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x5,-0x44(%rbp)
jge    126c <main+0x11c>
movslq -0x44(%rbp),%rax
cvtsi2ssl -0x40(%rbp,%rax,4),%xmm0
movslq -0x44(%rbp),%rax
addss  -0x20(%rbp,%rax,4),%xmm0
movss  %xmm0,-0x20(%rbp,%rax,4)
movslq -0x44(%rbp),%rax
cvtsi2ssl -0x40(%rbp,%rax,4),%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1226 <main+0xd6>
mov    -0x28(%rbp),%esi
movss  -0x24(%rbp),%xmm0
movss  0xd84(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb2(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11c6 <main+0x76>
mov    -0x50(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12ef <main+0x19f>
mov    -0x44(%rbp),%esi
add    $0x1,%esi
movslq -0x44(%rbp),%rax
movss  -0x20(%rbp,%rax,4),%xmm0
movss  0xd35(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd78(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    12a7 <main+0x157>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xeaf(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11b5 <main+0x75>
mov    %rax,%rbx
lea    0x14(%rsp),%rcx
lea    0x18(%rsp),%r8
lea    0x1c(%rsp),%rbp
lea    0x20(%rsp),%r12
mov    %r12,(%rsp)
lea    0xea6(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rax,%rdi
mov    %rbp,%r9
call   1050 <fscanf@plt>
mov    0x2e49(%rip),%r13
cmp    0x0(%r13),%rax
jne    11ce <main+0x8e>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %r14d,%r14d
jmp    12f8 <main+0x1b8>
lea    0xe54(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%r14d
jmp    12f8 <main+0x1b8>
xorps  %xmm1,%xmm1
xorps  %xmm3,%xmm3
mov    $0xffffffffffffffff,%r15
lea    0x10(%rsp),%r14
cvtdq2ps 0x10(%rsp),%xmm0
addps  %xmm0,%xmm1
movaps %xmm1,0x30(%rsp)
movaps %xmm0,%xmm1
shufps $0x55,%xmm0,%xmm1
addss  %xmm0,%xmm1
movaps %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
addss  %xmm1,%xmm2
shufps $0xff,%xmm0,%xmm0
addss  %xmm2,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0x20(%rsp),%xmm1
addss  %xmm1,%xmm3
movss  %xmm3,0x2c(%rsp)
addss  %xmm1,%xmm0
lea    0x2(%r15),%esi
divss  0xdd2(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe04(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r12,(%rsp)
mov    %rbx,%rdi
lea    0xde0(%rip),%rsi
mov    %r14,%rdx
lea    0x14(%rsp),%rcx
lea    0x18(%rsp),%r8
mov    %rbp,%r9
call   1050 <fscanf@plt>
movss  0x2c(%rsp),%xmm3
movaps 0x30(%rsp),%xmm1
add    $0x1,%r15
cmp    0x0(%r13),%rax
jne    11e0 <main+0xa0>
movaps %xmm1,0x40(%rsp)
movss  %xmm3,0x50(%rsp)
mov    %rbx,%rdi
call   1030 <fclose@plt>
movaps 0x30(%rsp),%xmm0
divss  0xd64(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdab(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %r14d,%r14d
test   %r15d,%r15d
je     12f8 <main+0x1b8>
mov    $0x1,%ebp
lea    0xd8b(%rip),%rbx
nopw   0x0(%rax,%rax,1)
movss  0x40(%rsp,%rbp,4),%xmm0
add    $0x1,%rbp
divss  0xd1e(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0xffffffffffffffff,%r15
jne    12d0 <main+0x190>
mov    %r14d,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"testo.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [30 x i8] c"Errore nell'apertura del file\00"
@.str.3 = [15 x i8] c"%d %d %d %d %d\00"
@EOF = global i64 0
@.str.4 = [21 x i8] c"Media riga %d\09%6.1f\0A\00"
@.str.5 = [24 x i8] c"Media colonna %d\09%6.1f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x float]
%3 = alloca float
%4 = alloca i32
%5 = alloca [5 x i32]
%6 = alloca i32
%7 = alloca i32*
store i32 0, i32* %1
%8 = bitcast [5 x float]* %2 to i8*
store float 0.000000e+00, float* %3
store i32 0, i32* %4
store i32 0, i32* %6
%9 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %79
14: ; preds = %0
br label %15
15: ; preds = %52, %14
%16 = load i32*, i32** %7
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 1
%19 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 2
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 3
%21 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 4
%22 = call i64 @fscanf(i32* %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32* %17, i32* %18, i32* %19, i32* %20, i32* %21)
%23 = load i64, i64* @EOF
%24 = icmp ne i64 %22, %23
br i1 %24, label %25, label %58
25: ; preds = %15
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
store float 0.000000e+00, float* %3
store i32 0, i32* %6
br label %28
28: ; preds = %49, %25
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 5
br i1 %30, label %31, label %52
31: ; preds = %28
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = sitofp i32 %35 to float
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [5 x float], [5 x float]* %2, i64 0, i64 %38
%40 = load float, float* %39
%41 = fadd float %40, %36
store float %41, float* %39
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = sitofp i32 %45 to float
%47 = load float, float* %3
%48 = fadd float %47, %46
store float %48, float* %3
br label %49
49: ; preds = %31
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %28
52: ; preds = %28
%53 = load i32, i32* %4
%54 = load float, float* %3
%55 = fdiv float %54, 5.000000e+00
%56 = fpext float %55 to double
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %53, double %56)
br label %15
58: ; preds = %15
%59 = load i32*, i32** %7
%60 = call i32 @fclose(i32* %59)
store i32 0, i32* %6
br label %61
61: ; preds = %75, %58
%62 = load i32, i32* %6
%63 = load i32, i32* %4
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %78
65: ; preds = %61
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
%68 = load i32, i32* %6
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [5 x float], [5 x float]* %2, i64 0, i64 %69
%71 = load float, float* %70
%72 = fdiv float %71, 5.000000e+00
%73 = fpext float %72 to double
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %67, double %73)
br label %75
75: ; preds = %65
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
br label %61
78: ; preds = %61
store i32 0, i32* %1
br label %79
79: ; preds = %78, %12
%80 = load i32, i32* %1
ret i32 %80
}

LLVM IR (-O2):
@.str = [10 x i8] c"testo.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [30 x i8] c"Errore nell'apertura del file\00"
@.str.3 = [15 x i8] c"%d %d %d %d %d\00"
@EOF = global i64 0
@.str.4 = [21 x i8] c"Media riga %d\09%6.1f\0A\00"
@.str.5 = [24 x i8] c"Media colonna %d\09%6.1f\0A\00"
define i32 @main() {
%1 = alloca [5 x float]
%2 = alloca [5 x i32]
%3 = bitcast [5 x float]* %1 to i8*
%4 = bitcast [5 x i32]* %2 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %21, label %7
7: ; preds = %0
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 1
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 2
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 3
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 4
%13 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32* %8, i32* %9, i32* %10, i32* %11, i32* %12)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %7
%17 = call i32 @fclose(i32* %5)
br label %67
18: ; preds = %7
%19 = getelementptr inbounds [5 x float], [5 x float]* %1, i64 0, i64 4
%20 = bitcast [5 x i32]* %2 to <4 x i32>*
br label %23
21: ; preds = %0
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %67
23: ; preds = %18, %23
%24 = phi float [ %39, %23 ], [ 0.000000e+00, %18 ]
%25 = phi i32 [ %41, %23 ], [ 0, %18 ]
%26 = phi <4 x float> [ %33, %23 ], [ zeroinitializer, %18 ]
%27 = load <4 x i32>, <4 x i32>* %20
%28 = sitofp <4 x i32> %27 to <4 x float>
%29 = shufflevector <4 x float> %28, <4 x float> poison, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
%30 = fadd <4 x float> %29, %28
%31 = shufflevector <4 x float> %28, <4 x float> poison, <4 x i32> <i32 2, i32 undef, i32 undef, i32 undef>
%32 = fadd <4 x float> %30, %31
%33 = fadd <4 x float> %26, %28
%34 = shufflevector <4 x float> %28, <4 x float> poison, <4 x i32> <i32 3, i32 undef, i32 undef, i32 undef>
%35 = fadd <4 x float> %32, %34
%36 = extractelement <4 x float> %35, i64 0
%37 = load i32, i32* %12
%38 = sitofp i32 %37 to float
%39 = fadd float %24, %38
%40 = fadd float %36, %38
%41 = add nuw nsw i32 %25, 1
%42 = fdiv float %40, 5.000000e+00
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %41, double %43)
%45 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32* %8, i32* %9, i32* %10, i32* %11, i32* %12)
%46 = load i64, i64* @EOF
%47 = icmp eq i64 %45, %46
br i1 %47, label %48, label %23
48: ; preds = %23
%49 = bitcast [5 x float]* %1 to <4 x float>*
store <4 x float> %33, <4 x float>* %49
store float %39, float* %19
%50 = call i32 @fclose(i32* %5)
%51 = zext i32 %41 to i64
%52 = extractelement <4 x float> %33, i64 0
%53 = fdiv float %52, 5.000000e+00
%54 = fpext float %53 to double
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 1, double %54)
%56 = icmp eq i32 %25, 0
br i1 %56, label %67, label %57
57: ; preds = %48, %57
%58 = phi i64 [ %61, %57 ], [ 1, %48 ]
%59 = getelementptr inbounds [5 x float], [5 x float]* %1, i64 0, i64 %58
%60 = load float, float* %59
%61 = add nuw nsw i64 %58, 1
%62 = fdiv float %60, 5.000000e+00
%63 = fpext float %62 to double
%64 = trunc i64 %61 to i32
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %64, double %63)
%66 = icmp eq i64 %61, %51
br i1 %66, label %67, label %57
67: ; preds = %57, %48, %16, %21
%68 = phi i32 [ -1, %21 ], [ 0, %16 ], [ 0, %48 ], [ 0, %57 ]
ret i32 %68
}