#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*/ wchar_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
scalar_t__ realloc(int /*<<< orphan*/ **, int);
int wcslen(int /*<<< orphan*/ *);
int /*<<< orphan*/ wcsncpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int get_text_file_info(char *file_path, wchar_t ***texts_or_querys) {
  FILE *fp;
  wchar_t buffer[500];
  int line_counter, line_length;
  fp = fopen(file_path, "r");
  if (fp == NULL) {
    printf("Arquivo nao encontrado\n");
    return 0;
  }
  line_counter = 0;
  *texts_or_querys = (wchar_t **)malloc(0);
  while (fscanf(fp, "%l[^\n]\n", buffer) == 1) {
    line_counter++;
    *texts_or_querys =
        (wchar_t **)realloc(*texts_or_querys, sizeof(wchar_t *) * line_counter);
    line_length = wcslen(buffer);
    (*texts_or_querys)[line_counter - 1] =
        (wchar_t *)malloc(sizeof(wchar_t) * (line_length + 1));
    wcsncpy((*texts_or_querys)[line_counter - 1], buffer, line_length + 1);
  }
  line_counter++;
  *texts_or_querys =
      (wchar_t **)realloc(*texts_or_querys, sizeof(wchar_t **) * line_counter);
  (*texts_or_querys)[line_counter - 1] = NULL;
  fclose(fp);
  return line_counter;
}


x86 assembly (clang, -O0):
<get_text_file_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ca <get_text_file_info+0x4a>
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1309 <get_text_file_info+0x189>
movl   $0x0,-0x7f4(%rbp)
xor    %edi,%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
lea    -0x7f0(%rbp),%rdx
lea    0xe23(%rip),%rsi
call   1060 <fscanf@plt>
cmp    $0x1,%eax
jne    12aa <get_text_file_info+0x12a>
mov    -0x7f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7f4(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
movslq -0x7f4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1090 <realloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x7f0(%rbp),%rdi
call   1050 <wcslen@plt>
mov    %eax,-0x7f8(%rbp)
mov    -0x7f8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x7f4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x7f4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x7f0(%rbp),%rsi
mov    -0x7f8(%rbp),%edx
add    $0x1,%edx
call   1070 <wcsncpy@plt>
jmp    11e5 <get_text_file_info+0x65>
mov    -0x7f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7f4(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
movslq -0x7f4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1090 <realloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x7f4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x7f4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_text_file_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7e8,%rsp
mov    %rsi,%r15
lea    0xe65(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1277 <get_text_file_info+0xf7>
mov    %rax,%r14
xor    %r12d,%r12d
xor    %edi,%edi
call   1080 <malloc@plt>
mov    %rax,(%r15)
lea    0xe42(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %r14,%rdi
call   1060 <fscanf@plt>
cmp    $0x1,%eax
jne    124a <get_text_file_info+0xca>
mov    $0x8,%ebp
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
lea    0x1(%r12),%rax
mov    %rax,0x8(%rsp)
mov    (%r15),%rdi
mov    %ebp,%esi
call   1090 <realloc@plt>
mov    %rax,(%r15)
lea    0x10(%rsp),%r13
mov    %r13,%rdi
call   1050 <wcslen@plt>
lea    0x1(%rax),%ebx
lea    0x4(,%rax,4),%edi
call   1080 <malloc@plt>
mov    (%r15),%rcx
mov    %rax,(%rcx,%r12,8)
mov    (%r15),%rax
mov    (%rax,%r12,8),%rdi
mov    0x8(%rsp),%r12
mov    %r13,%rsi
mov    %ebx,%edx
call   1070 <wcsncpy@plt>
mov    %r14,%rdi
lea    0xdc8(%rip),%rsi
mov    %r13,%rdx
call   1060 <fscanf@plt>
add    $0x8,%ebp
cmp    $0x1,%eax
je     11e0 <get_text_file_info+0x60>
lea    0x1(%r12),%ebp
mov    (%r15),%rdi
lea    0x8(,%r12,8),%esi
call   1090 <realloc@plt>
mov    %rax,(%r15)
mov    %r12d,%ecx
movq   $0x0,(%rax,%rcx,8)
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    1285 <get_text_file_info+0x105>
lea    0xd8c(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x7e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [24 x i8] c"Arquivo nao encontrado\0A\00"
@.str.2 = [8 x i8] c"%l[^\0A]\0A\00"
define i32 @get_text_file_info(i8* %0, i32*** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32***
%6 = alloca i32*
%7 = alloca [500 x i32]
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32*** %1, i32**** %5
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %84
16: ; preds = %2
store i32 0, i32* %8
%17 = call i64 @malloc(i32 0)
%18 = inttoptr i64 %17 to i32**
%19 = load i32***, i32**** %5
store i32** %18, i32*** %19
br label %20
20: ; preds = %25, %16
%21 = load i32*, i32** %6
%22 = getelementptr inbounds [500 x i32], [500 x i32]* %7, i64 0, i64 0
%23 = call i32 @fscanf(i32* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* %22)
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %63
25: ; preds = %20
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
%28 = load i32***, i32**** %5
%29 = load i32**, i32*** %28
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = mul i64 8, %31
%33 = trunc i64 %32 to i32
%34 = call i64 @realloc(i32** %29, i32 %33)
%35 = inttoptr i64 %34 to i32**
%36 = load i32***, i32**** %5
store i32** %35, i32*** %36
%37 = getelementptr inbounds [500 x i32], [500 x i32]* %7, i64 0, i64 0
%38 = call i32 @wcslen(i32* %37)
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = mul i64 4, %41
%43 = trunc i64 %42 to i32
%44 = call i64 @malloc(i32 %43)
%45 = inttoptr i64 %44 to i32*
%46 = load i32***, i32**** %5
%47 = load i32**, i32*** %46
%48 = load i32, i32* %8
%49 = sub nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32*, i32** %47, i64 %50
store i32* %45, i32** %51
%52 = load i32***, i32**** %5
%53 = load i32**, i32*** %52
%54 = load i32, i32* %8
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32*, i32** %53, i64 %56
%58 = load i32*, i32** %57
%59 = getelementptr inbounds [500 x i32], [500 x i32]* %7, i64 0, i64 0
%60 = load i32, i32* %9
%61 = add nsw i32 %60, 1
%62 = call i32 @wcsncpy(i32* %58, i32* %59, i32 %61)
br label %20
63: ; preds = %20
%64 = load i32, i32* %8
%65 = add nsw i32 %64, 1
store i32 %65, i32* %8
%66 = load i32***, i32**** %5
%67 = load i32**, i32*** %66
%68 = load i32, i32* %8
%69 = sext i32 %68 to i64
%70 = mul i64 8, %69
%71 = trunc i64 %70 to i32
%72 = call i64 @realloc(i32** %67, i32 %71)
%73 = inttoptr i64 %72 to i32**
%74 = load i32***, i32**** %5
store i32** %73, i32*** %74
%75 = load i32***, i32**** %5
%76 = load i32**, i32*** %75
%77 = load i32, i32* %8
%78 = sub nsw i32 %77, 1
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i32*, i32** %76, i64 %79
store i32* null, i32** %80
%81 = load i32*, i32** %6
%82 = call i32 @fclose(i32* %81)
%83 = load i32, i32* %8
store i32 %83, i32* %3
br label %84
84: ; preds = %63, %14
%85 = load i32, i32* %3
ret i32 %85
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"%l[^\0A]\0A\00"
@str = [23 x i8] c"Arquivo nao encontrado\00"
define i32 @get_text_file_info(i8* nocapture %0, i32*** nocapture %1) {
%3 = alloca [500 x i32]
%4 = bitcast [500 x i32]* %3 to i8*
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %48
9: ; preds = %2
%10 = tail call i64 @malloc(i32 0)
%11 = inttoptr i64 %10 to i32**
store i32** %11, i32*** %1
%12 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 0
%13 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* %12)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %38
15: ; preds = %9, %15
%16 = phi i64 [ %17, %15 ], [ 0, %9 ]
%17 = add nuw i64 %16, 1
%18 = load i32**, i32*** %1
%19 = trunc i64 %17 to i32
%20 = shl i32 %19, 3
%21 = call i64 @realloc(i32** %18, i32 %20)
%22 = inttoptr i64 %21 to i32**
store i32** %22, i32*** %1
%23 = call i32 @wcslen(i32* %12)
%24 = add nsw i32 %23, 1
%25 = shl i32 %24, 2
%26 = call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to i32*
%28 = load i32**, i32*** %1
%29 = getelementptr inbounds i32*, i32** %28, i64 %16
store i32* %27, i32** %29
%30 = load i32**, i32*** %1
%31 = getelementptr inbounds i32*, i32** %30, i64 %16
%32 = load i32*, i32** %31
%33 = call i32 @wcsncpy(i32* %32, i32* %12, i32 %24)
%34 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* %12)
%35 = icmp eq i32 %34, 1
br i1 %35, label %15, label %36
36: ; preds = %15
%37 = trunc i64 %17 to i32
br label %38
38: ; preds = %36, %9
%39 = phi i32 [ 0, %9 ], [ %37, %36 ]
%40 = add nuw nsw i32 %39, 1
%41 = load i32**, i32*** %1
%42 = shl i32 %40, 3
%43 = call i64 @realloc(i32** %41, i32 %42)
%44 = inttoptr i64 %43 to i32**
store i32** %44, i32*** %1
%45 = zext i32 %39 to i64
%46 = getelementptr inbounds i32*, i32** %44, i64 %45
store i32* null, i32** %46
%47 = call i32 @fclose(i32* %5)
br label %48
48: ; preds = %38, %7
%49 = phi i32 [ 0, %7 ], [ %40, %38 ]
ret i32 %49
}