#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*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int readFile(char *nomFile, char delimCampo, char delimRegistro) {
  FILE *fd;
  if ((fd = fopen(nomFile, "rt")) == NULL) {
    printf("\n\t\t\t    [msgError]: No se pudo abrir el archivo.");
    return -1;
  } else {
    fseek(fd, 0, 0);
    int i = 0;
    char buffer[15];
    while (!feof(fd)) {
      buffer[i++] = fgetc(fd);
      if (buffer[i - 1] == delimCampo) {
        buffer[i - 1] = '\0';
        printf("% 12s", buffer);
        i = 0;
      }
      if (buffer[i - 1] == delimRegistro) {
        buffer[i - 1] = '\0';
        i = 0;
        printf("% 12s\n\t", buffer);
      }
    }
    fclose(fd);
  }
  return 0;
}


x86 assembly (clang, -O0):
<readFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %rdi,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11af <readFile+0x4f>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1290 <readFile+0x130>
mov    -0x20(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1070 <fseek@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11e1 <readFile+0x81>
jmp    1280 <readFile+0x120>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,%cl
mov    -0x24(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
cltq
mov    %cl,-0x33(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x33(%rbp,%rax,1),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    123c <readFile+0xdc>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x33(%rbp,%rax,1)
lea    -0x33(%rbp),%rsi
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x33(%rbp,%rax,1),%eax
movsbl -0x12(%rbp),%ecx
cmp    %ecx,%eax
jne    127b <readFile+0x11b>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x33(%rbp,%rax,1)
movl   $0x0,-0x24(%rbp)
lea    -0x33(%rbp),%rsi
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c3 <readFile+0x63>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r15d
mov    %esi,%ebp
lea    0xe86(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11ab <readFile+0x4b>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <fseek@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11cd <readFile+0x6d>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    11be <readFile+0x5e>
lea    0xe51(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r12d,%r12d
lea    0x9(%rsp),%r13
lea    0xe5e(%rip),%r14
jmp    11ec <readFile+0x8c>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    119f <readFile+0x3f>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
movslq %r12d,%rcx
mov    %al,0x9(%rsp,%rcx,1)
cmp    %bpl,%al
jne    1230 <readFile+0xd0>
movb   $0x0,0x9(%rsp,%rcx,1)
xor    %r12d,%r12d
lea    0xe25(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x8(%rsp),%eax
cmp    %r15b,%al
jne    11e0 <readFile+0x80>
jmp    1239 <readFile+0xd9>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r12d
cmp    %r15b,%al
jne    11e0 <readFile+0x80>
movslq %r12d,%rax
movb   $0x0,-0x1(%rax,%r13,1)
xor    %r12d,%r12d
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11e0 <readFile+0x80>

LLVM IR (-O0):
@.str = [3 x i8] c"rt\00"
@.str.1 = [49 x i8] c"\0A\09\09\09 [msgError]: No se pudo abrir el archivo.\00"
@.str.2 = [6 x i8] c"% 12s\00"
@.str.3 = [8 x i8] c"% 12s\0A\09\00"
define i32 @readFile(i8* %0, i8 signext %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32*
%9 = alloca i32
%10 = alloca [15 x i8]
store i8* %0, i8** %5
store i8 %1, i8* %6
store i8 %2, i8* %7
%11 = load i8*, i8** %5
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %8
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %69
16: ; preds = %3
%17 = load i32*, i32** %8
%18 = call i32 @fseek(i32* %17, i32 0, i32 0)
store i32 0, i32* %9
br label %19
19: ; preds = %64, %16
%20 = load i32*, i32** %8
%21 = call i32 @feof(i32* %20)
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
br i1 %23, label %24, label %65
24: ; preds = %19
%25 = load i32*, i32** %8
%26 = call signext i8 @fgetc(i32* %25)
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds [15 x i8], [15 x i8]* %10, i64 0, i64 %29
store i8 %26, i8* %30
%31 = load i32, i32* %9
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [15 x i8], [15 x i8]* %10, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = load i8, i8* %6
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %36, %38
br i1 %39, label %40, label %47
40: ; preds = %24
%41 = load i32, i32* %9
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [15 x i8], [15 x i8]* %10, i64 0, i64 %43
store i8 0, i8* %44
%45 = getelementptr inbounds [15 x i8], [15 x i8]* %10, i64 0, i64 0
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %45)
store i32 0, i32* %9
br label %47
47: ; preds = %40, %24
%48 = load i32, i32* %9
%49 = sub nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [15 x i8], [15 x i8]* %10, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = load i8, i8* %7
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %53, %55
br i1 %56, label %57, label %64
57: ; preds = %47
%58 = load i32, i32* %9
%59 = sub nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [15 x i8], [15 x i8]* %10, i64 0, i64 %60
store i8 0, i8* %61
store i32 0, i32* %9
%62 = getelementptr inbounds [15 x i8], [15 x i8]* %10, i64 0, i64 0
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %62)
br label %64
64: ; preds = %57, %47
br label %19
65: ; preds = %19
%66 = load i32*, i32** %8
%67 = call i32 @fclose(i32* %66)
br label %68
68: ; preds = %65
store i32 0, i32* %4
br label %69
69: ; preds = %68, %14
%70 = load i32, i32* %4
ret i32 %70
}

LLVM IR (-O2):
@.str = [3 x i8] c"rt\00"
@.str.1 = [49 x i8] c"\0A\09\09\09 [msgError]: No se pudo abrir el archivo.\00"
@.str.2 = [6 x i8] c"% 12s\00"
@.str.3 = [8 x i8] c"% 12s\0A\09\00"
define i32 @readFile(i8* nocapture %0, i8 signext %1, i8 signext %2) {
%4 = alloca [15 x i8]
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
br label %41
9: ; preds = %3
%10 = tail call i32 @fseek(i32* %5, i32 0, i32 0)
%11 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%12 = call i32 @feof(i32* %5)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %39
14: ; preds = %9
%15 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 -1
br label %16
16: ; preds = %14, %35
%17 = phi i32 [ %36, %35 ], [ 0, %14 ]
%18 = call signext i8 @fgetc(i32* %5)
%19 = add nsw i32 %17, 1
%20 = sext i32 %17 to i64
%21 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 %20
store i8 %18, i8* %21
%22 = icmp eq i8 %18, %1
br i1 %22, label %23, label %26
23: ; preds = %16
store i8 0, i8* %21
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%25 = load i8, i8* %15
br label %26
26: ; preds = %23, %16
%27 = phi i8 [ %25, %23 ], [ %18, %16 ]
%28 = phi i32 [ 0, %23 ], [ %19, %16 ]
%29 = icmp eq i8 %27, %2
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = add nsw i32 %28, -1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 %32
store i8 0, i8* %33
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %11)
br label %35
35: ; preds = %30, %26
%36 = phi i32 [ 0, %30 ], [ %28, %26 ]
%37 = call i32 @feof(i32* %5)
%38 = icmp eq i32 %37, 0
br i1 %38, label %16, label %39
39: ; preds = %35, %9
%40 = call i32 @fclose(i32* %5)
br label %41
41: ; preds = %39, %7
%42 = phi i32 [ -1, %7 ], [ 0, %39 ]
ret i32 %42
}