#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*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_SET;
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int lectureScore(char pseudo[100][4], int score[100]) {
  FILE *sauv = NULL;
  sauv = fopen("score.txt", "r");
  char lecture[5];
  int i = 0;
  if (sauv != NULL) {
    fseek(sauv, 0, SEEK_SET);
    while (!feof(sauv)) {
      fgets(lecture, 4, sauv);
      strcpy(pseudo[i], lecture);
      fseek(sauv, 1, SEEK_CUR);
      fgets(lecture, 5, sauv);
      score[i] = atoi(lecture);
      i++;
    }
    fclose(sauv);
  } else {
    printf("Erreur lors de l'ouverture du fichier pour lecture");
  }
  return (i - 1);
}


x86 assembly (clang, -O0):
<lectureScore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe61(%rip),%rdi
lea    0xe64(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1278 <lectureScore+0xf8>
mov    -0x18(%rbp),%rdi
mov    0x2e0c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f3 <lectureScore+0x73>
jmp    126a <lectureScore+0xea>
lea    -0x1d(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x4,%esi
call   1060 <fgets@plt>
mov    -0x8(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
lea    -0x1d(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    0x2dc0(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%esi
call   1080 <fseek@plt>
lea    -0x1d(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x5,%esi
call   1060 <fgets@plt>
lea    -0x1d(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d5 <lectureScore+0x55>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1284 <lectureScore+0x104>
lea    0xd8d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lectureScore>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe68(%rip),%rdi
lea    0xe6b(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1245 <lectureScore+0xc5>
mov    %rax,%r12
mov    0x2e21(%rip),%rax
mov    (%rax),%edx
xor    %ebx,%ebx
mov    %r12,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %r12,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    123b <lectureScore+0xbb>
xor    %ebx,%ebx
lea    0x3(%rsp),%r13
mov    0x2e09(%rip),%rbp
nop
mov    %r13,%rdi
mov    $0x4,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    0x0(%rbp),%edx
mov    %r12,%rdi
mov    $0x1,%esi
call   1080 <fseek@plt>
mov    %r13,%rdi
mov    $0x5,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
mov    %r13,%rdi
call   10a0 <atoi@plt>
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
mov    %r12,%rdi
call   1070 <feof@plt>
add    $0x4,%r15
test   %eax,%eax
je     11e0 <lectureScore+0x60>
mov    %r12,%rdi
call   1040 <fclose@plt>
jmp    1253 <lectureScore+0xd3>
lea    0xdc0(%rip),%rdi
call   1050 <printf@plt>
xor    %ebx,%ebx
add    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"score.txt\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
@.str.2 = [51 x i8] c"Erreur lors de l'ouverture du fichier pour lecture\00"
define i32 @lectureScore([4 x i8]* %0, i32* %1) {
%3 = alloca [4 x i8]*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [5 x i8]
%7 = alloca i32
store [4 x i8]* %0, [4 x i8]** %3
store i32* %1, i32** %4
store i32* null, i32** %5
%8 = 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* %8, i32** %5
store i32 0, i32* %7
%9 = load i32*, i32** %5
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %48
11: ; preds = %2
%12 = load i32*, i32** %5
%13 = load i32, i32* @SEEK_SET
%14 = call i32 @fseek(i32* %12, i32 0, i32 %13)
br label %15
15: ; preds = %20, %11
%16 = load i32*, i32** %5
%17 = call i32 @feof(i32* %16)
%18 = icmp ne i32 %17, 0
%19 = xor i1 %18, true
br i1 %19, label %20, label %45
20: ; preds = %15
%21 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%22 = load i32*, i32** %5
%23 = call i32 @fgets(i8* %21, i32 4, i32* %22)
%24 = load [4 x i8]*, [4 x i8]** %3
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %24, i64 %26
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %27, i64 0, i64 0
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%30 = call i32 @strcpy(i8* %28, i8* %29)
%31 = load i32*, i32** %5
%32 = load i32, i32* @SEEK_CUR
%33 = call i32 @fseek(i32* %31, i32 1, i32 %32)
%34 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%35 = load i32*, i32** %5
%36 = call i32 @fgets(i8* %34, i32 5, i32* %35)
%37 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%38 = call i32 @atoi(i8* %37)
%39 = load i32*, i32** %4
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
store i32 %38, i32* %42
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %15
45: ; preds = %15
%46 = load i32*, i32** %5
%47 = call i32 @fclose(i32* %46)
br label %50
48: ; preds = %2
%49 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
br label %50
50: ; preds = %48, %45
%51 = load i32, i32* %7
%52 = sub nsw i32 %51, 1
ret i32 %52
}

LLVM IR (-O2):
@.str = [10 x i8] c"score.txt\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
@.str.2 = [51 x i8] c"Erreur lors de l'ouverture du fichier pour lecture\00"
define i32 @lectureScore([4 x i8]* %0, i32* nocapture writeonly %1) {
%3 = alloca [5 x i8]
%4 = 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))
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%6 = icmp eq i32* %4, null
br i1 %6, label %30, label %7
7: ; preds = %2
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %4, i32 0, i32 %8)
%10 = call i32 @feof(i32* %4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %7, %12
%13 = phi i64 [ %22, %12 ], [ 0, %7 ]
%14 = call i32 @fgets(i8* %5, i32 4, i32* %4)
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %0, i64 %13, i64 0
%16 = call i32 @strcpy(i8* %15, i8* %5)
%17 = load i32, i32* @SEEK_CUR
%18 = call i32 @fseek(i32* %4, i32 1, i32 %17)
%19 = call i32 @fgets(i8* %5, i32 5, i32* %4)
%20 = call i32 @atoi(i8* %5)
%21 = getelementptr inbounds i32, i32* %1, i64 %13
store i32 %20, i32* %21
%22 = add nuw i64 %13, 1
%23 = call i32 @feof(i32* %4)
%24 = icmp eq i32 %23, 0
br i1 %24, label %12, label %25
25: ; preds = %12
%26 = trunc i64 %22 to i32
br label %27
27: ; preds = %25, %7
%28 = phi i32 [ 0, %7 ], [ %26, %25 ]
%29 = call i32 @fclose(i32* %4)
br label %32
30: ; preds = %2
%31 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = phi i32 [ %28, %27 ], [ 0, %30 ]
%34 = add nsw i32 %33, -1
ret i32 %34
}