#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(unsigned char *, char *);
char getc(int /*<<< orphan*/ *);
unsigned char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned char *);
int /*<<< orphan*/ strcat(unsigned char *, char *);
int consultador() {
  FILE *fp;
  unsigned char *linea;
  unsigned char *nombre;
  int nump, num, count = 1;
  char c;
  linea = malloc(sizeof(unsigned char));
  nombre = malloc(sizeof(unsigned char));
  do {
    printf("Ingrese el nombre del archivo\n");
    scanf("%s", nombre);
    strcat(nombre, "_cal.csv");
    printf("\n");
    fp = fopen(nombre, "r");
    if (fp == NULL) {
      printf("No se encontro el archivo\n");
    }
  } while (fp == NULL);
  printf("*--------*--------------*----------------*---------------*-----------"
         "---------*\n");
  printf("| Cuenta | Calificacion | Res. Correctas | No. Preguntas | Tiempo "
         "Transcurrido|\n");
  printf("*--------*--------------*----------------*---------------*-----------"
         "---------*\n");
  while ((c = getc(fp)) != EOF) {
    if (c == ',')
      printf("\t\t");
    else
      printf("%c", c);
  }
  printf("*--------------------------------------------------------------------"
         "---------*\n");
  fclose(fp);
}


x86 assembly (clang, -O0):
<consultador>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x1,-0x2c(%rbp)
mov    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1080 <strcat@plt>
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1204 <consultador+0x94>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1209 <consultador+0x99>
cmpq   $0x0,-0x10(%rbp)
je     119b <consultador+0x2b>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1090 <getc@plt>
mov    %al,-0x2d(%rbp)
movsbl %al,%eax
mov    0x2d94(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1296 <consultador+0x126>
movsbl -0x2d(%rbp),%eax
cmp    $0x2c,%eax
jne    127f <consultador+0x10f>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1291 <consultador+0x121>
movsbl -0x2d(%rbp),%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123e <consultador+0xce>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<consultador>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xe62(%rip),%rdi
call   1040 <puts@plt>
lea    0xe45(%rip),%rdi
mov    %r14,%rsi
call   1080 <scanf@plt>
lea    0xe39(%rip),%rsi
mov    %r14,%rdi
call   10a0 <strcat@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe29(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1257 <consultador+0xc7>
lea    0xe17(%rip),%r12
lea    0xdff(%rip),%r13
lea    0xdfb(%rip),%rbp
lea    0xdfd(%rip),%r15
nop
lea    0xf08(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1080 <scanf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   10a0 <strcat@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1210 <consultador+0x80>
mov    %rax,%rbx
lea    0xe21(%rip),%rbp
mov    %rbp,%rdi
call   1040 <puts@plt>
lea    0xdc2(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   10b0 <getc@plt>
mov    0x2d5f(%rip),%rbp
cmp    0x0(%rbp),%al
jne    12b0 <consultador+0x120>
lea    0xe3a(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fclose@plt>
lea    0xd57(%rip),%r14
jmp    12d5 <consultador+0x145>
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   10b0 <getc@plt>
cmp    0x0(%rbp),%al
je     128e <consultador+0xfe>
cmp    $0x2c,%al
jne    12c0 <consultador+0x130>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    12c8 <consultador+0x138>

LLVM IR (-O0):
@.str = [31 x i8] c"Ingrese el nombre del archivo\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [9 x i8] c"_cal.csv\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [27 x i8] c"No se encontro el archivo\0A\00"
@.str.6 = [81 x i8] c"*--------*--------------*----------------*---------------*--------------------*\0A\00"
@.str.7 = [81 x i8] c"| Cuenta | Calificacion | Res. Correctas | No. Preguntas | Tiempo Transcurrido|\0A\00"
@EOF = global i8 0
@.str.8 = [3 x i8] c"\09\09\00"
@.str.9 = [3 x i8] c"%c\00"
@.str.10 = [81 x i8] c"*-----------------------------------------------------------------------------*\0A\00"
define i32 @consultador() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32 1, i32* %7
%9 = call i8* @malloc(i32 1)
store i8* %9, i8** %3
%10 = call i8* @malloc(i32 1)
store i8* %10, i8** %4
br label %11
11: ; preds = %25, %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** %4
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %4
%16 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%18 = load i8*, i8** %4
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %19, i32** %2
%20 = load i32*, i32** %2
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %11
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %24
24: ; preds = %22, %11
br label %25
25: ; preds = %24
%26 = load i32*, i32** %2
%27 = icmp eq i32* %26, null
br i1 %27, label %11, label %28
28: ; preds = %25
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.6, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.7, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.6, i64 0, i64 0))
br label %32
32: ; preds = %49, %28
%33 = load i32*, i32** %2
%34 = call signext i8 @getc(i32* %33)
store i8 %34, i8* %8
%35 = sext i8 %34 to i32
%36 = load i8, i8* @EOF
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %35, %37
br i1 %38, label %39, label %50
39: ; preds = %32
%40 = load i8, i8* %8
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 44
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %49
45: ; preds = %39
%46 = load i8, i8* %8
%47 = sext i8 %46 to i32
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %45, %43
br label %32
50: ; preds = %32
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.10, i64 0, i64 0))
%52 = load i32*, i32** %2
%53 = call i32 @fclose(i32* %52)
%54 = load i32, i32* %1
ret i32 %54
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [9 x i8] c"_cal.csv\00"
@.str.4 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.8 = [3 x i8] c"\09\09\00"
@str = [30 x i8] c"Ingrese el nombre del archivo\00"
@str.12 = [80 x i8] c"| Cuenta | Calificacion | Res. Correctas | No. Preguntas | Tiempo Transcurrido|\00"
@str.13 = [80 x i8] c"*--------*--------------*----------------*---------------*--------------------*\00"
@str.14 = [80 x i8] c"*-----------------------------------------------------------------------------*\00"
@str.15 = [26 x i8] c"No se encontro el archivo\00"
define i32 @consultador() {
%1 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @putchar(i32 10)
%6 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %16
8: ; preds = %0, %8
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.15, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%12 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @putchar(i32 10)
%14 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %8, label %16
16: ; preds = %8, %0
%17 = phi i32* [ %6, %0 ], [ %14, %8 ]
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str.13, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str.12, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str.13, i64 0, i64 0))
%21 = tail call signext i8 @getc(i32* %17)
%22 = load i8, i8* @EOF
%23 = icmp eq i8 %21, %22
br i1 %23, label %36, label %24
24: ; preds = %16, %32
%25 = phi i8 [ %33, %32 ], [ %21, %16 ]
%26 = icmp eq i8 %25, 44
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %32
29: ; preds = %24
%30 = sext i8 %25 to i32
%31 = tail call i32 @putchar(i32 %30)
br label %32
32: ; preds = %29, %27
%33 = tail call signext i8 @getc(i32* %17)
%34 = load i8, i8* @EOF
%35 = icmp eq i8 %33, %34
br i1 %35, label %36, label %24
36: ; preds = %32, %16
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str.14, i64 0, i64 0))
%38 = tail call i32 @fclose(i32* %17)
ret i32 undef
}