// File: /workspace/github_cpp_makefile_star2_O1/Cristian-Castillo[P]Multithreaded-HTTP-Server/./httpserver_definitions.cpp
// Function: f_check_copy(char*, int)
void *f_check_copy(char *file_name, int clientSocket)
{
    /* 
       if a copy is not found in a directory then copyX_found = 0. 
       If file is found in the directory then copyX_found = 1  for X in (1,2,3)
    */
    int copy1_found, copy2_found, copy3_found;
    copy1_found = 0;
    copy2_found = 0;
    copy3_found = 0;

    /* Checking if the file requested by user exists in ./copy1 directory */
    DIR *dir;
    struct dirent *listD;
    dir = opendir("./copy1");
    
    if(dir == NULL){
        perror("Error: Unable to open current server directory copy1.\n)");
        copy1_found = 0;
    }
    else{
        while((listD = readdir(dir)) != NULL){
            if((strcmp(file_name, listD->d_name) == 0) && (listD->d_type == DT_REG)){
                copy1_found = 1;
            }
        }
    }
    dir = opendir("./copy2");
    
    if(dir == NULL){
        perror("Error: Unable to open current server directory copy2.\n)");
        copy2_found = 0;
    }
    else{
        while((listD = readdir(dir)) != NULL){

            if((strcmp(file_name, listD->d_name) == 0) && (listD->d_type == DT_REG)){
                copy2_found = 1;
            }
        }
    }
    dir = opendir("./copy3");
    
    if(dir == NULL){
        perror("Error: Unable to open current server directory copy3.\n)");
        copy3_found = 0;
    }
    else{
        while((listD = readdir(dir)) != NULL){
            if((strcmp(file_name, listD->d_name) == 0) && (listD->d_type == DT_REG)){
                copy3_found = 1;
            }
        }
    }
    closedir(dir);


    /* 
       If a file's permission is locking us out, then copyX_no_permission = 1. 
       But if we have the permission, copyX_no_permission = 0 
    */
    int copy1_no_permission, copy2_no_permission, copy3_no_permission;
    copy1_no_permission = 0;
    copy2_no_permission = 0;
    copy3_no_permission = 0;

    struct http_node *child;
    child = &spawnNode;

    /* Opening a file in directory ./copy1 */
    char path_with_name1[20]; 
    strcpy (path_with_name1,"copy1/");
    strcat (path_with_name1, file_name);

    int file_copy1 = open(path_with_name1, O_RDONLY,0664);
    if(copy1_found == 1){ /* Indicatese if file was found in directory */
    
    /* if this condition is met that means file in directory but no permission to open  //f_void_client_error_not_found(clientSocket);} */
        if(file_copy1 == -1) {copy1_no_permission = 1;}  
    }
    /* copy1_permission = f_int_permission_put(path_with_name1, clientSocket); */

    /* Opening a file in directory ./copy2 */
    char path_with_name2[20]; 

    strcpy (path_with_name2,"copy2/");

    strcat (path_with_name2, file_name);

    int file_copy2 = open(path_with_name2, O_RDONLY,0664);
    if(copy2_found == 1){
        if(file_copy2 == -1) {copy2_no_permission = 1;} /* {f_void_client_error_not_found(clientSocket);} */
    }
    /* copy2_permission = f_int_permission_put(path_with_name2, clientSocket); */

    /* Opening a file in directory ./copy3 */
    char path_with_name3[20]; 

    strcpy (path_with_name3,"copy3/");

    strcat (path_with_name3, file_name);

    int file_copy3 = open(path_with_name3, O_RDONLY,0664);
    if(copy3_found == 1){
        if(file_copy3 == -1){
            copy3_no_permission = 1; /* {f_void_client_error_not_found(clientSocket);} */
        } 
    }
    /* copy3_permission = f_int_permission_put(path_with_name3, clientSocket); */


    /* getting the content length of each file within each ./copyX directory for X in (1,2,3) */
    struct stat buf1;
    fstat(file_copy1,&buf1);
    int get_length1 = buf1.st_size;
    ////////////////////////////////////////////////////////////////////////////////////
    struct stat buf2;
    fstat(file_copy2,&buf2);
    int get_length2 = buf2.st_size;
    ////////////////////////////////////////////////////////////////////////////////////
    struct stat buf3;
    fstat(file_copy3,&buf3);
    int get_length3 = buf3.st_size;
    ////////////////////////////////////////////////////////////////////////////////////


    char *buff1 = (char*)malloc(get_length1*sizeof(char*));
    char *buff2 = (char*)malloc(get_length2*sizeof(char*));
    char *buff3 = (char*)malloc(get_length3*sizeof(char*));

    /* 
        If two files are found to be the same in regards to content length 
        and ascii character comparison, then copyXY = 1 
    */
    int copy12_same, copy13_same, copy23_same;
    copy12_same = copy13_same = copy23_same = 0;

    ssize_t check_bytes_recv1;
    ssize_t check_bytes_recv2;
    ssize_t check_bytes_recv3;

    /* Checking to see if the the file in ./copy1 is the same in ./copy2 in terms of ascii content and length */
    ssize_t write_bytes = 0;

    if((get_length1 == get_length2) && (file_copy1 != -1) && (file_copy2 !=-1)){
        lseek(file_copy1, 0*sizeof(char), SEEK_SET);
        lseek(file_copy2, 0*sizeof(char), SEEK_SET);
        while(((check_bytes_recv1 = read(file_copy1,buff1,get_length1)) >= 0) && ((check_bytes_recv2 = read(file_copy2,buff2,get_length2)) >= 0) ){
            write_bytes += check_bytes_recv1;
  
            sleep(2);
            /* comparing ascii values */
            if(strcmp(buff1,buff2) != 0){
                break;
            }
            if(write_bytes == get_length1){

                copy12_same = 1;
                break;
            }
        }
    }

     /* 
        Checking to see if the the file in ./copy1 is the same in
        ./copy3 in terms of ascii content and length 
    */
    memset(buff1, 0, get_length1);
    memset(buff2, 0, get_length2);
    
    if(copy12_same == 0 && (get_length1 == get_length3)  && (file_copy1 != -1) && (file_copy3 !=-1)){
        
            lseek(file_copy1, 0*sizeof(char), SEEK_SET);
            lseek(file_copy3, 0*sizeof(char), SEEK_SET);
            write_bytes = 0;
            
            while((check_bytes_recv1 = read(file_copy1,buff1,get_length1)) >= 0 && (check_bytes_recv3 = read(file_copy3,buff3,get_length3)) >= 0){
            write_bytes += check_bytes_recv1;
            
            if(strcmp(buff1,buff3) != 1){
                break;
            }
            if(write_bytes == get_length1){
    
                copy13_same = 1;
                break;
            }
        }
    }

    /* Checking to see if the the file in ./copy2 is the same in ./copy3 in terms of ascii content and length */
    memset(buff1, 0, get_length1);
    memset(buff3, 0, get_length3);
    
    if((copy12_same == 0) && (copy13_same == 0) && (get_length2 == get_length3)  && (file_copy2 != -1) && (file_copy3 !=-1)){
        
        lseek(file_copy2, 0*sizeof(char), SEEK_SET);
        lseek(file_copy3, 0*sizeof(char), SEEK_SET);
        write_bytes = 0;
        

        while((check_bytes_recv2 = read(file_copy2,buff2,get_length2)) >= 0 && (check_bytes_recv3 = read(file_copy3,buff3,get_length3)) >= 0){
            write_bytes += check_bytes_recv2;

            sleep(2);
            if(strcmp(buff2,buff3) != 0){
                break;
            }
            if(write_bytes == get_length2){
  
                copy23_same = 1;
                break;
            }
        }
    }
    memset(buff1, 0, get_length1);
    memset(buff3, 0, get_length3);

    lseek(file_copy1, 0*sizeof(char), SEEK_SET);
    lseek(file_copy2, 0*sizeof(char), SEEK_SET);
    
    free(buff1);
    free(buff2);
    free(buff3);

    close(file_copy3);

    /* 
       NOTE: the number of files that gives us no permission 
       to open is always less than or equal to the number of files that exist 
    */ 

    /* calculates the number of files that gives no permission for us to open in directorys ./copyX */
    int num_of_no_permission_files = copy1_no_permission + copy2_no_permission + copy3_no_permission;

    /* calculates the number of files that exists in the directory ./copyX */
    int num_of_files_that_exist = copy1_found + copy2_found + copy3_found;

    /* If all three files are not found or no permission, the status code should be 500 */
    if((num_of_files_that_exist == 0) || (num_of_no_permission_files == 3)){
       /* printf("500 internal error\n"); */
        close(file_copy1);
        close(file_copy2);
        f_void_intr_error(clientSocket);
    }

    /*  GET file with 2/3 or 3/3 files giving no permissions  */
    if(num_of_no_permission_files >=2 ){                
        /* printf("403 error per post @385 endosred by Daniel Alvs #2 & 3 ALSO @336 #1\n");*/
        close(file_copy1);
        close(file_copy2);
        f_void_client_error_forbid(clientSocket);
    }

    /*  GET file with 1/3 files giving no permissions, 1/3 files that don't exist, 1/3 files that do exist and we have permission */
    if((num_of_files_that_exist == 2) && (num_of_no_permission_files == 1)){                
        /* printf("500 error per post @385 endosred by Daniel Alvs #4 ALSO @336 #2\n"); */
        close(file_copy1);
        close(file_copy2);
        f_void_intr_error(clientSocket);
    }

    /*  GET with 2/3 files that don't exist, and file with 1/3 files giving no permissions   */
    if((num_of_files_that_exist == 1) && (num_of_no_permission_files == 1)){                
        /* printf("404 error per post @385 endosred by Daniel Alvs #5 ALSO @336 #3\n"); */
        close(file_copy1);
        close(file_copy2);
        f_void_client_error_not_found(clientSocket);
    }

    if(copy12_same == 1 || copy13_same == 1){

        /* sending HTTP 200 */
        f_client_req_found(file_copy1,clientSocket); 
        ssize_t send_bytes = 0;

        char *buffs = (char*)malloc(get_length1*sizeof(char*));

        /* Store file contents */
        while((child->content_length = read(file_copy1,buffs,sizeof(buffs))) != 0){

            /* printf("if you see then that means i am writing into the client socket\n"); */
            send_bytes +=  write(clientSocket,buffs,child->content_length);
            if(send_bytes == get_length1){break;}
        }
        close(file_copy1);
        close(file_copy2);
            
        if(child->content_length == 0){
            free(buffs);
            return NULL;
        }
        else{ 
            /* Internal error of 500 Content failuire*/
            f_void_intr_error(clientSocket);
            free(buffs);
            return NULL;   
        }

    }
    else if(copy23_same == 1){

        f_client_req_found(file_copy2,clientSocket);
        ssize_t send_bytes;

        char *buffs = (char*)malloc(get_length2*sizeof(char*));
        
        /* Store file contents */
        while((child->content_length = read(file_copy2,buffs,sizeof(buffs))) != 0){
            send_bytes =  write(clientSocket,buffs,child->content_length);
            if(send_bytes == get_length2){break;}
        }
        close(file_copy1);
        close(file_copy2);
            
        if(child->content_length == 0){
            free(buffs);
            return NULL;
        }
        else{ 
            /* Internal error of 500 Content failuire */
            f_void_intr_error(clientSocket);
            free(buffs);
            return NULL;
                
        }
    }
    else{
        close(file_copy1);
        close(file_copy2);
        f_void_intr_error(clientSocket);
        return NULL;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movl %esi, %r12d
movq %rdi, %rbx
leaq 0x101d1(%rip), %rdi     # 0x15724
callq 0x4550
testq %rax, %rax
je 0x55a3
movq %rax, %r14
movq %rax, %rdi
callq 0x4570
testq %rax, %rax
je 0x55af
movq %rax, %r15
xorl %r13d, %r13d
movl $0x1, %ebp
leaq 0x13(%r15), %rsi
movq %rbx, %rdi
callq 0x44d0
testl %eax, %eax
jne 0x5591
cmpb $0x8, 0x12(%r15)
cmovel %ebp, %r13d
movq %r14, %rdi
callq 0x4570
movq %rax, %r15
testq %rax, %rax
jne 0x5578
jmp 0x55b2
leaq 0x10182(%rip), %rdi     # 0x1572c
callq 0x42e0
xorl %r13d, %r13d
leaq 0x101ab(%rip), %rdi     # 0x15764
callq 0x4550
testq %rax, %rax
movl %r13d, 0x44(%rsp)
je 0x560e
movq %rax, %r14
movq %rax, %rdi
callq 0x4570
testq %rax, %rax
je 0x561a
movq %rax, %r15
xorl %r13d, %r13d
movl $0x1, %ebp
leaq 0x13(%r15), %rsi
movq %rbx, %rdi
callq 0x44d0
testl %eax, %eax
jne 0x55fc
cmpb $0x8, 0x12(%r15)
cmovel %ebp, %r13d
movq %r14, %rdi
callq 0x4570
movq %rax, %r15
testq %rax, %rax
jne 0x55e3
jmp 0x561d
leaq 0x10157(%rip), %rdi     # 0x1576c
callq 0x42e0
xorl %r13d, %r13d
leaq 0x10180(%rip), %rdi     # 0x157a4
callq 0x4550
movq %rax, %r14
testq %rax, %rax
je 0x5680
movq %r14, %rdi
callq 0x4570
testq %rax, %rax
je 0x568c
movq %rax, %r15
movl $0x0, 0x1c(%rsp)
movl $0x1, %ebp
leaq 0x13(%r15), %rsi
movq %rbx, %rdi
callq 0x44d0
testl %eax, %eax
jne 0x566e
cmpb $0x8, 0x12(%r15)
movl 0x1c(%rsp), %eax
cmovel %ebp, %eax
movl %eax, 0x1c(%rsp)
movq %r14, %rdi
callq 0x4570
movq %rax, %r15
testq %rax, %rax
jne 0x564e
jmp 0x5694
leaq 0x10125(%rip), %rdi     # 0x157ac
callq 0x42e0
movl $0x0, 0x1c(%rsp)
movl %r12d, 0x64(%rsp)
movq %r14, %rdi
callq 0x45a0
movl $0x79706f63, %r15d      # imm = 0x79706F63
leaq 0xd0(%rsp), %r14
movl %r15d, (%r14)
movl $0x2f3179, 0x3(%r14)    # imm = 0x2F3179
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4620
movl $0x0, 0x20(%rsp)
movq %r14, %rdi
xorl %esi, %esi
movl $0x1b4, %edx            # imm = 0x1B4
xorl %eax, %eax
callq 0x4280
movl %eax, %ebp
movl 0x44(%rsp), %eax
xorl $0x1, %eax
movl %ebp, %ecx
notl %ecx
orl %eax, %ecx
sete 0xc(%rsp)
leaq 0xb0(%rsp), %r14
movl %r15d, (%r14)
movl $0x2f3279, 0x3(%r14)    # imm = 0x2F3279
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4620
movq %r14, %rdi
xorl %esi, %esi
movl $0x1b4, %edx            # imm = 0x1B4
xorl %eax, %eax
callq 0x4280
movl %eax, %r12d
movl %r13d, 0x60(%rsp)
cmpl $0x1, %r13d
sete 0x24(%rsp)
cmpl $-0x1, %eax
sete 0x10(%rsp)
leaq 0x90(%rsp), %r14
movl %r15d, (%r14)
movl $0x2f3379, 0x3(%r14)    # imm = 0x2F3379
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4620
movq %r14, %rdi
xorl %esi, %esi
movl $0x1b4, %edx            # imm = 0x1B4
xorl %eax, %eax
callq 0x4280
movl %eax, %r14d
movl 0x1c(%rsp), %eax
xorl $0x1, %eax
movl %r14d, %ecx
notl %ecx
movl $0x0, 0x34(%rsp)
orl %eax, %ecx
sete 0x1b(%rsp)
leaq 0x208(%rsp), %rbx
movl %ebp, %edi
movq %rbx, %rsi
callq 0x45d0
movq 0x30(%rbx), %r15
leaq 0x178(%rsp), %rbx
movl %r12d, %edi
movq %rbx, %rsi
callq 0x45d0
movq 0x30(%rbx), %r13
leaq 0xe8(%rsp), %rbx
movl %r14d, 0x14(%rsp)
movl %r14d, %edi
movq %rbx, %rsi
callq 0x45d0
movq 0x30(%rbx), %rbx
movq %r15, 0x70(%rsp)
movslq %r15d, %r15
leaq (,%r15,8), %rdi
movq %rdi, 0x88(%rsp)
callq 0x44b0
movq %rax, 0x38(%rsp)
movq %r13, 0x78(%rsp)
movslq %r13d, %r14
leaq (,%r14,8), %rdi
movq %rdi, 0x80(%rsp)
callq 0x44b0
movq %rax, %r13
movq %rbx, 0x68(%rsp)
movslq %ebx, %rax
movq %rax, 0x48(%rsp)
leaq (,%rax,8), %rdi
callq 0x44b0
movq %rax, 0x50(%rsp)
movl %r12d, 0x8(%rsp)
cmpl $-0x1, %r12d
movq %r14, 0x28(%rsp)
je 0x58e9
cmpl $-0x1, %ebp
je 0x58e9
movb $0x1, %r12b
movq 0x70(%rsp), %rax
cmpl 0x78(%rsp), %eax
movq 0x38(%rsp), %rbx
jne 0x58f1
xorl %r12d, %r12d
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4690
movl 0x8(%rsp), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4690
movl %ebp, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4510
testq %rax, %rax
js 0x58d7
movq %rax, %r14
movl 0x8(%rsp), %edi
movq %r13, %rsi
movq 0x28(%rsp), %rdx
callq 0x4510
testq %rax, %rax
js 0x58d7
movl $0x2, %edi
callq 0x42a0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x44d0
testl %eax, %eax
jne 0x58d7
addq %r14, %r12
cmpq %r15, %r12
jne 0x5880
movb $0x1, %al
movl %eax, 0x20(%rsp)
xorl %r12d, %r12d
jmp 0x58e2
movl $0x0, 0x20(%rsp)
movb $0x1, %r12b
movq 0x28(%rsp), %r14
jmp 0x58f1
movb $0x1, %r12b
movq 0x38(%rsp), %rbx
movb 0x10(%rsp), %al
andb %al, 0x24(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x41f0
movq %r13, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x41f0
movl %r12d, 0x5c(%rsp)
testb %r12b, %r12b
movl %ebp, 0x38(%rsp)
je 0x59c6
movl $0x0, 0x10(%rsp)
cmpl $-0x1, %ebp
movl $0x0, %r12d
je 0x59d1
cmpl $-0x1, 0x14(%rsp)
je 0x59d1
movq 0x70(%rsp), %rax
cmpl 0x68(%rsp), %eax
jne 0x59d1
xorl %r12d, %r12d
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4690
movl 0x14(%rsp), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4690
movl %ebp, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4510
testq %rax, %rax
js 0x59c6
movq %rax, %r14
movl 0x14(%rsp), %edi
movq 0x50(%rsp), %rbp
movq %rbp, %rsi
movq 0x48(%rsp), %rdx
callq 0x4510
testq %rax, %rax
js 0x59c6
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x44d0
cmpl $0x1, %eax
jne 0x59c6
addq %r14, %r12
cmpq %r15, %r12
movl 0x38(%rsp), %ebp
jne 0x596d
movb $0x1, %al
movl %eax, 0x10(%rsp)
xorl %ebp, %ebp
xorl %r12d, %r12d
jmp 0x59d4
movl $0x0, 0x10(%rsp)
xorl %r12d, %r12d
movb $0x1, %bpl
movb 0xc(%rsp), %al
movb %al, %r12b
movzbl 0x24(%rsp), %eax
movl %eax, 0x24(%rsp)
movl 0x34(%rsp), %eax
movb 0x1b(%rsp), %cl
movb %cl, %al
movl %eax, 0x34(%rsp)
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x41f0
movq 0x50(%rsp), %rdi
xorl %esi, %esi
movq 0x48(%rsp), %rdx
callq 0x41f0
movl 0x5c(%rsp), %eax
andb %bpl, %al
cmpb $0x1, %al
jne 0x5ad3
xorl %r14d, %r14d
cmpl $-0x1, 0x8(%rsp)
je 0x5ad3
cmpl $-0x1, 0x14(%rsp)
je 0x5ad3
movq 0x68(%rsp), %rax
cmpl %eax, 0x78(%rsp)
jne 0x5ad3
movl %r12d, 0xc(%rsp)
xorl %r12d, %r12d
movl 0x8(%rsp), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4690
movl 0x14(%rsp), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4690
movq 0x28(%rsp), %rdx
movq 0x50(%rsp), %rbp
movl 0x8(%rsp), %edi
movq %r13, %rsi
callq 0x4510
testq %rax, %rax
js 0x5acb
movq %rax, %r14
movl 0x14(%rsp), %edi
movq %rbp, %rsi
movq 0x48(%rsp), %rdx
callq 0x4510
testq %rax, %rax
js 0x5acb
movl $0x2, %edi
callq 0x42a0
movq %r13, %rdi
movq %rbp, %rsi
callq 0x44d0
testl %eax, %eax
jne 0x5acb
addq %r14, %r12
movq 0x28(%rsp), %rdx
cmpq %rdx, %r12
jne 0x5a76
movb $0x1, %r14b
jmp 0x5ace
xorl %r14d, %r14d
movl 0xc(%rsp), %r12d
movl %r14d, 0xc(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x41f0
movq 0x50(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
movq 0x48(%rsp), %rdx
callq 0x41f0
movl 0x38(%rsp), %ebp
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4690
movl 0x8(%rsp), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4690
movq %rbx, %rdi
callq 0x4400
movq %r13, %rdi
callq 0x4400
movq %r14, %rdi
callq 0x4400
movl 0x14(%rsp), %edi
callq 0x46d0
movl 0x24(%rsp), %r14d
addl %r12d, %r14d
addl 0x34(%rsp), %r14d
movl 0x60(%rsp), %ebx
addl 0x44(%rsp), %ebx
addl 0x1c(%rsp), %ebx
movl 0x64(%rsp), %r12d
je 0x5b5c
cmpl $0x3, %r14d
jne 0x5b7d
movl %ebp, %edi
callq 0x46d0
movl 0x8(%rsp), %edi
callq 0x46d0
leaq 0xfa04(%rip), %rsi      # 0x15577
movl %r12d, %edi
xorl %eax, %eax
callq 0x4200
cmpl $0x2, %r14d
jb 0x5ba4
movl %ebp, %edi
callq 0x46d0
movl 0x8(%rsp), %edi
callq 0x46d0
leaq 0xf97c(%rip), %rsi      # 0x15516
movl %r12d, %edi
xorl %eax, %eax
callq 0x4200
cmpl $0x2, %ebx
jne 0x5bd0
cmpl $0x1, %r14d
jne 0x5bd0
movl %ebp, %edi
callq 0x46d0
movl 0x8(%rsp), %edi
callq 0x46d0
leaq 0xf9b1(%rip), %rsi      # 0x15577
movl %r12d, %edi
xorl %eax, %eax
callq 0x4200
cmpl $0x1, %ebx
jne 0x5bfc
cmpl $0x1, %r14d
jne 0x5bfc
movl %ebp, %edi
callq 0x46d0
movl 0x8(%rsp), %edi
callq 0x46d0
leaq 0xf952(%rip), %rsi      # 0x15544
movl %r12d, %edi
xorl %eax, %eax
callq 0x4200
movl 0x20(%rsp), %eax
orb 0x10(%rsp), %al
cmpb $0x1, %al
jne 0x5c56
movl %ebp, %edi
movl %r12d, %esi
callq 0x5102
movq 0x88(%rsp), %rdi
callq 0x44b0
movq %rax, %rbx
xorl %r14d, %r14d
movl $0x8, %edx
movl %ebp, %edi
movq %rbx, %rsi
callq 0x4510
movl %eax, 0x19c82(%rip)     # 0x1f8bc
testl %eax, %eax
je 0x5cb0
movslq %eax, %rdx
movl %r12d, %edi
movq %rbx, %rsi
callq 0x4130
addq %rax, %r14
cmpq %r15, %r14
jne 0x5c25
jmp 0x5cb0
cmpb $0x0, 0xc(%rsp)
je 0x5ce4
movl 0x8(%rsp), %edi
movl %r12d, %esi
callq 0x5102
movq 0x80(%rsp), %rdi
callq 0x44b0
movq %rax, %rbx
movq 0x28(%rsp), %r14
movl $0x8, %edx
movl 0x8(%rsp), %edi
movq %rbx, %rsi
callq 0x4510
movl %eax, 0x19c23(%rip)     # 0x1f8bc
testl %eax, %eax
je 0x5cb0
movslq %eax, %rdx
movl %r12d, %edi
movq %rbx, %rsi
callq 0x4130
cmpq %r14, %rax
jne 0x5c82
movl %ebp, %edi
callq 0x46d0
movl 0x8(%rsp), %edi
callq 0x46d0
cmpl $0x0, 0x19bf5(%rip)     # 0x1f8bc
je 0x5cda
leaq 0xf8a7(%rip), %rsi      # 0x15577
movl %r12d, %edi
xorl %eax, %eax
callq 0x4200
movq %rbx, %rdi
callq 0x4400
jmp 0x5d05
movl %ebp, %edi
callq 0x46d0
movl 0x8(%rsp), %edi
callq 0x46d0
leaq 0xf87c(%rip), %rsi      # 0x15577
movl %r12d, %edi
xorl %eax, %eax
callq 0x4200
xorl %eax, %eax
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq