#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 */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *const, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *const);
int /*<<< orphan*/ fread(void *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char **);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
void *malloc(long);
int /*<<< orphan*/ stderr;
char **read_text_files(const char *const *paths, unsigned paths_sz) {
  char **file_datas = malloc(sizeof(char *) * paths_sz);
  FILE *file = NULL;
  long int file_size = 0;
  if (paths == NULL || paths_sz == 0) {
    free(file_datas);
    return NULL;
  }
  for (int i = 0; i < paths_sz; ++i) {
    file = fopen(paths[i], "rb");
    if (file == NULL) {
      fprintf(stderr, "Cannot read %s: No such file or directory\n", paths[i]);
      if (file_datas != NULL) {
        free(file_datas);
        file_datas = NULL;
      }
      continue;
    }
    if (file_datas == NULL) {
      fclose(file);
      continue;
    }
    fseek(file, 0, SEEK_END);
    file_size = ftell(file);
    fseek(file, 0, SEEK_SET);
    file_datas[i] = malloc((file_size + 1) * sizeof(char));
    file_datas[i][file_size] = 0;
    fread((void *)file_datas[i], 1, file_size, file);
    fclose(file);
  }
  return file_datas;
}


x86 assembly (clang, -O0):
<read_text_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%edi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11c6 <read_text_files+0x46>
cmpl   $0x0,-0x14(%rbp)
jne    11dc <read_text_files+0x5c>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1317 <read_text_files+0x197>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    130f <read_text_files+0x18f>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdfe(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1258 <read_text_files+0xd8>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdd1(%rip),%rsi
call   1060 <fprintf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1253 <read_text_files+0xd3>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
jmp    1301 <read_text_files+0x181>
cmpq   $0x0,-0x20(%rbp)
jne    1271 <read_text_files+0xf1>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
jmp    1301 <read_text_files+0x181>
mov    -0x28(%rbp),%rdi
mov    0x2d6c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x28(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2d33(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
shl    $0x0,%rdi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11e3 <read_text_files+0x63>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_text_files>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%rbp
mov    %esi,%r14d
lea    0x0(,%r14,8),%rdi
call   1080 <malloc@plt>
mov    %rax,%r13
test   %rbp,%rbp
je     12a1 <read_text_files+0x121>
test   %ebx,%ebx
je     12a1 <read_text_files+0x121>
xor    %r15d,%r15d
lea    0xe42(%rip),%r12
mov    %rbp,(%rsp)
jmp    123d <read_text_files+0xbd>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x2e11(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %rax,%rbp
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
lea    0x1(%rbp),%rdi
call   1080 <malloc@plt>
mov    %rax,0x0(%r13,%r15,8)
movb   $0x0,(%rax,%rbp,1)
mov    0x0(%r13,%r15,8),%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    (%rsp),%rbp
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
add    $0x1,%r15
cmp    %r15,%r14
je     12ac <read_text_files+0x12c>
mov    0x0(%rbp,%r15,8),%rdi
mov    %r12,%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1270 <read_text_files+0xf0>
mov    %rax,%rbx
test   %r13,%r13
jne    11d0 <read_text_files+0x50>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %r13d,%r13d
jmp    1234 <read_text_files+0xb4>
nopl   0x0(%rax,%rax,1)
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp,%r15,8),%rdx
lea    0xd7e(%rip),%rsi
call   1060 <fprintf@plt>
test   %r13,%r13
jne    1294 <read_text_files+0x114>
xor    %r13d,%r13d
jmp    1234 <read_text_files+0xb4>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %r13d,%r13d
jmp    1234 <read_text_files+0xb4>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %r13d,%r13d
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"Cannot read %s: No such file or directory\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i8** @read_text_files(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
%10 = load i32, i32* %5
%11 = zext i32 %10 to i64
%12 = mul i64 8, %11
%13 = call i8* @malloc(i64 %12)
%14 = bitcast i8* %13 to i8**
store i8** %14, i8*** %6
store i32* null, i32** %7
store i64 0, i64* %8
%15 = load i8**, i8*** %4
%16 = icmp eq i8** %15, null
br i1 %16, label %20, label %17
17: ; preds = %2
%18 = load i32, i32* %5
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17, %2
%21 = load i8**, i8*** %6
%22 = call i32 @free(i8** %21)
store i8** null, i8*** %3
br label %96
23: ; preds = %17
store i32 0, i32* %9
br label %24
24: ; preds = %91, %23
%25 = load i32, i32* %9
%26 = load i32, i32* %5
%27 = icmp ult i32 %25, %26
br i1 %27, label %28, label %94
28: ; preds = %24
%29 = load i8**, i8*** %4
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %34, i32** %7
%35 = load i32*, i32** %7
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %51
37: ; preds = %28
%38 = load i32, i32* @stderr
%39 = load i8**, i8*** %4
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %43)
%45 = load i8**, i8*** %6
%46 = icmp ne i8** %45, null
br i1 %46, label %47, label %50
47: ; preds = %37
%48 = load i8**, i8*** %6
%49 = call i32 @free(i8** %48)
store i8** null, i8*** %6
br label %50
50: ; preds = %47, %37
br label %91
51: ; preds = %28
%52 = load i8**, i8*** %6
%53 = icmp eq i8** %52, null
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32*, i32** %7
%56 = call i32 @fclose(i32* %55)
br label %91
57: ; preds = %51
%58 = load i32*, i32** %7
%59 = load i32, i32* @SEEK_END
%60 = call i32 @fseek(i32* %58, i32 0, i32 %59)
%61 = load i32*, i32** %7
%62 = call i64 @ftell(i32* %61)
store i64 %62, i64* %8
%63 = load i32*, i32** %7
%64 = load i32, i32* @SEEK_SET
%65 = call i32 @fseek(i32* %63, i32 0, i32 %64)
%66 = load i64, i64* %8
%67 = add nsw i64 %66, 1
%68 = mul i64 %67, 1
%69 = call i8* @malloc(i64 %68)
%70 = load i8**, i8*** %6
%71 = load i32, i32* %9
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %70, i64 %72
store i8* %69, i8** %73
%74 = load i8**, i8*** %6
%75 = load i32, i32* %9
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %74, i64 %76
%78 = load i8*, i8** %77
%79 = load i64, i64* %8
%80 = getelementptr inbounds i8, i8* %78, i64 %79
store i8 0, i8* %80
%81 = load i8**, i8*** %6
%82 = load i32, i32* %9
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %81, i64 %83
%85 = load i8*, i8** %84
%86 = load i64, i64* %8
%87 = load i32*, i32** %7
%88 = call i32 @fread(i8* %85, i32 1, i64 %86, i32* %87)
%89 = load i32*, i32** %7
%90 = call i32 @fclose(i32* %89)
br label %91
91: ; preds = %57, %54, %50
%92 = load i32, i32* %9
%93 = add nsw i32 %92, 1
store i32 %93, i32* %9
br label %24
94: ; preds = %24
%95 = load i8**, i8*** %6
store i8** %95, i8*** %3
br label %96
96: ; preds = %94, %20
%97 = load i8**, i8*** %3
ret i8** %97
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"Cannot read %s: No such file or directory\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i8** @read_text_files(i8** %0, i32 %1) {
%3 = zext i32 %1 to i64
%4 = shl nuw nsw i64 %3, 3
%5 = tail call i8* @malloc(i64 %4)
%6 = bitcast i8* %5 to i8**
%7 = icmp eq i8** %0, null
%8 = icmp eq i32 %1, 0
%9 = or i1 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @free(i8** %6)
br label %47
12: ; preds = %2, %43
%13 = phi i64 [ %45, %43 ], [ 0, %2 ]
%14 = phi i8** [ %44, %43 ], [ %6, %2 ]
%15 = getelementptr inbounds i8*, i8** %0, i64 %13
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %26
19: ; preds = %12
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %15
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = icmp eq i8** %14, null
br i1 %23, label %43, label %24
24: ; preds = %19
%25 = tail call i32 @free(i8** %14)
br label %43
26: ; preds = %12
%27 = icmp eq i8** %14, null
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = tail call i32 @fclose(i32* %17)
br label %43
30: ; preds = %26
%31 = load i32, i32* @SEEK_END
%32 = tail call i32 @fseek(i32* %17, i32 0, i32 %31)
%33 = tail call i64 @ftell(i32* %17)
%34 = load i32, i32* @SEEK_SET
%35 = tail call i32 @fseek(i32* %17, i32 0, i32 %34)
%36 = add nsw i64 %33, 1
%37 = tail call i8* @malloc(i64 %36)
%38 = getelementptr inbounds i8*, i8** %14, i64 %13
store i8* %37, i8** %38
%39 = getelementptr inbounds i8, i8* %37, i64 %33
store i8 0, i8* %39
%40 = load i8*, i8** %38
%41 = tail call i32 @fread(i8* %40, i32 1, i64 %33, i32* %17)
%42 = tail call i32 @fclose(i32* %17)
br label %43
43: ; preds = %19, %24, %30, %28
%44 = phi i8** [ null, %24 ], [ null, %19 ], [ null, %28 ], [ %14, %30 ]
%45 = add nuw nsw i64 %13, 1
%46 = icmp eq i64 %45, %3
br i1 %46, label %47, label %12
47: ; preds = %43, %10
%48 = phi i8** [ null, %10 ], [ %44, %43 ]
ret i8** %48
}