#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 */

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int strlen(char *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  char buffer[512];
  int i = argc;
  printf("El número de parámetros es: %d", i);
  printf("\n");
  printf("El primer argumento de las cadenas es: %s\n", argv[0]);
  printf("El segudno argumento, en caso de existir, es: %s\n", argv[1]);
  printf("\n");
  int fd = open(argv[1], O_RDWR);
  if (fd == -1) {
    printf("Error en la apertura del archivo %s\n", argv[1]);
    exit(-1);
  } else {
    printf("El archivo %s, tiene como descriptor: %d\n", argv[1], fd);
    int readbytes = read(fd, buffer, 512);
    write(1, buffer, readbytes);
    int tFile = strlen(buffer);
    printf("El tamaño del array es: %d", tFile);
    close(fd);
    printf("\n\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x214(%rbp)
mov    -0x214(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf44(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2df3(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x218(%rbp)
cmpl   $0xffffffff,-0x218(%rbp)
jne    122f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x218(%rbp),%edx
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x218(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0x200,%edx
call   1070 <read@plt>
mov    %eax,-0x21c(%rbp)
lea    -0x210(%rbp),%rsi
mov    -0x21c(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
lea    -0x210(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x220(%rbp)
mov    -0x220(%rbp),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x218(%rbp),%edi
call   1060 <close@plt>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%rbx
mov    %edi,%esi
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rbx),%rsi
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%rsi
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rbx),%rdi
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    0x8(%rbx),%rsi
cmp    $0xffffffff,%eax
je     1268 <main+0xd8>
mov    %eax,%ebp
lea    0xe9c(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x200,%edx
call   1090 <read@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0xe8d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebp,%edi
call   1080 <close@plt>
lea    0xe74(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe0f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"El n\C3\BAmero de par\C3\A1metros es: %d\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [43 x i8] c"El primer argumento de las cadenas es: %s\0A\00"
@.str.3 = [50 x i8] c"El segudno argumento, en caso de existir, es: %s\0A\00"
@O_RDWR = global i32 0
@.str.4 = [37 x i8] c"Error en la apertura del archivo %s\0A\00"
@.str.5 = [42 x i8] c"El archivo %s, tiene como descriptor: %d\0A\00"
@.str.6 = [28 x i8] c"El tama\C3\B1o del array es: %d\00"
@.str.7 = [3 x i8] c"\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [512 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%10 = load i32, i32* %3
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = load i8**, i8*** %4
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = load i32, i32* @O_RDWR
%27 = call i32 @open(i8* %25, i32 %26)
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %36
30: ; preds = %2
%31 = load i8**, i8*** %4
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %33)
%35 = call i32 @exit(i32 -1)
unreachable
36: ; preds = %2
%37 = load i8**, i8*** %4
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = load i32, i32* %7
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i8* %39, i32 %40)
%42 = load i32, i32* %7
%43 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%44 = call i32 @read(i32 %42, i8* %43, i32 512)
store i32 %44, i32* %8
%45 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%46 = load i32, i32* %8
%47 = call i32 @write(i32 1, i8* %45, i32 %46)
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%49 = call i32 @strlen(i8* %48)
store i32 %49, i32* %9
%50 = load i32, i32* %9
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %7
%53 = call i32 @close(i32 %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %55
55: ; preds = %36
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"El n\C3\BAmero de par\C3\A1metros es: %d\00"
@.str.2 = [43 x i8] c"El primer argumento de las cadenas es: %s\0A\00"
@.str.3 = [50 x i8] c"El segudno argumento, en caso de existir, es: %s\0A\00"
@O_RDWR = global i32 0
@.str.4 = [37 x i8] c"Error en la apertura del archivo %s\0A\00"
@.str.5 = [42 x i8] c"El archivo %s, tiene como descriptor: %d\0A\00"
@.str.6 = [28 x i8] c"El tama\C3\B1o del array es: %d\00"
@str = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %0)
%6 = tail call i32 @putchar(i32 10)
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%12 = tail call i32 @putchar(i32 10)
%13 = load i8*, i8** %9
%14 = load i32, i32* @O_RDWR
%15 = tail call i32 @open(i8* %13, i32 %14)
%16 = icmp eq i32 %15, -1
%17 = load i8*, i8** %9
br i1 %16, label %18, label %21
18: ; preds = %2
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %17)
%20 = tail call i32 @exit(i32 -1)
unreachable
21: ; preds = %2
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i8* %17, i32 %15)
%23 = call i32 @read(i32 %15, i8* %4, i32 512)
%24 = call i32 @write(i32 1, i8* %4, i32 %23)
%25 = call i32 @strlen(i8* %4)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %25)
%27 = call i32 @close(i32 %15)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}