#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 ssize_t;
typedef int /*<<< orphan*/ sizefilename;
typedef char off_t;
typedef int /*<<< orphan*/ lenfilename;
typedef int /*<<< orphan*/ found;
typedef int /*<<< orphan*/ flag_f;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int read(int, ...);
int /*<<< orphan*/ sprintf(char *, char *, ...);
scalar_t__ strcmp(char *, char *);
scalar_t__ strlen(char *);
int write(int /*<<< orphan*/, char *, int);
void list(int fd) {
  off_t sizefilename;
  ssize_t nbytes;
  size_t lenfilename;
  char buf[1033];
  char type[4];
  char flag_f = '#';
  char *filename;
  int found = 0;
  nbytes = read(fd, &found, sizeof(found));
  if (nbytes == -1) {
    perror("Error read");
    exit(EXIT_FAILURE);
  }
  if (found == 1) {
    nbytes = read(fd, type, 3);
    if (nbytes == -1) {
      perror("Error read");
      exit(EXIT_FAILURE);
    }
    if (nbytes == 0) {
      exit(EXIT_SUCCESS);
    }
    type[nbytes] = '\0';
    if (strcmp(type, "REG") == 0) {
      nbytes = read(fd, &sizefilename, sizeof(sizefilename));
      if (nbytes == -1) {
        perror("Error read");
        exit(EXIT_FAILURE);
      }
      if (nbytes == 0) {
        exit(EXIT_SUCCESS);
      }
      sprintf(buf, "The size of the file is %lld\n", sizefilename);
      if (write(STDOUT_FILENO, buf, strlen(buf)) < strlen(buf)) {
        perror("Error write");
        exit(EXIT_FAILURE);
      }
    } else if (strcmp(type, "DIR") == 0) {
      for (;;) {
        nbytes = read(fd, &flag_f, sizeof(flag_f));
        if (nbytes == -1) {
          perror("Error read");
          exit(EXIT_FAILURE);
        }
        if (nbytes == 0) {
          exit(EXIT_SUCCESS);
        }
        if (flag_f == 'f') {
          if (nbytes == -1) {
            perror("Error read");
            exit(EXIT_FAILURE);
          }
          filename = (char *)malloc(sizeof(char) * 1024 + 1);
          if (filename == NULL) {
            perror("Error malloc list");
            exit(EXIT_FAILURE);
          }
          nbytes = read(fd, &lenfilename, sizeof(lenfilename));
          if (nbytes == -1) {
            perror("Error read");
            exit(EXIT_FAILURE);
          }
          if (nbytes == 0) {
            exit(EXIT_SUCCESS);
          }
          nbytes = read(fd, filename, lenfilename);
          if (nbytes == -1) {
            perror("Error read");
            exit(EXIT_FAILURE);
          }
          filename[nbytes] = '\0';
          nbytes = read(fd, &sizefilename, sizeof(sizefilename));
          if (nbytes == -1) {
            perror("Error read");
            exit(EXIT_FAILURE);
          }
          sprintf(buf, "The file %s has size: %llu\n", filename, sizefilename);
          if (write(STDOUT_FILENO, buf, strlen(buf)) < strlen(buf)) {
            perror("Error write");
            exit(EXIT_FAILURE);
          }
          free(filename);
        } else if (flag_f == 'd') {
          continue;
        } else {
          if (flag_f == 'e') {
            break;
          }
        }
      }
    } else {
      if (write(STDOUT_FILENO, "The file is not a regular file/directory!\n",
                42) < 42) {
        perror("Error write");
        exit(EXIT_SUCCESS);
      }
    }
  } else {
    if (write(STDOUT_FILENO, "File not found!\n", 16) < 16) {
      perror("Error write");
      exit(EXIT_FAILURE);
    }
  }
}


x86 assembly (clang, -O0):
<list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x480,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x23,-0x435(%rbp)
movl   $0x0,-0x444(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x444(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1060 <read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    11ec <list+0x5c>
lea    0xe27(%rip),%rdi
call   1090 <perror@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
cmpl   $0x1,-0x444(%rbp)
jne    165b <list+0x4cb>
mov    -0x4(%rbp),%edi
lea    -0x434(%rbp),%rsi
mov    $0x3,%edx
mov    $0x0,%al
call   1060 <read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1236 <list+0xa6>
lea    0xddd(%rip),%rdi
call   1090 <perror@plt>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0xc(%rbp)
jne    124e <list+0xbe>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
movslq -0xc(%rbp),%rax
movb   $0x0,-0x434(%rbp,%rax,1)
lea    -0x434(%rbp),%rdi
lea    0xda3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1366 <list+0x1d6>
mov    -0x4(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1060 <read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    12b1 <list+0x121>
lea    0xd62(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0xc(%rbp)
jne    12c9 <list+0x139>
mov    0x2d0e(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
lea    -0x430(%rbp),%rdi
movsbl -0x5(%rbp),%edx
lea    0xd34(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    0x2d07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x45c(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x458(%rbp)
lea    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x45c(%rbp),%edi
mov    -0x458(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
cltq
mov    %rax,-0x450(%rbp)
lea    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x450(%rbp),%rax
cmp    %rcx,%rax
jge    1361 <list+0x1d1>
lea    0xcdf(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c7e(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
jmp    1656 <list+0x4c6>
lea    -0x434(%rbp),%rdi
lea    0xcc5(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    160f <list+0x47f>
jmp    1388 <list+0x1f8>
mov    -0x4(%rbp),%edi
lea    -0x435(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1060 <read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    13c5 <list+0x235>
lea    0xc4e(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0xc(%rbp)
jne    13dd <list+0x24d>
mov    0x2bfa(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
movsbl -0x435(%rbp),%eax
cmp    $0x66,%eax
jne    15d1 <list+0x441>
cmpl   $0xffffffff,-0xc(%rbp)
jne    1411 <list+0x281>
lea    0xc02(%rip),%rdi
call   1090 <perror@plt>
mov    0x2bce(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    $0x401,%edi
call   1080 <malloc@plt>
mov    %rax,-0x440(%rbp)
cmpq   $0x0,-0x440(%rbp)
jne    144a <list+0x2ba>
lea    0xc06(%rip),%rdi
call   1090 <perror@plt>
mov    0x2b95(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1060 <read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1484 <list+0x2f4>
lea    0xb8f(%rip),%rdi
call   1090 <perror@plt>
mov    0x2b5b(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0xc(%rbp)
jne    149c <list+0x30c>
mov    0x2b3b(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x440(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1060 <read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    14d8 <list+0x348>
lea    0xb3b(%rip),%rdi
call   1090 <perror@plt>
mov    0x2b07(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x440(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x4(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1060 <read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1521 <list+0x391>
lea    0xaf2(%rip),%rdi
call   1090 <perror@plt>
mov    0x2abe(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
lea    -0x430(%rbp),%rdi
mov    -0x440(%rbp),%rdx
movsbl -0x5(%rbp),%ecx
lea    0xb15(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    0x2aa8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x474(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x470(%rbp)
lea    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x474(%rbp),%edi
mov    -0x470(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
cltq
mov    %rax,-0x468(%rbp)
lea    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x468(%rbp),%rax
cmp    %rcx,%rax
jge    15c0 <list+0x430>
lea    0xa80(%rip),%rdi
call   1090 <perror@plt>
mov    0x2a1f(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x440(%rbp),%rdi
call   1030 <free@plt>
jmp    1605 <list+0x475>
movsbl -0x435(%rbp),%eax
cmp    $0x64,%eax
jne    15e6 <list+0x456>
jmp    1388 <list+0x1f8>
movsbl -0x435(%rbp),%eax
cmp    $0x65,%eax
jne    15fb <list+0x46b>
jmp    160a <list+0x47a>
jmp    1600 <list+0x470>
jmp    1605 <list+0x475>
jmp    1388 <list+0x1f8>
jmp    1651 <list+0x4c1>
mov    0x29da(%rip),%rax
mov    (%rax),%edi
lea    0xa4c(%rip),%rsi
mov    $0x2a,%edx
call   1040 <write@plt>
cmp    $0x2a,%eax
jge    164c <list+0x4bc>
lea    0x9f4(%rip),%rdi
call   1090 <perror@plt>
mov    0x298b(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
jmp    1651 <list+0x4c1>
jmp    1656 <list+0x4c6>
jmp    169d <list+0x50d>
mov    0x298e(%rip),%rax
mov    (%rax),%edi
lea    0xa2b(%rip),%rsi
mov    $0x10,%edx
call   1040 <write@plt>
cmp    $0x10,%eax
jge    1698 <list+0x508>
lea    0x9a8(%rip),%rdi
call   1090 <perror@plt>
mov    0x2947(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
jmp    169d <list+0x50d>
add    $0x480,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    %edi,%ebx
movb   $0x23,0xf(%rsp)
movl   $0x0,0x14(%rsp)
lea    0x14(%rsp),%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1060 <read@plt>
cmp    $0xffffffff,%eax
je     1413 <list+0x283>
cmpl   $0x1,0x14(%rsp)
jne    1264 <list+0xd4>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x3,%edx
xor    %eax,%eax
call   1060 <read@plt>
test   %eax,%eax
je     142d <list+0x29d>
cmp    $0xffffffff,%eax
je     1413 <list+0x283>
cltq
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xe04(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1288 <list+0xf8>
lea    0xe1c(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     130a <list+0x17a>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xe2b(%rip),%rsi
mov    $0x2a,%edx
call   1040 <write@plt>
cmp    $0x29,%eax
jg     12f8 <list+0x168>
lea    0xdd3(%rip),%rdi
call   1090 <perror@plt>
jmp    142d <list+0x29d>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    0xe22(%rip),%rsi
mov    $0x10,%edx
call   1040 <write@plt>
cmp    $0xf,%eax
jg     12f8 <list+0x168>
jmp    143b <list+0x2ab>
lea    0xe(%rsp),%rsi
mov    $0x1,%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <read@plt>
test   %eax,%eax
je     142d <list+0x29d>
cmp    $0xffffffff,%eax
je     1413 <list+0x283>
movsbl 0xe(%rsp),%edx
lea    0xd57(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    0x2d22(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
movslq %eax,%rbp
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    %rbp,%rax
jg     143b <list+0x2ab>
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xf(%rsp),%r14
lea    0x20(%rsp),%r13
jmp    1324 <list+0x194>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x65,%al
je     12f8 <list+0x168>
mov    $0x1,%edx
mov    %ebx,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <read@plt>
test   %eax,%eax
je     142d <list+0x29d>
cmp    $0xffffffff,%eax
je     1413 <list+0x283>
movzbl 0xf(%rsp),%eax
cmp    $0x66,%al
jne    1320 <list+0x190>
mov    $0x401,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     1444 <list+0x2b4>
mov    %rax,%r15
mov    $0x8,%edx
mov    %ebx,%edi
lea    0x18(%rsp),%rsi
xor    %eax,%eax
call   1060 <read@plt>
test   %eax,%eax
je     142d <list+0x29d>
cmp    $0xffffffff,%eax
je     1413 <list+0x283>
mov    0x18(%rsp),%rdx
mov    %ebx,%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <read@plt>
cmp    $0xffffffff,%eax
je     1413 <list+0x283>
cltq
movb   $0x0,(%r15,%rax,1)
mov    $0x1,%edx
mov    %ebx,%edi
lea    0xe(%rsp),%rsi
xor    %eax,%eax
call   1060 <read@plt>
cmp    $0xffffffff,%eax
je     1413 <list+0x283>
movsbl 0xe(%rsp),%ecx
mov    %r13,%rdi
lea    0xc82(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    0x2c12(%rip),%rax
mov    (%rax),%r12d
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %r12d,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
movslq %eax,%rbp
mov    %r13,%rdi
call   1050 <strlen@plt>
cmp    %rbp,%rax
jg     143b <list+0x2ab>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    1324 <list+0x194>
lea    0xbe6(%rip),%rdi
call   1090 <perror@plt>
mov    0x2bb2(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    0x2b9c(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
lea    0xbeb(%rip),%rdi
jmp    141a <list+0x28a>
lea    0xbf2(%rip),%rdi
jmp    141a <list+0x28a>

LLVM IR (-O0):
@.str = [11 x i8] c"Error read\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.1 = [4 x i8] c"REG\00"
@.str.2 = [30 x i8] c"The size of the file is %lld\0A\00"
@STDOUT_FILENO = global i32 0
@.str.3 = [12 x i8] c"Error write\00"
@.str.4 = [4 x i8] c"DIR\00"
@.str.5 = [18 x i8] c"Error malloc list\00"
@.str.6 = [28 x i8] c"The file %s has size: %llu\0A\00"
@.str.7 = [43 x i8] c"The file is not a regular file/directory!\0A\00"
@.str.8 = [17 x i8] c"File not found!\0A\00"
define void @list(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
%5 = alloca i64
%6 = alloca [1033 x i8]
%7 = alloca [4 x i8]
%8 = alloca i8
%9 = alloca i8*
%10 = alloca i32
store i32 %0, i32* %2
store i8 35, i8* %8
store i32 0, i32* %10
%11 = load i32, i32* %2
%12 = call i32 (i32, ...) @read(i32 %11, i32* %10, i64 4)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %19
15: ; preds = %1
%16 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %1
%20 = load i32, i32* %10
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %207
22: ; preds = %19
%23 = load i32, i32* %2
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%25 = call i32 (i32, ...) @read(i32 %23, i8* %24, i32 3)
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %22
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i32, i32* @EXIT_SUCCESS
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %32
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 %40
store i8 0, i8* %41
%42 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %80
45: ; preds = %38
%46 = load i32, i32* %2
%47 = call i32 (i32, ...) @read(i32 %46, i8* %3, i64 1)
store i32 %47, i32* %4
%48 = load i32, i32* %4
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %54
50: ; preds = %45
%51 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %45
%55 = load i32, i32* %4
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load i32, i32* @EXIT_SUCCESS
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %54
%61 = getelementptr inbounds [1033 x i8], [1033 x i8]* %6, i64 0, i64 0
%62 = load i8, i8* %3
%63 = sext i8 %62 to i32
%64 = call i32 (i8*, i8*, ...) @sprintf(i8* %61, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %63)
%65 = load i32, i32* @STDOUT_FILENO
%66 = getelementptr inbounds [1033 x i8], [1033 x i8]* %6, i64 0, i64 0
%67 = getelementptr inbounds [1033 x i8], [1033 x i8]* %6, i64 0, i64 0
%68 = call i64 @strlen(i8* %67)
%69 = trunc i64 %68 to i32
%70 = call i32 @write(i32 %65, i8* %66, i32 %69)
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [1033 x i8], [1033 x i8]* %6, i64 0, i64 0
%73 = call i64 @strlen(i8* %72)
%74 = icmp slt i64 %71, %73
br i1 %74, label %75, label %79
75: ; preds = %60
%76 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%77 = load i32, i32* @EXIT_FAILURE
%78 = call i32 @exit(i32 %77)
unreachable
79: ; preds = %60
br label %206
80: ; preds = %38
%81 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%82 = call i64 @strcmp(i8* %81, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %196
84: ; preds = %80
br label %85
85: ; preds = %194, %186, %84
%86 = load i32, i32* %2
%87 = call i32 (i32, ...) @read(i32 %86, i8* %8, i64 1)
store i32 %87, i32* %4
%88 = load i32, i32* %4
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %94
90: ; preds = %85
%91 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%92 = load i32, i32* @EXIT_FAILURE
%93 = call i32 @exit(i32 %92)
unreachable
94: ; preds = %85
%95 = load i32, i32* %4
%96 = icmp eq i32 %95, 0
br i1 %96, label %97, label %100
97: ; preds = %94
%98 = load i32, i32* @EXIT_SUCCESS
%99 = call i32 @exit(i32 %98)
unreachable
100: ; preds = %94
%101 = load i8, i8* %8
%102 = sext i8 %101 to i32
%103 = icmp eq i32 %102, 102
br i1 %103, label %104, label %182
104: ; preds = %100
%105 = load i32, i32* %4
%106 = icmp eq i32 %105, -1
br i1 %106, label %107, label %111
107: ; preds = %104
%108 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%109 = load i32, i32* @EXIT_FAILURE
%110 = call i32 @exit(i32 %109)
unreachable
111: ; preds = %104
%112 = call i64 @malloc(i32 1025)
%113 = inttoptr i64 %112 to i8*
store i8* %113, i8** %9
%114 = load i8*, i8** %9
%115 = icmp eq i8* %114, null
br i1 %115, label %116, label %120
116: ; preds = %111
%117 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%118 = load i32, i32* @EXIT_FAILURE
%119 = call i32 @exit(i32 %118)
unreachable
120: ; preds = %111
%121 = load i32, i32* %2
%122 = call i32 (i32, ...) @read(i32 %121, i64* %5, i64 8)
store i32 %122, i32* %4
%123 = load i32, i32* %4
%124 = icmp eq i32 %123, -1
br i1 %124, label %125, label %129
125: ; preds = %120
%126 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%127 = load i32, i32* @EXIT_FAILURE
%128 = call i32 @exit(i32 %127)
unreachable
129: ; preds = %120
%130 = load i32, i32* %4
%131 = icmp eq i32 %130, 0
br i1 %131, label %132, label %135
132: ; preds = %129
%133 = load i32, i32* @EXIT_SUCCESS
%134 = call i32 @exit(i32 %133)
unreachable
135: ; preds = %129
%136 = load i32, i32* %2
%137 = load i8*, i8** %9
%138 = load i64, i64* %5
%139 = call i32 (i32, ...) @read(i32 %136, i8* %137, i64 %138)
store i32 %139, i32* %4
%140 = load i32, i32* %4
%141 = icmp eq i32 %140, -1
br i1 %141, label %142, label %146
142: ; preds = %135
%143 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%144 = load i32, i32* @EXIT_FAILURE
%145 = call i32 @exit(i32 %144)
unreachable
146: ; preds = %135
%147 = load i8*, i8** %9
%148 = load i32, i32* %4
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds i8, i8* %147, i64 %149
store i8 0, i8* %150
%151 = load i32, i32* %2
%152 = call i32 (i32, ...) @read(i32 %151, i8* %3, i64 1)
store i32 %152, i32* %4
%153 = load i32, i32* %4
%154 = icmp eq i32 %153, -1
br i1 %154, label %155, label %159
155: ; preds = %146
%156 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%157 = load i32, i32* @EXIT_FAILURE
%158 = call i32 @exit(i32 %157)
unreachable
159: ; preds = %146
%160 = getelementptr inbounds [1033 x i8], [1033 x i8]* %6, i64 0, i64 0
%161 = load i8*, i8** %9
%162 = load i8, i8* %3
%163 = sext i8 %162 to i32
%164 = call i32 (i8*, i8*, ...) @sprintf(i8* %160, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %161, i32 %163)
%165 = load i32, i32* @STDOUT_FILENO
%166 = getelementptr inbounds [1033 x i8], [1033 x i8]* %6, i64 0, i64 0
%167 = getelementptr inbounds [1033 x i8], [1033 x i8]* %6, i64 0, i64 0
%168 = call i64 @strlen(i8* %167)
%169 = trunc i64 %168 to i32
%170 = call i32 @write(i32 %165, i8* %166, i32 %169)
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds [1033 x i8], [1033 x i8]* %6, i64 0, i64 0
%173 = call i64 @strlen(i8* %172)
%174 = icmp slt i64 %171, %173
br i1 %174, label %175, label %179
175: ; preds = %159
%176 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%177 = load i32, i32* @EXIT_FAILURE
%178 = call i32 @exit(i32 %177)
unreachable
179: ; preds = %159
%180 = load i8*, i8** %9
%181 = call i32 @free(i8* %180)
br label %194
182: ; preds = %100
%183 = load i8, i8* %8
%184 = sext i8 %183 to i32
%185 = icmp eq i32 %184, 100
br i1 %185, label %186, label %187
186: ; preds = %182
br label %85
187: ; preds = %182
%188 = load i8, i8* %8
%189 = sext i8 %188 to i32
%190 = icmp eq i32 %189, 101
br i1 %190, label %191, label %192
191: ; preds = %187
br label %195
192: ; preds = %187
br label %193
193: ; preds = %192
br label %194
194: ; preds = %193, %179
br label %85
195: ; preds = %191
br label %205
196: ; preds = %80
%197 = load i32, i32* @STDOUT_FILENO
%198 = call i32 @write(i32 %197, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i32 42)
%199 = icmp slt i32 %198, 42
br i1 %199, label %200, label %204
200: ; preds = %196
%201 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%202 = load i32, i32* @EXIT_SUCCESS
%203 = call i32 @exit(i32 %202)
unreachable
204: ; preds = %196
br label %205
205: ; preds = %204, %195
br label %206
206: ; preds = %205, %79
br label %216
207: ; preds = %19
%208 = load i32, i32* @STDOUT_FILENO
%209 = call i32 @write(i32 %208, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 16)
%210 = icmp slt i32 %209, 16
br i1 %210, label %211, label %215
211: ; preds = %207
%212 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%213 = load i32, i32* @EXIT_FAILURE
%214 = call i32 @exit(i32 %213)
unreachable
215: ; preds = %207
br label %216
216: ; preds = %215, %206
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"Error read\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.1 = [4 x i8] c"REG\00"
@.str.2 = [30 x i8] c"The size of the file is %lld\0A\00"
@STDOUT_FILENO = global i32 0
@.str.3 = [12 x i8] c"Error write\00"
@.str.4 = [4 x i8] c"DIR\00"
@.str.5 = [18 x i8] c"Error malloc list\00"
@.str.6 = [28 x i8] c"The file %s has size: %llu\0A\00"
@.str.7 = [43 x i8] c"The file is not a regular file/directory!\0A\00"
@.str.8 = [17 x i8] c"File not found!\0A\00"
define void @list(i32 %0) {
%2 = alloca i8
%3 = alloca i64
%4 = alloca [1033 x i8]
%5 = alloca [4 x i8]
%6 = alloca i8
%7 = alloca i32
%8 = bitcast i64* %3 to i8*
%9 = getelementptr inbounds [1033 x i8], [1033 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
store i8 35, i8* %6
%11 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%12 = call i32 (i32, ...) @read(i32 %0, i32* %7, i64 4)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %18
14: ; preds = %1
%15 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %1
%19 = load i32, i32* %7
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %133
21: ; preds = %18
%22 = call i32 (i32, ...) @read(i32 %0, i8* %10, i32 3)
switch i32 %22, label %30 [
i32 -1, label %23
i32 0, label %27
]
23: ; preds = %21
%24 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %21
%28 = load i32, i32* @EXIT_SUCCESS
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %21
%31 = sext i32 %22 to i64
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 %31
store i8 0, i8* %32
%33 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %59
35: ; preds = %30
%36 = call i32 (i32, ...) @read(i32 %0, i8* %2, i64 1)
switch i32 %36, label %44 [
i32 -1, label %37
i32 0, label %41
]
37: ; preds = %35
%38 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %35
%42 = load i32, i32* @EXIT_SUCCESS
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %35
%45 = load i8, i8* %2
%46 = sext i8 %45 to i32
%47 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %46)
%48 = load i32, i32* @STDOUT_FILENO
%49 = call i64 @strlen(i8* %9)
%50 = trunc i64 %49 to i32
%51 = call i32 @write(i32 %48, i8* %9, i32 %50)
%52 = sext i32 %51 to i64
%53 = call i64 @strlen(i8* %9)
%54 = icmp sgt i64 %53, %52
br i1 %54, label %55, label %141
55: ; preds = %44
%56 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%57 = load i32, i32* @EXIT_FAILURE
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %30
%60 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %125
62: ; preds = %59, %124
%63 = call i32 (i32, ...) @read(i32 %0, i8* %6, i64 1)
switch i32 %63, label %71 [
i32 -1, label %64
i32 0, label %68
]
64: ; preds = %62
%65 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%66 = load i32, i32* @EXIT_FAILURE
%67 = call i32 @exit(i32 %66)
unreachable
68: ; preds = %62
%69 = load i32, i32* @EXIT_SUCCESS
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %62
%72 = load i8, i8* %6
switch i8 %72, label %124 [
i8 102, label %73
i8 101, label %141
]
73: ; preds = %71
%74 = call i64 @malloc(i32 1025)
%75 = inttoptr i64 %74 to i8*
%76 = icmp eq i64 %74, 0
br i1 %76, label %77, label %81
77: ; preds = %73
%78 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%79 = load i32, i32* @EXIT_FAILURE
%80 = call i32 @exit(i32 %79)
unreachable
81: ; preds = %73
%82 = call i32 (i32, ...) @read(i32 %0, i64* %3, i64 8)
switch i32 %82, label %90 [
i32 -1, label %83
i32 0, label %87
]
83: ; preds = %81
%84 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%85 = load i32, i32* @EXIT_FAILURE
%86 = call i32 @exit(i32 %85)
unreachable
87: ; preds = %81
%88 = load i32, i32* @EXIT_SUCCESS
%89 = call i32 @exit(i32 %88)
unreachable
90: ; preds = %81
%91 = load i64, i64* %3
%92 = call i32 (i32, ...) @read(i32 %0, i8* %75, i64 %91)
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %98
94: ; preds = %90
%95 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%96 = load i32, i32* @EXIT_FAILURE
%97 = call i32 @exit(i32 %96)
unreachable
98: ; preds = %90
%99 = sext i32 %92 to i64
%100 = getelementptr inbounds i8, i8* %75, i64 %99
store i8 0, i8* %100
%101 = call i32 (i32, ...) @read(i32 %0, i8* %2, i64 1)
%102 = icmp eq i32 %101, -1
br i1 %102, label %103, label %107
103: ; preds = %98
%104 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%105 = load i32, i32* @EXIT_FAILURE
%106 = call i32 @exit(i32 %105)
unreachable
107: ; preds = %98
%108 = load i8, i8* %2
%109 = sext i8 %108 to i32
%110 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %75, i32 %109)
%111 = load i32, i32* @STDOUT_FILENO
%112 = call i64 @strlen(i8* %9)
%113 = trunc i64 %112 to i32
%114 = call i32 @write(i32 %111, i8* %9, i32 %113)
%115 = sext i32 %114 to i64
%116 = call i64 @strlen(i8* %9)
%117 = icmp sgt i64 %116, %115
br i1 %117, label %118, label %122
118: ; preds = %107
%119 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%120 = load i32, i32* @EXIT_FAILURE
%121 = call i32 @exit(i32 %120)
unreachable
122: ; preds = %107
%123 = call i32 @free(i8* %75)
br label %124
124: ; preds = %122, %71
br label %62
125: ; preds = %59
%126 = load i32, i32* @STDOUT_FILENO
%127 = call i32 @write(i32 %126, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i32 42)
%128 = icmp slt i32 %127, 42
br i1 %128, label %129, label %141
129: ; preds = %125
%130 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%131 = load i32, i32* @EXIT_SUCCESS
%132 = call i32 @exit(i32 %131)
unreachable
133: ; preds = %18
%134 = load i32, i32* @STDOUT_FILENO
%135 = call i32 @write(i32 %134, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 16)
%136 = icmp slt i32 %135, 16
br i1 %136, label %137, label %141
137: ; preds = %133
%138 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%139 = load i32, i32* @EXIT_FAILURE
%140 = call i32 @exit(i32 %139)
unreachable
141: ; preds = %71, %133, %44, %125
ret void
}