#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*/ line_buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int BUFSIZ;
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
void parse_nodes_file(char *filename) {
  FILE *infile;
  char line_buffer[BUFSIZ];
  char line_number;
  infile = fopen(filename, "r");
  if (!infile) {
    printf("No se pudo abrir el archivo %s\n", filename);
  }
  printf("Archivo abierto %s\n\n", filename);
  line_number = 0;
  while (fgets(line_buffer, sizeof(line_buffer), infile)) {
    ++line_number;
    printf("%s", line_buffer);
  }
}


x86 assembly (clang, -O0):
<parse_nodes_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x38(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119b <parse_nodes_file+0x6b>
mov    -0x8(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
movb   $0x0,-0x21(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11e9 <parse_nodes_file+0xb9>
mov    -0x30(%rbp),%rsi
mov    -0x21(%rbp),%al
add    $0x1,%al
mov    %al,-0x21(%rbp)
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
jmp    11af <parse_nodes_file+0x7f>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_nodes_file>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
mov    0x2e9b(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%rbx
mov    %r14,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe9d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    117f <parse_nodes_file+0x4f>
lea    0xe8b(%rip),%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11ce <parse_nodes_file+0x9e>
lea    0xe8f(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    11b0 <parse_nodes_file+0x80>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [32 x i8] c"No se pudo abrir el archivo %s\0A\00"
@.str.2 = [21 x i8] c"Archivo abierto %s\0A\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define void @parse_nodes_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8
store i8* %0, i8** %2
%7 = load i32, i32* @BUFSIZ
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %4
%10 = alloca i8, i64 %8
store i64 %8, i64* %5
%11 = load i8*, i8** %2
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %3
%13 = load i32*, i32** %3
%14 = icmp ne i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %1
%16 = load i8*, i8** %2
%17 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %15, %1
%19 = load i8*, i8** %2
%20 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %19)
store i8 0, i8* %6
br label %21
21: ; preds = %26, %18
%22 = trunc i64 %8 to i32
%23 = load i32*, i32** %3
%24 = call i64 @fgets(i8* %10, i32 %22, i32* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = load i8, i8* %6
%28 = add i8 %27, 1
store i8 %28, i8* %6
%29 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %10)
br label %21
30: ; preds = %21
%31 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [32 x i8] c"No se pudo abrir el archivo %s\0A\00"
@.str.2 = [21 x i8] c"Archivo abierto %s\0A\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define void @parse_nodes_file(i8* %0) {
%2 = load i32, i32* @BUFSIZ
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %7, %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%11 = call i64 @fgets(i8* %4, i32 %2, i32* %5)
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %9, %13
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%15 = call i64 @fgets(i8* %4, i32 %2, i32* %5)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %13
17: ; preds = %13, %9
ret void
}