#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int leggiPagina(char pagina[80][60 + 1], int max_r) {
  FILE *fp;
  int i = 0;
  if ((fp = fopen("sequenze.txt", "r")) == NULL)
    exit(1);
  while (fgets(pagina[i++], 60 + 1, fp) != NULL && i < max_r)
    ;
  fclose(fp);
  return i - 1;
}


x86 assembly (clang, -O0):
<leggiPagina>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xea3(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1181 <leggiPagina+0x41>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    1186 <leggiPagina+0x46>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
imul   $0x3d,%rax,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3d,%esi
call   1040 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x1d(%rbp)
je     11ca <leggiPagina+0x8a>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11da <leggiPagina+0x9a>
jmp    11df <leggiPagina+0x9f>
jmp    1186 <leggiPagina+0x46>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<leggiPagina>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xeac(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11bc <leggiPagina+0x7c>
mov    %rax,%r14
movslq %ebp,%r15
mov    $0xffffffff,%ebp
mov    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x3d,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
add    $0x1,%ebp
test   %rax,%rax
je     11a9 <leggiPagina+0x69>
add    $0x3d,%rbx
lea    0x1(%r12),%rax
cmp    %r15,%r12
mov    %rax,%r12
jl     1180 <leggiPagina+0x40>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"sequenze.txt\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @leggiPagina([61 x i8]* %0, i32 %1) {
%3 = alloca [61 x i8]*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store [61 x i8]* %0, [61 x i8]** %3
store i32 %1, i32* %4
store i32 0, i32* %6
%7 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %5
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %2
br label %12
12: ; preds = %28, %11
%13 = load [61 x i8]*, [61 x i8]** %3
%14 = load i32, i32* %6
%15 = add nsw i32 %14, 1
store i32 %15, i32* %6
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds [61 x i8], [61 x i8]* %13, i64 %16
%18 = getelementptr inbounds [61 x i8], [61 x i8]* %17, i64 0, i64 0
%19 = load i32*, i32** %5
%20 = call i32* @fgets(i8* %18, i32 61, i32* %19)
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %26
22: ; preds = %12
%23 = load i32, i32* %6
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br label %26
26: ; preds = %22, %12
%27 = phi i1 [ false, %12 ], [ %25, %22 ]
br i1 %27, label %28, label %29
28: ; preds = %26
br label %12
29: ; preds = %26
%30 = load i32*, i32** %5
%31 = call i32 @fclose(i32* %30)
%32 = load i32, i32* %6
%33 = sub nsw i32 %32, 1
ret i32 %33
}

LLVM IR (-O2):
@.str = [13 x i8] c"sequenze.txt\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @leggiPagina([61 x i8]* %0, i32 %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = sext i32 %1 to i64
br label %9
7: ; preds = %2
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %11, %9 ]
%11 = add nuw nsw i64 %10, 1
%12 = getelementptr inbounds [61 x i8], [61 x i8]* %0, i64 %10, i64 0
%13 = tail call i32* @fgets(i8* %12, i32 61, i32* %3)
%14 = icmp ne i32* %13, null
%15 = icmp slt i64 %11, %6
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %9, label %17
17: ; preds = %9
%18 = trunc i64 %10 to i32
%19 = tail call i32 @fclose(i32* %3)
ret i32 %18
}