// File: /workspace/github_c_makefile_star2_O2/morozov312[P]documentary/./src/processing.c
// Function: Create_document
int Create_document(char* path, char* dest_dir)
{
    /** if founded begin of multiline documentary comment -> start flag == true
     */
    int qty_structs = 0, start_flag = 0;
    int valid_Check = Check_extension(path);
    if (!valid_Check) {
        printf("%s%s\n", "Unsupported file format on - ", path);
        return 0;
    }
    char** document_data = Get_data_from_document(path);
    int count_of_lines = 0;
    /// if file cannot be read
    if (document_data == NULL) {
        return 0;
    }
    for (int i = 0; i < MAX_QTY_STR; i++) {
        if (strlen(document_data[i]) != 0) {
            document_data[i] = Escape_html(document_data[i]);
            count_of_lines++;
        }
    }
    /// this error appears if the document empty ot has 1 line
    if (count_of_lines <= 1) {
        printf("%s%s", "Error,file on path ", path);
        printf("%s\n", " too small for documentation");
        return 0;
    }
    /// calling function of the main algorithm
    comment* comments_array = Create_struct_of_data(
            count_of_lines, document_data, &qty_structs, &start_flag);
    /// if was a beginning of a documentary comment but there wasn't end
    if (start_flag) {
        printf("%s%s\n", "Syntax error in file - ", path);
        return 0;
    }
    if (qty_structs == 0) {
        printf("%s%s%s\n",
               "In file - ",
               path,
               " there are no documentary comments");
        return 0;
    }
    int creation_flag
            = Generate_html(comments_array, path, qty_structs, dest_dir);
    if (creation_flag) {
        printf("%s%s\n",
               "\x1b[32mSuccessfully created documentation on file - \x1b[0m",
               path);
    }
    //======================================
    for (int i = 0; i < MAX_QTY_STR; i++) {
        free(document_data[i]);
    }
    free(document_data);
    free(comments_array);
    //=======================================
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
andl $0x0, -0x2c(%rbp)
movq %rdi, %rbx
andl $0x0, -0x30(%rbp)
callq 0x42c4
testl %eax, %eax
je 0x4953
movq %rbx, %rdi
callq 0x3dc0
testq %rax, %rax
je 0x4998
movq %rax, %r14
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpq $0xc350, %r13           # imm = 0xC350
je 0x4927
movq (%r14,%r13,8), %rdi
cmpb $0x0, (%rdi)
je 0x4922
callq 0x3ba8
movq %rax, (%r14,%r13,8)
incl %r12d
incq %r13
jmp 0x4904
cmpl $0x2, %r12d
jge 0x4963
leaq 0x12a8(%rip), %rdi      # 0x5bdc
leaq 0x141e(%rip), %rsi      # 0x5d59
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2100
leaq 0x1421(%rip), %rdi      # 0x5d6d
callq 0x2080
jmp 0x4998
leaq 0x1114(%rip), %rdi      # 0x5a6e
leaq 0x13da(%rip), %rsi      # 0x5d3b
jmp 0x498e
leaq -0x2c(%rbp), %rdx
leaq -0x30(%rbp), %r13
movl %r12d, %edi
movq %r14, %rsi
movq %r13, %rcx
callq 0x46ce
cmpl $0x0, (%r13)
je 0x49a9
leaq 0x10e7(%rip), %rdi      # 0x5a6e
leaq 0x13fc(%rip), %rsi      # 0x5d8a
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2100
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl -0x2c(%rbp), %edx
testl %edx, %edx
je 0x4a08
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x44b0
testl %eax, %eax
je 0x49dd
leaq 0x10a2(%rip), %rdi      # 0x5a6e
leaq 0x13fd(%rip), %rsi      # 0x5dd0
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2100
xorl %ebx, %ebx
cmpq $0xc350, %rbx           # imm = 0xC350
je 0x49f6
movq (%r14,%rbx,8), %rdi
callq 0x2030
incq %rbx
jmp 0x49df
movq %r14, %rdi
callq 0x2030
movq %r12, %rdi
callq 0x2030
jmp 0x4998
leaq 0x105d(%rip), %rdi      # 0x5a6c
leaq 0x138c(%rip), %rsi      # 0x5da2
leaq 0x1390(%rip), %rcx      # 0x5dad
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2100
jmp 0x4998