// File: /workspace/github_c_makefile_star2_O3/Zarh[P]regps3iso/iso.c
// Function: GetFileInfo
u8 GetFileInfo(char *iso, file_info_t **file_info, u32 *file_number)
{
    struct stat s;
    int n;
    
    *file_number = 0;
    
    file_info_t *local =NULL;
    
	char path1[0x420];
    char path2[0x420];
    int len_path2 = 0;

	strcpy(path1, iso);
    u8 *sectors = NULL;
    u8 *sectors2 = NULL;
    u8 *sectors3 = NULL;

    static char string[0x420];
    static char string2[0x420];
    static u16 wstring[1024];

    struct iso_primary_descriptor sect_descriptor;
    struct iso_directory_record * idr;
    int idx = -1;

	//u32 flba = 0;
	u32 lba;
	u32 p = 0;
	//u32 toc;
	u32 lba0;
	u32 size0;
    
	directory_iso2 = NULL;

    fp_split = NULL;
    fp_split0 = NULL;
    split_index = 0;

    // libc test
    if(sizeof(s.st_size) != 8) {
        printf("Error!: stat st_size must be a 64 bit number!  (size %i)\n\nPress ENTER key to exit\n\n", sizeof(s.st_size));
        return -1;
    }
    
    fixpath(path1);

    n = strlen(path1);

    sprintf(split_file[0].path, "%s", path1);
	
    if(stat(split_file[0].path, &s)<0) {
        printf("Error: ISO file don't exists!\n\nPress ENTER key to exit\n"); return -1;
    }
    split_file[0].size = s.st_size;
    split_file[1].size = 0; // split off

    FILE *fp = fopen(path1, "rb");
    if(!fp) {
        printf("Error!: Cannot open ISO file\n\nPress ENTER key to exit\n\n");
        return -1;
    }

    
    if(fseek(fp, 0x8800, SEEK_SET)<0) {
        printf("Error!: in sect_descriptor fseek\n\n");
        goto err;
    }

    if(fread((void *) &sect_descriptor, 1, 2048, fp) != 2048) {
        printf("Error!: reading sect_descriptor\n\n");
        goto err;
    }

    if(!(sect_descriptor.type[0] == 2 && !strncmp((const char *) &sect_descriptor.id[0], "CD001",5))) {
        printf("Error!: UTF16 descriptor not found\n\nPress ENTER key to exit\n\n");
        goto err;
    }

    //toc = isonum_733(&sect_descriptor.volume_space_size[0]);

    lba0 = isonum_731(&sect_descriptor.type_l_path_table[0]); // lba
    size0 = isonum_733(&sect_descriptor.path_table_size[0]); // tamaño
    //printf("lba0 %u size %u %u\n", lba0, size0, ((size0 + 2047)/2048) * 2048);
    
    if(fseek(fp, lba0 * 2048, SEEK_SET)<0) {
        printf("Error!: in path_table fseek\n\n");
        goto err;
    }

    directory_iso2 = (_directory_iso2 *) malloc((MAX_ISO_PATHS + 1) * sizeof(_directory_iso2));

    if(!directory_iso2) {
        printf("Error!: in directory_is malloc()\n\n");
        goto err;
    }

    memset(directory_iso2, 0, (MAX_ISO_PATHS + 1) * sizeof(_directory_iso2));
 
    sectors = (u8*) malloc(((size0 + 2047)/2048) * 2048);

    if(!sectors) {
        printf("Error!: in sectors malloc()\n\n");
        goto err;
    }

    sectors2 = (u8*) malloc(2048 * 2);

    if(!sectors2) {
        printf("Error!: in sectors2 malloc()\n\n");
        goto err;
    }

    sectors3 = (u8*) malloc(128 * 2048);

    if(!sectors3) {
        printf("Error!: in sectors3 malloc()\n\n");
        goto err;
    }

    if(fread((void *) sectors, 1, size0, fp) != size0) {
        printf("Error!: reading path_table\n\n");
        goto err;
    }

    string2[0] = 0;

    fp_split = NULL;
    fp_split0 = NULL;

    split_index = 0;
    
    idx = 0;

    directory_iso2[idx].name = NULL;

    while(p < size0) {
        u32 snamelen = isonum_721((char *) &sectors[p]);
        if(snamelen == 0) p= ((p/2048) * 2048) + 2048;
        p+=2;
        lba = isonum_731(&sectors[p]);
        p+=4;
        u32 parent =isonum_721((char *) &sectors[p]);
        p+=2;

        memset(wstring, 0, 512 * 2);
        memcpy(wstring, &sectors[p], snamelen);
        
        UTF16_to_UTF8(wstring, (u8 *) string);

        if(idx >= MAX_ISO_PATHS){
            printf("Too much folders (max %i)\n\n", MAX_ISO_PATHS);
            goto err;
        }

        directory_iso2[idx].name = (char *) malloc(strlen(string) + 2);
        if(!directory_iso2[idx].name) {
            printf("Error!: in directory_iso2.name malloc()\n\n");
            goto err;
        }

        strcpy(directory_iso2[idx].name, "/");
        strcat(directory_iso2[idx].name, string);
        
        directory_iso2[idx].parent = parent;
        
        get_iso_path(string2, idx);

        strcat(path2, string2);
		
        path2[len_path2] = 0;
   
        u32 file_lba = 0;
        u64 file_size = 0;

        char file_aux[0x420];

        file_aux[0] = 0;

        int q2 = 0;
        int size_directory = 0;

        while(1) {

            if(fseek(fp, ((u64) lba) * 2048ULL, SEEK_SET)<0) {
                printf("Error!: in directory_record fseek\n\n");
                goto err;
            }

            memset(sectors2 + 2048, 0, 2048);

            if(fread((void *) sectors2, 1, 2048, fp) != 2048) {
                printf("Error!: reading directory_record sector\n\n");
                goto err;
            }

            int q = 0;
            
            if(q2 == 0) {
                idr = (struct iso_directory_record *) &sectors2[q];
                if((int) idr->name_len[0] == 1 && idr->name[0]== 0 && (u64) lba == (u64) (isonum_731((unsigned char *) idr->extent)) && idr->flags[0] == 0x2) {
                    size_directory = isonum_733((unsigned char *) idr->size);
                 
                } else {
                    printf("Error!: Bad first directory record! (LBA %i)\n\n", lba);
                    goto err;
                }
            }

            int signal_idr_correction = 0;

            while(1) {

               
                if(signal_idr_correction) {
                    signal_idr_correction = 0;
                    q-= 2048; // sector correction
                    // copy next sector to first
                    memcpy(sectors2, sectors2 + 2048, 2048);
                    memset(sectors2 + 2048, 0, 2048);
                    lba++;

                    q2 += 2048;

                }

                if(q2 >= size_directory) goto end_dir_rec;
               
                idr = (struct iso_directory_record *) &sectors2[q];

                if(idr->length[0]!=0 && (idr->length[0] + q) > 2048) {

                    printf("Warning! Entry directory break the standard ISO 9660\n\nPress ENTER key\n\n");
                   
                    if(fseek(fp, lba * 2048 + 2048, SEEK_SET)<0) {
                        printf("Error!: in directory_record fseek\n\n");
                        goto err;
                    }

                    if(fread((void *) (sectors2 + 2048), 1, 2048, fp) != 2048) {
                        printf("Error!: reading directory_record sector\n\n");
                        goto err;
                    }

                    signal_idr_correction = 1;

                }

                if(idr->length[0] == 0 && (2048 - q) > 255) goto end_dir_rec;

                if((idr->length[0] == 0 && q != 0) || q == 2048)  { 
                    
                    lba++;
                    q2 += 2048;

                    if(q2 >= size_directory) goto end_dir_rec;

                    if(fseek(fp, (((u64) lba) * 2048ULL), SEEK_SET)<0) {
                        printf("Error!: in directory_record fseek\n\n");
                        goto err;
                    }

                    if(fread((void *) (sectors2), 1, 2048, fp) != 2048) {
                        printf("Error!: reading directory_record sector\n\n");
                        goto err;
                    }
                    memset(sectors2 + 2048, 0, 2048);

                    q = 0;
                    idr = (struct iso_directory_record *) &sectors2[q];

                    if(idr->length[0] == 0 || ((int) idr->name_len[0] == 1 && !idr->name[0])) goto end_dir_rec;
                    
                }

                if((int) idr->name_len[0] > 1 && idr->flags[0] != 0x2 &&
                    idr->name[idr->name_len[0] - 1]== '1' && idr->name[idr->name_len[0] - 3]== ';') { // skip directories
                    
                    memset(wstring, 0, 512 * 2);
                    memcpy(wstring, idr->name, idr->name_len[0]);
                
                    UTF16_to_UTF8(wstring, (u8 *) string); 

                    if(file_aux[0]) {
                        if(strcmp(string, file_aux)) {
    
                            printf("Error!: in batch file %s\n\nPress ENTER key to exit\n\n", file_aux);
                            goto err;
                        }

                        file_size += (u64) (u32) isonum_733(&idr->size[0]);
                        if(idr->flags[0] == 0x80) {// get next batch file
                            q+= idr->length[0]; 
                            continue;
                        } 

                        file_aux[0] = 0; // stop batch file

                    } else {

                        file_lba = isonum_733(&idr->extent[0]);
                        file_size = (u64) (u32) isonum_733(&idr->size[0]);
                        if(idr->flags[0] == 0x80) {
                            strcpy(file_aux, string);
                            q+= idr->length[0];
                            continue;  // get next batch file
                        }
                    }

                    int len = strlen(string);

                    string[len - 2] = 0; // break ";1" string
                    
                    len = strlen(string2);
					if(strcmp(string2, "/") != 0)	strcat(string2, "/");
                    strcat(string2, string);
					
					local = (file_info_t *) realloc(local, (*file_number + 1) * sizeof(file_info_t));
                    local[*file_number].sector = file_lba;
                    local[*file_number].size = file_size; 
                    local[*file_number].path = strcpy_malloc(string2);
					
					*file_number = *file_number + 1;
					                    
                    path2[len_path2] = 0;
                    string2[len] = 0;
                }

                q+= idr->length[0];
            }

            lba ++; 
            q2+= 2048;
            if(q2 >= size_directory) goto end_dir_rec;

        }

        end_dir_rec:

        p+= snamelen;
        if(snamelen & 1) p++;

        idx++;

    }

    if(fp) fclose(fp);
    if(split_index && fp_split) {fclose(fp_split); fp_split = NULL;}
    if(sectors) free(sectors);
    if(sectors2) free(sectors2);
    if(sectors3) free(sectors3);

    for(n = 0; n <= idx; n++)
        if(directory_iso2[n].name) {free(directory_iso2[n].name); directory_iso2[n].name = NULL;}
    
    if(directory_iso2) free(directory_iso2); 

	
    // sort
    *file_info = (file_info_t *) malloc((*file_number) * sizeof(file_info_t) );
	
    u32 i,j;
	u32 smallest_sector = 0;
	for(j=0; j<(*file_number); j++) {
		
		for(i=0; i<(*file_number); i++) {
			if( local[i].sector < local[smallest_sector].sector ) {
				smallest_sector = i;
			}
		}
		(*file_info)[j].size = local[smallest_sector].size;
		(*file_info)[j].sector = local[smallest_sector].sector;
		(*file_info)[j].path = strcpy_malloc(local[smallest_sector].path);
		
		local[smallest_sector].sector = -1; // MAX !
	}
	
	for(j=0; j<(*file_number); j++) FREE(local[j].path);
	FREE(local);
	
    return 0;

err:

    if(fp) fclose(fp);
    if(split_index && fp_split) {fclose(fp_split); fp_split = NULL;}

    if(sectors) free(sectors);
    if(sectors2) free(sectors2);
    if(sectors3) free(sectors3);

    for(n = 0; n <= idx; n++)
        if(directory_iso2[n].name) {free(directory_iso2[n].name); directory_iso2[n].name = NULL;}
    
    if(directory_iso2) free(directory_iso2);

    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1168, %rsp           # imm = 0x1168
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %rsi
movl $0x0, (%rdx)
leaq 0x540(%rsp), %r15
movq %r15, %rdi
callq 0x401020
movq $0x0, 0xf4e59(%rip) # 0x4f8420
cmpb $0x22, (%r15)
jne 0x403603
leaq 0x540(%rsp), %r12
movq %r12, %rdi
callq 0x4010f8
movb $0x0, 0x53f(%rsp,%rax)
leaq 0x541(%rsp), %r13
movq %r12, %rdi
callq 0x4010f8
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x401048
movzbl (%r15), %eax
cmpl $0x5c, %eax
je 0x40361b
testl %eax, %eax
je 0x403628
cmpl $0x22, %eax
je 0x403624
cmpb $0x20, %al
jae 0x40361f
jmp 0x403624
movb $0x2f, (%r15)
incq %r15
jmp 0x403603
movb $0x0, (%r15)
leaq 0xf4e05(%rip), %r15     # 0x4f8434
leaq 0x540(%rsp), %rsi
movq %r15, %rdi
callq 0x401020
leaq 0x90(%rsp), %rsi
movq %r15, %rdi
callq 0x4650b0
testl %eax, %eax
js 0x403dec
movl 0xc0(%rsp), %eax
movl %eax, 0xf4dcc(%rip)     # 0x4f8430
movl $0x0, 0xf51e6(%rip)     # 0x4f8854
leaq 0xbf9b2(%rip), %rsi     # 0x4c3027
leaq 0x540(%rsp), %rdi
callq 0x41cbe0
testq %rax, %rax
je 0x403df5
movq %rax, %r15
movl $0x8800, %esi           # imm = 0x8800
movq %rax, %rdi
xorl %edx, %edx
callq 0x41f640
testl %eax, %eax
js 0x403e03
leaq 0x968(%rsp), %rdi
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
movq %r15, %rcx
callq 0x41ce10
cmpq $0x800, %rax            # imm = 0x800
jne 0x403e0c
leaq 0xbfdbf(%rip), %rdi     # 0x4c3491
cmpb $0x2, 0x968(%rsp)
jne 0x403e13
movl $0x30304443, %eax       # imm = 0x30304443
xorl 0x969(%rsp), %eax
movzbl 0x96d(%rsp), %ecx
xorl $0x31, %ecx
orl %eax, %ecx
jne 0x403e13
movl 0x9ec(%rsp), %ebp
movl 0x9f4(%rsp), %esi
shll $0xb, %esi
movq %r15, %rdi
xorl %edx, %edx
callq 0x41f640
testl %eax, %eax
js 0x403e48
movl $0x1, %edi
movl $0x10010, %esi          # imm = 0x10010
callq 0x42c090
movq %rax, 0xf4ce8(%rip)     # 0x4f8420
testq %rax, %rax
je 0x403e51
leal 0x7ff(%rbp), %edi
andl $0xfffff800, %edi       # imm = 0xFFFFF800
callq 0x42ac40
testq %rax, %rax
je 0x403e5a
movq %rax, %r13
movl $0x1000, %edi           # imm = 0x1000
callq 0x42ac40
movq %rax, (%rsp)
testq %rax, %rax
movq %r13, 0x38(%rsp)
je 0x403e63
movl $0x40000, %edi          # imm = 0x40000
callq 0x42ac40
testq %rax, %rax
je 0x403e6c
movq %rax, %r13
movl $0x1, %eax
movq %rax, 0x10(%rsp)
movl $0x1, %esi
movq 0x38(%rsp), %rdi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x41ce10
cmpq %rbp, %rax
jne 0x403e82
movb $0x0, 0xf4041(%rip)     # 0x4f7800
movq 0xf4c5a(%rip), %rax     # 0x4f8420
movq $0x0, 0x8(%rax)
movq %rbp, 0x78(%rsp)
testq %rbp, %rbp
je 0x403f05
movq %r13, 0x18(%rsp)
movq (%rsp), %rax
addq $0x800, %rax            # imm = 0x800
movq %rax, 0x50(%rsp)
leaq 0xf4429(%rip), %rsi     # 0x4f7c20
leaq 0xbfc37(%rip), %rax     # 0x4c3435
movq %rax, 0x68(%rsp)
xorl %eax, %eax
movq $0x0, 0x30(%rsp)
xorl %ecx, %ecx
movq %rax, 0x10(%rsp)
movl %ecx, %eax
movq 0x38(%rsp), %rdi
movzbl (%rdi,%rax), %edx
movzbl 0x1(%rdi,%rax), %r13d
shll $0x8, %r13d
movl %edx, 0x64(%rsp)
orl %edx, %r13d
movl %ecx, %ebp
andl $0xfffff800, %ebp       # imm = 0xFFFFF800
addl $0x800, %ebp            # imm = 0x800
testl %r13d, %r13d
cmovnel %ecx, %ebp
leal 0x2(%rbp), %eax
movl (%rdi,%rax), %eax
movq %rax, 0x28(%rsp)
leal 0x6(%rbp), %eax
movzwl (%rdi,%rax), %eax
movl %eax, 0x8(%rsp)
addl $0x8, %ebp
movl $0x400, %edx            # imm = 0x400
movq %rsi, %r12
movq %rsi, %rdi
xorl %esi, %esi
callq 0x4010b8
movq %rbp, 0x80(%rsp)
movq 0x38(%rsp), %rax
leaq (%rax,%rbp), %rsi
movq 0x10(%rsp), %rbp
movq %r12, %rdi
movq %r13, 0x88(%rsp)
movq %r13, %rdx
callq 0x401048
callq 0x404126
cmpq $0x1000, %rbp           # imm = 0x1000
je 0x4040bf
leaq 0xf3b2e(%rip), %r12     # 0x4f73e0
movq %r12, %rdi
callq 0x4010f8
leaq 0x2(%rax), %rdi
callq 0x42ac40
movq 0xf4b56(%rip), %rcx     # 0x4f8420
movq %rbp, %rdx
shlq $0x4, %rdx
movq %rax, 0x8(%rcx,%rdx)
testq %rax, %rax
je 0x4040d9
leaq (%rcx,%rdx), %r13
addq $0x8, %r13
movw $0x2f, (%rax)
movq (%r13), %rdi
movq %r12, %rsi
callq 0x401060
movl 0x8(%rsp), %eax
movl %eax, -0x8(%r13)
movl %ebp, %edi
callq 0x40423b
movb $0x0, 0x120(%rsp)
movq 0x28(%rsp), %rsi
shlq $0xb, %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x41f640
testl %eax, %eax
js 0x4040fb
movl $0x800, %edx            # imm = 0x800
movq 0x50(%rsp), %rdi
xorl %esi, %esi
callq 0x4010b8
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
movq (%rsp), %rdi
movq %r15, %rcx
callq 0x41ce10
cmpq $0x800, %rax            # imm = 0x800
jne 0x4040ef
movq (%rsp), %rax
cmpb $0x1, 0x20(%rax)
leaq 0xf42b4(%rip), %rsi     # 0x4f7c20
movq 0x28(%rsp), %r8
jne 0x404094
movq (%rsp), %rax
cmpb $0x0, 0x21(%rax)
jne 0x404094
movq (%rsp), %rax
movslq 0x2(%rax), %rax
cmpq %rax, %r8
jne 0x404094
movq (%rsp), %rax
cmpb $0x2, 0x19(%rax)
jne 0x404094
movq (%rsp), %rax
movl 0xa(%rax), %eax
movl %eax, 0x4c(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x58(%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %eax, %eax
testl %eax, %eax
je 0x403a20
addl $0xfffff800, %ebp       # imm = 0xFFFFF800
movl %ebp, 0x8(%rsp)
movl $0x800, %edx            # imm = 0x800
movq (%rsp), %rdi
movl %r13d, %r12d
movq 0x50(%rsp), %r13
movq %r13, %rsi
movq %r8, 0x28(%rsp)
callq 0x401048
movl $0x800, %edx            # imm = 0x800
movq %r13, %rdi
movl %r12d, %r13d
movl 0x8(%rsp), %ebp
xorl %esi, %esi
callq 0x4010b8
movq 0x28(%rsp), %r8
leaq 0xf420a(%rip), %rsi     # 0x4f7c20
incl %r8d
addl $0x800, %r13d           # imm = 0x800
cmpl 0x4c(%rsp), %r13d
jge 0x403daf
movslq %ebp, %rax
movq (%rsp), %rcx
leaq (%rcx,%rax), %rdi
movb (%rcx,%rax), %al
testb %al, %al
setne %cl
movzbl %al, %edx
addl %ebp, %edx
cmpl $0x801, %edx            # imm = 0x801
setge %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x403ad0
movq %rdi, 0x40(%rsp)
movl %r13d, 0xc(%rsp)
leaq 0xbf961(%rip), %rdi     # 0x4c33c5
movq %r8, %r12
callq 0x41d390
movq %r12, %r13
movl %r12d, %esi
shll $0xb, %esi
addl $0x800, %esi            # imm = 0x800
movq %r15, %rdi
xorl %edx, %edx
callq 0x41f640
testl %eax, %eax
js 0x404082
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
movq 0x50(%rsp), %rdi
movq %r15, %rcx
callq 0x41ce10
cmpq $0x800, %rax            # imm = 0x800
jne 0x40408b
movq 0x40(%rsp), %rdi
movb (%rdi), %al
movl $0x1, 0x24(%rsp)
leaq 0xf415a(%rip), %rsi     # 0x4f7c20
movq %r13, %r8
movl 0xc(%rsp), %r13d
jmp 0x403ad8
movl $0x0, 0x24(%rsp)
testb %al, %al
sete %cl
cmpl $0x701, %ebp            # imm = 0x701
setl %dl
testb %dl, %cl
jne 0x403daf
testb %al, %al
sete %cl
testl %ebp, %ebp
setne %dl
testb %dl, %cl
jne 0x403b0c
cmpl $0x800, %ebp            # imm = 0x800
je 0x403b0c
movb 0x20(%rdi), %cl
jmp 0x403b9e
addl $0x800, %r13d           # imm = 0x800
cmpl 0x4c(%rsp), %r13d
jge 0x403daf
incl %r8d
movq %r8, %r12
movl %r8d, %esi
shlq $0xb, %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x41f640
testl %eax, %eax
js 0x404082
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
movq (%rsp), %rdi
movq %r15, %rcx
callq 0x41ce10
cmpq $0x800, %rax            # imm = 0x800
jne 0x40408b
movl $0x800, %edx            # imm = 0x800
movq 0x50(%rsp), %rdi
xorl %esi, %esi
callq 0x4010b8
movq (%rsp), %rax
movb (%rax), %al
testb %al, %al
leaq 0xf40a1(%rip), %rsi     # 0x4f7c20
je 0x403daf
movq %r12, %r8
movq (%rsp), %rcx
movb 0x20(%rcx), %cl
xorl %ebp, %ebp
cmpb $0x1, %cl
je 0x403d9b
movq (%rsp), %rdi
cmpb $0x2, %cl
jb 0x403da7
cmpb $0x2, 0x19(%rdi)
je 0x403da7
movzbl %cl, %ecx
leal -0x1(%rcx), %edx
cmpb $0x31, 0x21(%rdi,%rdx)
jne 0x403da7
movl %r13d, 0xc(%rsp)
leaq 0x21(%rdi), %r13
movl %ecx, %r12d
cmpb $0x3b, -0x3(%r12,%r13)
jne 0x403c6a
movq %rdi, 0x40(%rsp)
movl %ebp, 0x8(%rsp)
movq %r8, 0x28(%rsp)
movl $0x400, %edx            # imm = 0x400
movq %rsi, %rbp
movq %rsi, %rdi
xorl %esi, %esi
callq 0x4010b8
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x401048
callq 0x404126
cmpb $0x0, 0x120(%rsp)
je 0x403c74
leaq 0xf37c2(%rip), %rdi     # 0x4f73e0
leaq 0x120(%rsp), %rsi
callq 0x4010c8
testl %eax, %eax
movq 0x28(%rsp), %r8
movl 0xc(%rsp), %r13d
movl 0x8(%rsp), %ebp
jne 0x4040a7
movq 0x40(%rsp), %rcx
movl 0xa(%rcx), %eax
addq %rax, 0x58(%rsp)
xorl %eax, %eax
cmpb 0x19(%rcx), %al
leaq 0xf3fc6(%rip), %rsi     # 0x4f7c20
jno 0x403ccf
movzbl (%rcx), %eax
addl %eax, %ebp
movl 0x24(%rsp), %eax
jmp 0x4039c8
movl 0xc(%rsp), %r13d
jmp 0x403da7
movq 0x40(%rsp), %r12
movl 0x2(%r12), %eax
movq %rax, 0x70(%rsp)
movl 0xa(%r12), %eax
movq %rax, 0x58(%rsp)
xorl %eax, %eax
cmpb 0x19(%r12), %al
jno 0x403cd7
leaq 0x120(%rsp), %rdi
leaq 0xf373b(%rip), %rsi     # 0x4f73e0
callq 0x401020
movzbl (%r12), %eax
movl 0x8(%rsp), %ebp
addl %eax, %ebp
leaq 0xf3f64(%rip), %rsi     # 0x4f7c20
movq 0x28(%rsp), %r8
movl 0xc(%rsp), %r13d
movl 0x24(%rsp), %eax
jmp 0x4039c8
movb $0x0, 0x120(%rsp)
leaq 0xf3702(%rip), %r12     # 0x4f73e0
movq %r12, %rdi
callq 0x4010f8
addl $-0x2, %eax
cltq
movb $0x0, (%rax,%r12)
leaq 0xf3b09(%rip), %r13     # 0x4f7800
movq %r13, %rdi
callq 0x4010f8
movq %rax, %rbp
cmpw $0x2f, 0xf3af6(%rip)    # 0x4f7800
je 0x403d1b
movq %r13, %rdi
callq 0x4010f8
movw $0x2f, (%rax,%r13)
movq %r13, %rdi
movq %r12, %rsi
callq 0x401060
movl (%rbx), %eax
incl %eax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
movq 0x30(%rsp), %rdi
callq 0x42b2d0
movq %rax, %r12
movl (%rbx), %eax
leaq (%rax,%rax,2), %rax
movq 0x70(%rsp), %rcx
movl %ecx, 0x8(%r12,%rax,8)
movq 0x58(%rsp), %rcx
movq %rcx, 0x10(%r12,%rax,8)
movq %r13, %rdi
callq 0x403544
movl (%rbx), %ecx
leaq (%rcx,%rcx,2), %rdx
movq %r12, 0x30(%rsp)
movq %rax, (%r12,%rdx,8)
leal 0x1(%rcx), %eax
movl %eax, (%rbx)
movslq %ebp, %rax
movb $0x0, (%rax,%r13)
movq 0x40(%rsp), %rax
movb (%rax), %al
leaq 0xf3e95(%rip), %rsi     # 0x4f7c20
movq 0x28(%rsp), %r8
movl 0xc(%rsp), %r13d
movl 0x8(%rsp), %ebp
jmp 0x403da7
xorl %ebp, %ebp
movq (%rsp), %rcx
cmpb $0x0, 0x21(%rcx)
je 0x403daf
movzbl %al, %eax
jmp 0x403c5f
movl 0x64(%rsp), %eax
andl $0x1, %eax
movq 0x88(%rsp), %rcx
addl %eax, %ecx
addl 0x80(%rsp), %ecx
movq 0x10(%rsp), %rdx
leaq 0x1(%rdx), %rax
cmpl 0x78(%rsp), %ecx
jb 0x403810
addl $0x2, %edx
movq %rdx, 0x10(%rsp)
movq 0x18(%rsp), %r13
jmp 0x403f0e
leaq 0xbf71e(%rip), %rdi     # 0x4c3511
jmp 0x403dfc
leaq 0xbf4ee(%rip), %rdi     # 0x4c32ea
callq 0x41d390
jmp 0x403e34
leaq 0xbf6e5(%rip), %rdi     # 0x4c34ef
jmp 0x403e13
leaq 0xbf6bb(%rip), %rdi     # 0x4c34ce
callq 0x41d390
movq %r15, %rdi
callq 0x41c640
movq 0xf45f9(%rip), %rbx     # 0x4f8420
testq %rbx, %rbx
je 0x403e34
movq %rbx, %rdi
callq 0x42af80
movb $-0x1, %al
addq $0x1168, %rsp           # imm = 0x1168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbf625(%rip), %rdi     # 0x4c3474
jmp 0x403e13
leaq 0xbf4c9(%rip), %rdi     # 0x4c3321
jmp 0x403e13
leaq 0xbf4e2(%rip), %rdi     # 0x4c3343
jmp 0x403e13
leaq 0xbf4f6(%rip), %rdi     # 0x4c3360
jmp 0x403e73
leaq 0xbf50b(%rip), %rdi     # 0x4c337e
callq 0x41d390
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r13d, %r13d
jmp 0x403e93
leaq 0xbf5cf(%rip), %rdi     # 0x4c3458
callq 0x41d390
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %r15, %rdi
callq 0x41c640
movq 0x38(%rsp), %rdi
callq 0x42af80
cmpq $0x0, (%rsp)
je 0x403eb5
movq (%rsp), %rdi
callq 0x42af80
testq %r13, %r13
je 0x403ec2
movq %r13, %rdi
callq 0x42af80
movq 0xf4557(%rip), %rbx     # 0x4f8420
testl %ebp, %ebp
js 0x403e27
movl %ebp, %r14d
shlq $0x4, %r14
addq $0x10, %r14
xorl %r15d, %r15d
movq 0x8(%rbx,%r15), %rdi
testq %rdi, %rdi
je 0x403ef7
callq 0x42af80
movq $0x0, 0x8(%rbx,%r15)
addq $0x10, %r15
cmpq %r15, %r14
jne 0x403edf
jmp 0x403e2c
movq $0x0, 0x30(%rsp)
movq %r15, %rdi
callq 0x41c640
movq 0x38(%rsp), %rdi
callq 0x42af80
movq (%rsp), %rdi
callq 0x42af80
movq %r13, %rdi
callq 0x42af80
movq 0xf44e8(%rip), %r15     # 0x4f8420
movq 0x10(%rsp), %r13
shlq $0x4, %r13
xorl %r12d, %r12d
movq 0x8(%r15,%r12), %rdi
testq %rdi, %rdi
je 0x403f5c
callq 0x42af80
movq $0x0, 0x8(%r15,%r12)
addq $0x10, %r12
cmpq %r12, %r13
jne 0x403f44
movq %r15, %rdi
callq 0x42af80
movl (%rbx), %r15d
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %rdi
callq 0x42ac40
movq %rax, (%r14)
testq %r15, %r15
je 0x404069
movq 0x30(%rsp), %rbp
leaq 0x8(%rbp), %rax
movq %rax, (%rsp)
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpl $0x1, %r15d
adcl $0x0, %r15d
movq (%rsp), %rax
xorl %ecx, %ecx
movl %r12d, %edx
movl (%rax), %esi
movl %edx, %edi
leaq (%rdi,%rdi,2), %rdi
movl %ecx, %r12d
cmpl 0x8(%rbp,%rdi,8), %esi
jb 0x403fc5
movl %edx, %r12d
incq %rcx
addq $0x18, %rax
movl %r12d, %edx
cmpq %rcx, %r15
jne 0x403fb1
movl %r12d, %eax
leaq (%rax,%rax,2), %r15
movq 0x10(%rbp,%r15,8), %rax
movq (%r14), %rcx
leaq (,%r13,8), %rdx
leaq (%rdx,%rdx,2), %rbp
movq %rax, 0x10(%rcx,%rbp)
movq 0x30(%rsp), %rax
movl 0x8(%rax,%r15,8), %eax
movl %eax, 0x8(%rcx,%rbp)
movq 0x30(%rsp), %rax
movq (%rax,%r15,8), %rdi
callq 0x403544
movq (%r14), %rcx
movq %rax, (%rcx,%rbp)
movq 0x30(%rsp), %rbp
movl $0xffffffff, 0x8(%rbp,%r15,8) # imm = 0xFFFFFFFF
incq %r13
movl (%rbx), %r15d
cmpq %r15, %r13
jb 0x403fa0
testl %r15d, %r15d
je 0x404073
xorl %r14d, %r14d
movq %rbp, %r12
movq (%r12), %rdi
testq %rdi, %rdi
je 0x404058
callq 0x42af80
movq $0x0, (%r12)
movl (%rbx), %r15d
incq %r14
movl %r15d, %eax
addq $0x18, %r12
cmpq %rax, %r14
jb 0x40403f
jmp 0x404073
movq 0x30(%rsp), %rbp
testq %rbp, %rbp
je 0x40407b
movq %rbp, %rdi
callq 0x42af80
xorl %eax, %eax
jmp 0x403e36
leaq 0xbf3ac(%rip), %rdi     # 0x4c3435
jmp 0x404100
leaq 0xbf37a(%rip), %rdi     # 0x4c340c
jmp 0x404100
leaq 0xbf1ec(%rip), %rdi     # 0x4c3287
movl %r8d, %esi
xorl %eax, %eax
callq 0x40e110
jmp 0x404105
leaq 0xbf208(%rip), %rdi     # 0x4c32b6
leaq 0x120(%rsp), %rsi
xorl %eax, %eax
callq 0x40e110
jmp 0x404105
leaq 0xbf1a5(%rip), %rdi     # 0x4c326b
movl $0x1000, %ebp           # imm = 0x1000
movl $0x1000, %esi           # imm = 0x1000
xorl %eax, %eax
callq 0x40e110
jmp 0x4040e5
leaq 0xbf2bc(%rip), %rdi     # 0x4c339c
callq 0x41d390
movq 0x18(%rsp), %r13
jmp 0x403e93
leaq 0xbf316(%rip), %rax     # 0x4c340c
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
callq 0x41d390
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %rbp
movq %r15, %rdi
callq 0x41c640
movq 0x38(%rsp), %rdi
callq 0x42af80
jmp 0x403eac