#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*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int class[10];
  FILE *ptr_file;
  int i = 0;
  int j;
  int sum = 0;
  int *ptr_sum;
  int *ptr_class;
  ptr_sum = &sum;
  ptr_class = &class[0];
  for (j = 0; j < 10; j++) {
    class[j] = 0;
  }
  ptr_file = fopen("/root/practica2/Entrada2d.txt", "r");
  if (!ptr_file) {
    return 1;
  }
  while (1) {
    if (feof(ptr_file)) {
      break;
    }
    fscanf(ptr_file, "%d", ptr_class + i);
    i++;
    if (i == 10) {
      break;
    }
  }
  for (j = 0; j < 10; j++) {
    *ptr_sum += *(ptr_class + j);
  }
  fclose(ptr_file);
  printf("La suma final es: %d", *ptr_sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x44(%rbp)
lea    -0x44(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x40(%rbp)
cmpl   $0xa,-0x40(%rbp)
jge    11a8 <main+0x58>
movslq -0x40(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1184 <main+0x34>
lea    0xe51(%rip),%rdi
lea    0xe68(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11d6 <main+0x86>
movl   $0x1,-0x4(%rbp)
jmp    1283 <main+0x133>
jmp    11db <main+0x8b>
mov    -0x38(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     11f3 <main+0xa3>
jmp    122f <main+0xdf>
mov    -0x38(%rbp),%rdi
mov    -0x58(%rbp),%rdx
movslq -0x3c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe25(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0xa,-0x3c(%rbp)
jne    122a <main+0xda>
jmp    122f <main+0xdf>
jmp    11db <main+0x8b>
movl   $0x0,-0x40(%rbp)
cmpl   $0xa,-0x40(%rbp)
jge    1261 <main+0x111>
mov    -0x58(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x50(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1236 <main+0xe6>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x50(%rbp),%rax
mov    (%rax),%esi
lea    0xda9(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
pxor   %xmm0,%xmm0
movdqa %xmm0,0x10(%rsp)
movdqa %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
lea    0xe8b(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1334 <main+0x1e4>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    12ed <main+0x19d>
lea    0xe8d(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    12ed <main+0x19d>
lea    0x4(%rsp),%rdx
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    12ed <main+0x19d>
lea    0x8(%rsp),%rdx
lea    0xe40(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    12ed <main+0x19d>
lea    0xc(%rsp),%rdx
lea    0xe1b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    12ed <main+0x19d>
lea    0x10(%rsp),%rdx
lea    0xdf6(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    12ed <main+0x19d>
lea    0x14(%rsp),%rdx
lea    0xdd1(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    12ed <main+0x19d>
lea    0x18(%rsp),%rdx
lea    0xdb0(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    12ed <main+0x19d>
lea    0x1c(%rsp),%rdx
lea    0xd8f(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    12ed <main+0x19d>
lea    0x20(%rsp),%rdx
lea    0xd6e(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    12ed <main+0x19d>
lea    0x24(%rsp),%rdx
lea    0xd4d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fscanf@plt>
movdqu 0x8(%rsp),%xmm0
movdqu 0x18(%rsp),%xmm1
paddd  %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%ebp
add    0x4(%rsp),%ebp
add    (%rsp),%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xcf7(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
jmp    1339 <main+0x1e9>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"/root/practica2/Entrada2d.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [21 x i8] c"La suma final es: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %6
store i32* %6, i32** %7
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
store i32* %9, i32** %8
store i32 0, i32* %5
br label %10
10: ; preds = %17, %0
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %15
store i32 0, i32* %16
br label %17
17: ; preds = %13
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %10
20: ; preds = %10
%21 = call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %3
%22 = load i32*, i32** %3
%23 = icmp ne i32* %22, null
br i1 %23, label %25, label %24
24: ; preds = %20
store i32 1, i32* %1
br label %66
25: ; preds = %20
br label %26
26: ; preds = %25, %43
%27 = load i32*, i32** %3
%28 = call i64 @feof(i32* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
br label %44
31: ; preds = %26
%32 = load i32*, i32** %3
%33 = load i32*, i32** %8
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
%37 = call i32 @fscanf(i32* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %36)
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
%40 = load i32, i32* %4
%41 = icmp eq i32 %40, 10
br i1 %41, label %42, label %43
42: ; preds = %31
br label %44
43: ; preds = %31
br label %26
44: ; preds = %42, %30
store i32 0, i32* %5
br label %45
45: ; preds = %57, %44
%46 = load i32, i32* %5
%47 = icmp slt i32 %46, 10
br i1 %47, label %48, label %60
48: ; preds = %45
%49 = load i32*, i32** %8
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
%53 = load i32, i32* %52
%54 = load i32*, i32** %7
%55 = load i32, i32* %54
%56 = add nsw i32 %55, %53
store i32 %56, i32* %54
br label %57
57: ; preds = %48
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
store i32 %59, i32* %5
br label %45
60: ; preds = %45
%61 = load i32*, i32** %3
%62 = call i32 @fclose(i32* %61)
%63 = load i32*, i32** %7
%64 = load i32, i32* %63
%65 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %64)
store i32 0, i32* %1
br label %66
66: ; preds = %60, %24
%67 = load i32, i32* %1
ret i32 %67
}

LLVM IR (-O2):
@.str = [30 x i8] c"/root/practica2/Entrada2d.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [21 x i8] c"La suma final es: %d\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 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 %69, label %5
5: ; preds = %0
%6 = call i64 @feof(i32* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %56
8: ; preds = %5
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%10 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%11 = call i64 @feof(i32* %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %56
13: ; preds = %8
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%15 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %14)
%16 = call i64 @feof(i32* %3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %56
18: ; preds = %13
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%20 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %19)
%21 = call i64 @feof(i32* %3)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %56
23: ; preds = %18
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%25 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %24)
%26 = call i64 @feof(i32* %3)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %56
28: ; preds = %23
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%30 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %29)
%31 = call i64 @feof(i32* %3)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %56
33: ; preds = %28
%34 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%35 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %34)
%36 = call i64 @feof(i32* %3)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %56
38: ; preds = %33
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%40 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %39)
%41 = call i64 @feof(i32* %3)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %56
43: ; preds = %38
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%45 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %44)
%46 = call i64 @feof(i32* %3)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %56
48: ; preds = %43
%49 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%50 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %49)
%51 = call i64 @feof(i32* %3)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%55 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %54)
br label %56
56: ; preds = %53, %48, %43, %38, %33, %28, %23, %18, %13, %8, %5
%57 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%58 = load i32, i32* %57
%59 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%60 = load i32, i32* %59
%61 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%62 = bitcast i32* %61 to <8 x i32>*
%63 = load <8 x i32>, <8 x i32>* %62
%64 = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %63)
%65 = add nsw i32 %64, %60
%66 = add nsw i32 %65, %58
%67 = call i32 @fclose(i32* %3)
%68 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %66)
br label %69
69: ; preds = %0, %56
%70 = phi i32 [ 0, %56 ], [ 1, %0 ]
ret i32 %70
}