// File: /workspace/github_c_makefile_star2_O1/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
movq %rdi, %rbx
xorl %eax, %eax
movl %eax, -0x2c(%rbp)
movl %eax, -0x30(%rbp)
callq 0x43e0
testl %eax, %eax
je 0x4a8f
movq %rbx, %rdi
callq 0x3ea1
testq %rax, %rax
je 0x4ad4
movq %rax, %r14
xorl %r13d, %r13d
xorl %r12d, %r12d
movq (%r14,%r13,8), %rdi
cmpb $0x0, (%rdi)
je 0x4a57
callq 0x3c70
movq %rax, (%r14,%r13,8)
incl %r12d
incq %r13
cmpq $0xc350, %r13           # imm = 0xC350
jne 0x4a42
cmpl $0x2, %r12d
jge 0x4a9f
leaq 0x116c(%rip), %rdi      # 0x5bdc
leaq 0x12e2(%rip), %rsi      # 0x5d59
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2100
leaq 0x12e5(%rip), %rdi      # 0x5d6d
callq 0x2080
jmp 0x4ad4
leaq 0xfd9(%rip), %rdi       # 0x5a6f
leaq 0x129e(%rip), %rsi      # 0x5d3b
jmp 0x4aca
leaq -0x2c(%rbp), %rdx
leaq -0x30(%rbp), %r13
movl %r12d, %edi
movq %r14, %rsi
movq %r13, %rcx
callq 0x481c
cmpl $0x0, (%r13)
je 0x4ae5
leaq 0xfac(%rip), %rdi       # 0x5a6f
leaq 0x12c0(%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 0x4b42
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x4608
testl %eax, %eax
je 0x4b19
leaq 0xf67(%rip), %rdi       # 0x5a6f
leaq 0x12c1(%rip), %rsi      # 0x5dd0
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2100
xorl %ebx, %ebx
movq (%r14,%rbx,8), %rdi
callq 0x2030
incq %rbx
cmpq $0xc350, %rbx           # imm = 0xC350
jne 0x4b1b
movq %r14, %rdi
callq 0x2030
movq %r12, %rdi
callq 0x2030
jmp 0x4ad4
leaq 0xf24(%rip), %rdi       # 0x5a6d
leaq 0x1252(%rip), %rsi      # 0x5da2
leaq 0x1256(%rip), %rcx      # 0x5dad
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2100
jmp 0x4ad4