#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 EXIT_SUCCESS;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, char *, char *,
                          char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *fp;
  char *fild1, *fild2, *fild3, *fild4;
  if ((fp = fopen("./diario_de_aula.txt", "r")) == NULL) {
    printf("Cannot open file.\n");
    exit(1);
  };
  fild1 = (char *)malloc((size_t)(80) * sizeof(char));
  if (!fild1) {
    fprintf(stderr, "!!ERROR!!");
  }
  fild2 = (char *)malloc((size_t)(4) * sizeof(char));
  if (!fild2) {
    fprintf(stderr, "!!ERROR!!");
  }
  fild3 = (char *)malloc((size_t)(4) * sizeof(char));
  if (!fild3) {
    fprintf(stderr, "!!ERROR!!");
  }
  fild4 = (char *)malloc((size_t)(4) * sizeof(char));
  if (!fild4) {
    fprintf(stderr, "!!ERROR!!");
  }
  fscanf(fp, "%[^|\n]%*[ |]%[^|\n]%*[|]%[^|\n]%*[|]%[^|\n]|%*[\n]", fild1,
         fild2, fild3, fild4);
  printf("campo: %s\n", fild1);
  printf("campo: %s\n", fild2);
  printf("campo: %s\n", fild3);
  printf("campo: %s\n", fild4);
  free(fild1);
  free(fild2);
  free(fild3);
  free(fild4);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11bf <main+0x4f>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    $0x50,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ed <main+0x7d>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    121b <main+0xab>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1249 <main+0xd9>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1277 <main+0x107>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    0xdb8(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
lea    0xda2(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rsi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    0x2cce(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xe70(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12cd <main+0x14d>
mov    %rax,%r15
mov    $0x50,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11cf <main+0x4f>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x4,%edi
call   1080 <malloc@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11f6 <main+0x76>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x4,%edi
call   1080 <malloc@plt>
mov    %rax,%r13
test   %rax,%rax
jne    121d <main+0x9d>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x4,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1244 <main+0xc4>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xdd6(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %rbx,%r9
call   1060 <fscanf@plt>
lea    0xdea(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2d17(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xd87(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"./diario_de_aula.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"Cannot open file.\0A\00"
@stderr = global i32 0
@.str.3 = [10 x i8] c"!!ERROR!!\00"
@.str.4 = [47 x i8] c"%[^|\0A]%*[ |]%[^|\0A]%*[|]%[^|\0A]%*[|]%[^|\0A]|%*[\0A]\00"
@.str.5 = [11 x i8] c"campo: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %6
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = call i64 @malloc(i64 80)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %7
%19 = load i8*, i8** %7
%20 = icmp ne i8* %19, null
br i1 %20, label %24, label %21
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %21, %16
%25 = call i64 @malloc(i64 4)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %8
%27 = load i8*, i8** %8
%28 = icmp ne i8* %27, null
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %29, %24
%33 = call i64 @malloc(i64 4)
%34 = inttoptr i64 %33 to i8*
store i8* %34, i8** %9
%35 = load i8*, i8** %9
%36 = icmp ne i8* %35, null
br i1 %36, label %40, label %37
37: ; preds = %32
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %37, %32
%41 = call i64 @malloc(i64 4)
%42 = inttoptr i64 %41 to i8*
store i8* %42, i8** %10
%43 = load i8*, i8** %10
%44 = icmp ne i8* %43, null
br i1 %44, label %48, label %45
45: ; preds = %40
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %48
48: ; preds = %45, %40
%49 = load i32*, i32** %6
%50 = load i8*, i8** %7
%51 = load i8*, i8** %8
%52 = load i8*, i8** %9
%53 = load i8*, i8** %10
%54 = call i32 @fscanf(i32* %49, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* %50, i8* %51, i8* %52, i8* %53)
%55 = load i8*, i8** %7
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %55)
%57 = load i8*, i8** %8
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %57)
%59 = load i8*, i8** %9
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %59)
%61 = load i8*, i8** %10
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %61)
%63 = load i8*, i8** %7
%64 = call i32 @free(i8* %63)
%65 = load i8*, i8** %8
%66 = call i32 @free(i8* %65)
%67 = load i8*, i8** %9
%68 = call i32 @free(i8* %67)
%69 = load i8*, i8** %10
%70 = call i32 @free(i8* %69)
%71 = load i32, i32* @EXIT_SUCCESS
ret i32 %71
}

LLVM IR (-O2):
@.str = [21 x i8] c"./diario_de_aula.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [10 x i8] c"!!ERROR!!\00"
@.str.4 = [47 x i8] c"%[^|\0A]%*[ |]%[^|\0A]%*[|]%[^|\0A]%*[|]%[^|\0A]|%*[\0A]\00"
@.str.5 = [11 x i8] c"campo: %s\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [18 x i8] c"Cannot open file.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 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 %5, label %8
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = tail call i64 @malloc(i64 80)
%10 = inttoptr i64 %9 to i8*
%11 = icmp eq i64 %9, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %12, %8
%16 = tail call i64 @malloc(i64 4)
%17 = inttoptr i64 %16 to i8*
%18 = icmp eq i64 %16, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %19, %15
%23 = tail call i64 @malloc(i64 4)
%24 = inttoptr i64 %23 to i8*
%25 = icmp eq i64 %23, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %26, %22
%30 = tail call i64 @malloc(i64 4)
%31 = inttoptr i64 %30 to i8*
%32 = icmp eq i64 %30, 0
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = tail call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %33, %29
%37 = tail call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* %10, i8* %17, i8* %24, i8* %31)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %10)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %17)
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %24)
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %31)
%42 = tail call i32 @free(i8* %10)
%43 = tail call i32 @free(i8* %17)
%44 = tail call i32 @free(i8* %24)
%45 = tail call i32 @free(i8* %31)
%46 = load i32, i32* @EXIT_SUCCESS
ret i32 %46
}