#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int LeggiDati(char nome[14], int *n, int mat[10][10], int valori[40]) {
  FILE *file;
  int i, j;
  file = fopen(nome, "rb");
  if (file == NULL) {
    printf("Non sono riuscito ad aprire il file\n\n");
    return 0;
  }
  fread(n, sizeof(int), 1, file);
  for (i = 0; i < *n; i++) {
    for (j = 0; j < *n; j++) {
      fread(&(mat[i][j]), sizeof(int), 1, file);
    }
  }
  for (i = 0; i < 4 * (*n); i++) {
    fread(&(valori[i]), sizeof(int), 1, file);
  }
  fclose(file);
  return 1;
}


x86 assembly (clang, -O0):
<LeggiDati>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    118f <LeggiDati+0x4f>
lea    0xe85(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127b <LeggiDati+0x13b>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    1220 <LeggiDati+0xe0>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    120d <LeggiDati+0xcd>
mov    -0x20(%rbp),%rdi
movslq -0x34(%rbp),%rax
imul   $0x28,%rax,%rax
add    %rax,%rdi
movslq -0x38(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11c3 <LeggiDati+0x83>
jmp    1212 <LeggiDati+0xd2>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11ad <LeggiDati+0x6d>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jge    126b <LeggiDati+0x12b>
mov    -0x28(%rbp),%rdi
movslq -0x34(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1227 <LeggiDati+0xe7>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LeggiDati>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %rsi,%r13
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11e8 <LeggiDati+0xa8>
mov    %rax,%rbp
mov    $0x1,%r15d
mov    %r13,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
mov    0x0(%r13),%eax
test   %eax,%eax
jle    123a <LeggiDati+0xfa>
mov    %rbx,(%rsp)
xor    %r15d,%r15d
jmp    11b0 <LeggiDati+0x70>
nopl   0x0(%rax)
movslq %eax,%rcx
add    $0x1,%r15
add    $0x28,%r12
cmp    %rcx,%r15
jge    11f9 <LeggiDati+0xb9>
test   %eax,%eax
jle    11a0 <LeggiDati+0x60>
mov    %r12,%rbx
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
add    $0x1,%r14
movslq 0x0(%r13),%rax
add    $0x4,%rbx
cmp    %rax,%r14
jl     11c0 <LeggiDati+0x80>
jmp    11a0 <LeggiDati+0x60>
lea    0xe14(%rip),%rdi
call   1030 <puts@plt>
xor    %r15d,%r15d
jmp    1242 <LeggiDati+0x102>
test   %eax,%eax
mov    (%rsp),%r14
mov    $0x1,%r15d
jle    123a <LeggiDati+0xfa>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
add    $0x1,%rbx
movslq 0x0(%r13),%rax
shl    $0x2,%rax
add    $0x4,%r14
cmp    %rax,%rbx
jl     1210 <LeggiDati+0xd0>
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [38 x i8] c"Non sono riuscito ad aprire il file\0A\0A\00"
define i32 @LeggiDati(i8* %0, i32* %1, [10 x i32]* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [10 x i32]*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %6
store i32* %1, i32** %7
store [10 x i32]* %2, [10 x i32]** %8
store i32* %3, i32** %9
%13 = load i8*, i8** %6
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %10
%15 = load i32*, i32** %10
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %71
19: ; preds = %4
%20 = load i32*, i32** %7
%21 = load i32*, i32** %10
%22 = call i32 @fread(i32* %20, i32 4, i32 1, i32* %21)
store i32 0, i32* %11
br label %23
23: ; preds = %48, %19
%24 = load i32, i32* %11
%25 = load i32*, i32** %7
%26 = load i32, i32* %25
%27 = icmp slt i32 %24, %26
br i1 %27, label %28, label %51
28: ; preds = %23
store i32 0, i32* %12
br label %29
29: ; preds = %44, %28
%30 = load i32, i32* %12
%31 = load i32*, i32** %7
%32 = load i32, i32* %31
%33 = icmp slt i32 %30, %32
br i1 %33, label %34, label %47
34: ; preds = %29
%35 = load [10 x i32]*, [10 x i32]** %8
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %35, i64 %37
%39 = load i32, i32* %12
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %38, i64 0, i64 %40
%42 = load i32*, i32** %10
%43 = call i32 @fread(i32* %41, i32 4, i32 1, i32* %42)
br label %44
44: ; preds = %34
%45 = load i32, i32* %12
%46 = add nsw i32 %45, 1
store i32 %46, i32* %12
br label %29
47: ; preds = %29
br label %48
48: ; preds = %47
%49 = load i32, i32* %11
%50 = add nsw i32 %49, 1
store i32 %50, i32* %11
br label %23
51: ; preds = %23
store i32 0, i32* %11
br label %52
52: ; preds = %65, %51
%53 = load i32, i32* %11
%54 = load i32*, i32** %7
%55 = load i32, i32* %54
%56 = mul nsw i32 4, %55
%57 = icmp slt i32 %53, %56
br i1 %57, label %58, label %68
58: ; preds = %52
%59 = load i32*, i32** %9
%60 = load i32, i32* %11
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %59, i64 %61
%63 = load i32*, i32** %10
%64 = call i32 @fread(i32* %62, i32 4, i32 1, i32* %63)
br label %65
65: ; preds = %58
%66 = load i32, i32* %11
%67 = add nsw i32 %66, 1
store i32 %67, i32* %11
br label %52
68: ; preds = %52
%69 = load i32*, i32** %10
%70 = call i32 @fclose(i32* %69)
store i32 1, i32* %5
br label %71
71: ; preds = %68, %17
%72 = load i32, i32* %5
ret i32 %72
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@str = [37 x i8] c"Non sono riuscito ad aprire il file\0A\00"
define i32 @LeggiDati(i8* nocapture %0, i32* nocapture %1, [10 x i32]* nocapture %2, i32* nocapture %3) {
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %43
9: ; preds = %4
%10 = tail call i32 @fread(i32* %1, i32 4, i32 1, i32* %5)
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %41
13: ; preds = %9, %27
%14 = phi i32 [ %28, %27 ], [ %11, %9 ]
%15 = phi i64 [ %30, %27 ], [ 0, %9 ]
%16 = icmp sgt i32 %14, 0
br i1 %16, label %19, label %27
17: ; preds = %27
%18 = icmp sgt i32 %28, 0
br i1 %18, label %32, label %41
19: ; preds = %13, %19
%20 = phi i64 [ %23, %19 ], [ 0, %13 ]
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 %15, i64 %20
%22 = tail call i32 @fread(i32* %21, i32 4, i32 1, i32* %5)
%23 = add nuw nsw i64 %20, 1
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %19, label %27
27: ; preds = %19, %13
%28 = phi i32 [ %14, %13 ], [ %24, %19 ]
%29 = sext i32 %28 to i64
%30 = add nuw nsw i64 %15, 1
%31 = icmp slt i64 %30, %29
br i1 %31, label %13, label %17
32: ; preds = %17, %32
%33 = phi i64 [ %36, %32 ], [ 0, %17 ]
%34 = getelementptr inbounds i32, i32* %3, i64 %33
%35 = tail call i32 @fread(i32* %34, i32 4, i32 1, i32* %5)
%36 = add nuw nsw i64 %33, 1
%37 = load i32, i32* %1
%38 = shl nsw i32 %37, 2
%39 = sext i32 %38 to i64
%40 = icmp slt i64 %36, %39
br i1 %40, label %32, label %41
41: ; preds = %32, %9, %17
%42 = tail call i32 @fclose(i32* %5)
br label %43
43: ; preds = %41, %7
%44 = phi i32 [ 0, %7 ], [ 1, %41 ]
ret i32 %44
}