#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;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int file2arr(FILE *archivo, char *buffer) {
  char temp;
  int i;
  rewind(archivo);
  for (i = 0; i < 2048 && ((temp = fgetc(archivo)) != EOF); i++) {
    buffer[i] = temp;
    if (i == 2048 - 1) {
      printf("Error: No se ha podido leer el archivo en plenitud ya que excede "
             "los 2 MB, redefina la constante MAX_BUFFER.\n");
      return 2048;
    }
  }
  return i;
}


x86 assembly (clang, -O0):
<file2arr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <rewind@plt>
movl   $0x0,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0x800,-0x20(%rbp)
mov    %al,-0x21(%rbp)
jge    1183 <file2arr+0x53>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2e70(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1193 <file2arr+0x63>
jmp    11d9 <file2arr+0xa9>
mov    -0x19(%rbp),%dl
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
cmpl   $0x7ff,-0x20(%rbp)
jne    11c6 <file2arr+0x96>
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
movl   $0x800,-0x4(%rbp)
jmp    11df <file2arr+0xaf>
jmp    11cb <file2arr+0x9b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1150 <file2arr+0x20>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file2arr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <rewind@plt>
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    0x2e96(%rip),%r12
xor    %ebx,%ebx
cmp    (%r12),%al
je     1192 <file2arr+0x62>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %al,(%r14,%rbx,1)
cmp    $0x7ff,%rbx
je     1181 <file2arr+0x51>
add    $0x1,%rbx
mov    %r15,%rdi
call   1050 <fgetc@plt>
cmp    (%r12),%al
jne    1160 <file2arr+0x30>
jmp    1192 <file2arr+0x62>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
mov    $0x800,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i8 0
@.str = [110 x i8] c"Error: No se ha podido leer el archivo en plenitud ya que excede los 2 MB, redefina la constante MAX_BUFFER.\0A\00"
define i32 @file2arr(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%8 = load i32*, i32** %4
%9 = call i32 @rewind(i32* %8)
store i32 0, i32* %7
br label %10
10: ; preds = %33, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 2048
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32*, i32** %4
%15 = call signext i8 @fgetc(i32* %14)
store i8 %15, i8* %6
%16 = sext i8 %15 to i32
%17 = load i8, i8* @EOF
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %16, %18
br label %20
20: ; preds = %13, %10
%21 = phi i1 [ false, %10 ], [ %19, %13 ]
br i1 %21, label %22, label %36
22: ; preds = %20
%23 = load i8, i8* %6
%24 = load i8*, i8** %5
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
store i8 %23, i8* %27
%28 = load i32, i32* %7
%29 = icmp eq i32 %28, 2047
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = call i32 @printf(i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str, i64 0, i64 0))
store i32 2048, i32* %3
br label %38
32: ; preds = %22
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %10
36: ; preds = %20
%37 = load i32, i32* %7
store i32 %37, i32* %3
br label %38
38: ; preds = %36, %30
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@EOF = global i8 0
@str = [109 x i8] c"Error: No se ha podido leer el archivo en plenitud ya que excede los 2 MB, redefina la constante MAX_BUFFER.\00"
define i32 @file2arr(i32* nocapture %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @rewind(i32* %0)
%4 = tail call signext i8 @fgetc(i32* %0)
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %4, %5
br i1 %6, label %21, label %7
7: ; preds = %2, %14
%8 = phi i64 [ %15, %14 ], [ 0, %2 ]
%9 = phi i8 [ %16, %14 ], [ %4, %2 ]
%10 = getelementptr inbounds i8, i8* %1, i64 %8
store i8 %9, i8* %10
%11 = icmp eq i64 %8, 2047
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([109 x i8], [109 x i8]* @str, i64 0, i64 0))
br label %21
14: ; preds = %7
%15 = add nuw nsw i64 %8, 1
%16 = tail call signext i8 @fgetc(i32* %0)
%17 = load i8, i8* @EOF
%18 = icmp eq i8 %16, %17
br i1 %18, label %19, label %7
19: ; preds = %14
%20 = trunc i64 %15 to i32
br label %21
21: ; preds = %19, %2, %12
%22 = phi i32 [ 2048, %12 ], [ 0, %2 ], [ %20, %19 ]
ret i32 %22
}