#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
void imprimirEmpleados() {
  FILE *fp = fopen("salaries.csv", "r");
  char buffer[100], c;
  fgets(buffer, 100, fp);
  if (fp == NULL) {
    printf("Cannot open file \n");
    exit(0);
  }
  c = fgetc(fp);
  while (c != EOF) {
    printf("%c", c);
    c = fgetc(fp);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<imprimirEmpleados>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    0xe8e(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x64,%esi
call   1060 <fgets@plt>
cmpq   $0x0,-0x8(%rbp)
jne    11b4 <imprimirEmpleados+0x54>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x71(%rbp)
movsbl -0x71(%rbp),%eax
mov    0x2e1d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11f9 <imprimirEmpleados+0x99>
movsbl -0x71(%rbp),%esi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x71(%rbp)
jmp    11c0 <imprimirEmpleados+0x60>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imprimirEmpleados>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xe82(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x64,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rbx,%rbx
je     11e5 <imprimirEmpleados+0x75>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    0x2e37(%rip),%r14
cmp    (%r14),%al
je     11d5 <imprimirEmpleados+0x65>
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    (%r14),%al
jne    11c0 <imprimirEmpleados+0x50>
mov    %rbx,%rdi
call   1050 <fclose@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe23(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"salaries.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"Cannot open file \0A\00"
@EOF = global i8 0
@.str.3 = [3 x i8] c"%c\00"
define void @imprimirEmpleados() {
%1 = alloca i32*
%2 = alloca [100 x i8]
%3 = alloca i8
%4 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %1
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = load i32*, i32** %1
%7 = call i32 @fgets(i8* %5, i32 100, i32* %6)
%8 = load i32*, i32** %1
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %0
%14 = load i32*, i32** %1
%15 = call signext i8 @fgetc(i32* %14)
store i8 %15, i8* %3
br label %16
16: ; preds = %22, %13
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
%19 = load i8, i8* @EOF
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %18, %20
br i1 %21, label %22, label %28
22: ; preds = %16
%23 = load i8, i8* %3
%24 = sext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i32*, i32** %1
%27 = call signext i8 @fgetc(i32* %26)
store i8 %27, i8* %3
br label %16
28: ; preds = %16
%29 = load i32*, i32** %1
%30 = call i32 @fclose(i32* %29)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"salaries.csv\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@str = [18 x i8] c"Cannot open file \00"
define void @imprimirEmpleados() {
%1 = alloca [100 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = call i32 @fgets(i8* %3, i32 100, i32* %2)
%5 = icmp eq i32* %2, null
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%8 = call i32 @exit(i32 0)
unreachable
9: ; preds = %0
%10 = call signext i8 @fgetc(i32* %2)
%11 = load i8, i8* @EOF
%12 = icmp eq i8 %10, %11
br i1 %12, label %20, label %13
13: ; preds = %9, %13
%14 = phi i8 [ %17, %13 ], [ %10, %9 ]
%15 = sext i8 %14 to i32
%16 = call i32 @putchar(i32 %15)
%17 = call signext i8 @fgetc(i32* %2)
%18 = load i8, i8* @EOF
%19 = icmp eq i8 %17, %18
br i1 %19, label %20, label %13
20: ; preds = %13, %9
%21 = call i32 @fclose(i32* %2)
ret void
}