// File: /workspace/github_c_makefile_star2_O1/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, %rbp
movq %rdi, %rsi
movl $0x0, (%rdx)
leaq 0x540(%rsp), %r14
movq %r14, %rdi
callq 0x401020
movq $0x0, 0xf4eca(%rip) # 0x4f8420
cmpb $0x22, (%r14)
jne 0x403592
leaq 0x540(%rsp), %r15
movq %r15, %rdi
callq 0x4010f8
movb $0x0, 0x53f(%rsp,%rax)
leaq 0x541(%rsp), %r12
movq %r15, %rdi
callq 0x4010f8
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x401048
movzbl (%r14), %eax
cmpl $0x5c, %eax
je 0x4035aa
testl %eax, %eax
je 0x4035b7
cmpl $0x22, %eax
je 0x4035b3
cmpb $0x20, %al
jae 0x4035ae
jmp 0x4035b3
movb $0x2f, (%r14)
incq %r14
jmp 0x403592
movb $0x0, (%r14)
leaq 0xf4e76(%rip), %r14     # 0x4f8434
leaq 0x540(%rsp), %rsi
movq %r14, %rdi
callq 0x401020
leaq 0x90(%rsp), %rsi
movq %r14, %rdi
callq 0x465030
testl %eax, %eax
js 0x403dee
movl 0xc0(%rsp), %eax
movl %eax, 0xf4e3d(%rip)     # 0x4f8430
movl $0x0, 0xf5257(%rip)     # 0x4f8854
leaq 0xbfa23(%rip), %rsi     # 0x4c3027
leaq 0x540(%rsp), %rdi
callq 0x41cb70
testq %rax, %rax
je 0x403df7
movq %rax, %r15
xorl %r12d, %r12d
movl $0x8800, %esi           # imm = 0x8800
movq %rax, %rdi
xorl %edx, %edx
callq 0x41f5d0
testl %eax, %eax
js 0x403e0a
leaq 0x968(%rsp), %rdi
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
movq %r15, %rcx
callq 0x41cda0
cmpq $0x800, %rax            # imm = 0x800
jne 0x403e13
leaq 0xbfe30(%rip), %rdi     # 0x4c3494
cmpb $0x2, 0x968(%rsp)
jne 0x403e1a
movl $0x30304443, %eax       # imm = 0x30304443
xorl 0x969(%rsp), %eax
movzbl 0x96d(%rsp), %ecx
xorl $0x31, %ecx
orl %eax, %ecx
jne 0x403e1a
movzbl 0x9f4(%rsp), %esi
movzbl 0x9f5(%rsp), %eax
movzbl 0x9f6(%rsp), %ecx
movl 0x9ec(%rsp), %r14d
shll $0x1b, %ecx
shll $0x13, %eax
shll $0xb, %esi
orl %eax, %esi
orl %ecx, %esi
xorl %r12d, %r12d
movq %r15, %rdi
xorl %edx, %edx
callq 0x41f5d0
testl %eax, %eax
js 0x403ebe
movl $0x10010, %edi          # imm = 0x10010
callq 0x42abd0
movq %rax, 0xf4d3c(%rip)     # 0x4f8420
testq %rax, %rax
je 0x403eca
xorl %r12d, %r12d
movl $0x10010, %edx          # imm = 0x10010
movq %rax, %rdi
xorl %esi, %esi
callq 0x4010b8
leal 0x7ff(%r14), %edi
andl $0xfffff800, %edi       # imm = 0xFFFFF800
callq 0x42abd0
testq %rax, %rax
je 0x403ed6
movq %rax, %r13
movq %rbp, 0x78(%rsp)
movl $0x1000, %edi           # imm = 0x1000
callq 0x42abd0
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x403ee2
movl $0x40000, %edi          # imm = 0x40000
callq 0x42abd0
testq %rax, %rax
je 0x403ef3
movq %rax, %r12
movq %r14, 0x88(%rsp)
movl %r14d, %r14d
movl $0x1, %esi
movq %r13, %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0x41cda0
cmpq %r14, %rax
jne 0x403eff
movb $0x0, 0xf4082(%rip)     # 0x4f7800
movq 0xf4c9b(%rip), %rax     # 0x4f8420
movq $0x0, 0x8(%rax)
movq 0x28(%rsp), %rax
addq $0x800, %rax            # imm = 0x800
movq %rax, 0x60(%rsp)
xorl %r14d, %r14d
xorl %ecx, %ecx
movq $0x0, 0x38(%rsp)
movq %r13, 0x8(%rsp)
cmpl 0x88(%rsp), %ecx
jae 0x403f23
movl %ecx, %eax
movzbl (%r13,%rax), %edx
movl %r14d, 0x18(%rsp)
movq %r13, %r14
movzbl 0x1(%r13,%rax), %r13d
shll $0x8, %r13d
movl %edx, 0x6c(%rsp)
orl %edx, %r13d
movl %ecx, %eax
andl $0xfffff800, %eax       # imm = 0xFFFFF800
addl $0x800, %eax            # imm = 0x800
testl %r13d, %r13d
cmovnel %ecx, %eax
leal 0x2(%rax), %ecx
movl (%r14,%rcx), %ecx
movl %ecx, 0x24(%rsp)
leal 0x6(%rax), %ecx
movzwl (%r14,%rcx), %ecx
movl %ecx, 0x14(%rsp)
movl %eax, %ebp
addl $0x8, %ebp
movl $0x400, %edx            # imm = 0x400
leaq 0xf4408(%rip), %rdi     # 0x4f7c20
xorl %esi, %esi
callq 0x4010b8
movq %rbp, 0x48(%rsp)
leaq (%r14,%rbp), %rsi
movl 0x18(%rsp), %r14d
leaq 0xf43ec(%rip), %rdi     # 0x4f7c20
movq %r13, 0x80(%rsp)
movq %r13, %rdx
callq 0x401048
callq 0x4040a7
cmpl $0x1000, %r14d          # imm = 0x1000
jl 0x40386a
leaq 0xbfa15(%rip), %rdi     # 0x4c326e
movl $0x1000, %esi           # imm = 0x1000
xorl %eax, %eax
callq 0x40e0a0
jmp 0x403d35
leaq 0xf3b6f(%rip), %r13     # 0x4f73e0
movq %r13, %rdi
callq 0x4010f8
leaq 0x2(%rax), %rdi
callq 0x42abd0
movq 0xf4b97(%rip), %rcx     # 0x4f8420
movslq %r14d, %rdx
shlq $0x4, %rdx
movq %rax, 0x8(%rcx,%rdx)
testq %rax, %rax
je 0x403d17
leaq (%rcx,%rdx), %rbp
addq $0x8, %rbp
movw $0x2f, (%rax)
movq (%rbp), %rdi
movq %r13, %rsi
callq 0x401060
movl 0x14(%rsp), %eax
movl %eax, -0x8(%rbp)
movl %r14d, %edi
callq 0x4041bc
movb $0x0, 0x120(%rsp)
movl 0x24(%rsp), %r13d
movq %r13, %rsi
shlq $0xb, %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x41f5d0
testl %eax, %eax
js 0x403d20
movl $0x800, %edx            # imm = 0x800
movq 0x60(%rsp), %rdi
xorl %esi, %esi
callq 0x4010b8
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
movq 0x28(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rcx
callq 0x41cda0
cmpq $0x800, %rax            # imm = 0x800
jne 0x403d29
movq %r13, %rcx
cmpb $0x1, 0x20(%rbp)
movq 0x8(%rsp), %r13
jne 0x403d51
cmpb $0x0, 0x21(%rbp)
jne 0x403d51
movslq 0x2(%rbp), %rax
cmpq %rax, %rcx
jne 0x403d51
cmpb $0x2, 0x19(%rbp)
jne 0x403d51
movl 0xa(%rbp), %eax
movl %eax, 0x54(%rsp)
movq $0x0, 0x70(%rsp)
xorl %ebp, %ebp
movl $0x0, 0x14(%rsp)
xorl %r14d, %r14d
xorl %ecx, %ecx
testl %ecx, %ecx
je 0x4039b6
addl $0xfffff800, %r14d      # imm = 0xFFFFF800
movl $0x800, %edx            # imm = 0x800
movq 0x28(%rsp), %rdi
movq 0x60(%rsp), %r13
movq %r13, %rsi
callq 0x401048
movl $0x800, %edx            # imm = 0x800
movq %r13, %rdi
xorl %esi, %esi
callq 0x4010b8
incl 0x24(%rsp)
movl 0x14(%rsp), %edi
addl $0x800, %edi            # imm = 0x800
jmp 0x4039ba
movl 0x14(%rsp), %edi
cmpl 0x54(%rsp), %edi
jge 0x403d90
movslq %r14d, %r13
movq 0x28(%rsp), %rax
movb (%rax,%r13), %al
testb %al, %al
setne %cl
movzbl %al, %eax
addl %r14d, %eax
cmpl $0x801, %eax            # imm = 0x801
setge %al
andb %cl, %al
xorl %ecx, %ecx
cmpb $0x1, %al
jne 0x403a50
movl %r14d, 0x14(%rsp)
movl %edi, %r14d
leaq 0xbf9ce(%rip), %rdi     # 0x4c33c8
callq 0x41d320
movl 0x24(%rsp), %eax
movl %eax, %esi
shll $0xb, %esi
addl $0x800, %esi            # imm = 0x800
movq %r15, %rdi
xorl %edx, %edx
callq 0x41f5d0
testl %eax, %eax
js 0x403da4
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
movq 0x60(%rsp), %rdi
movq %r15, %rcx
callq 0x41cda0
movl $0x1, %ecx
cmpq $0x800, %rax            # imm = 0x800
movl %r14d, %edi
movl 0x14(%rsp), %r14d
jne 0x403dad
movl %ecx, 0x34(%rsp)
movq 0x28(%rsp), %rax
leaq (%rax,%r13), %rsi
movb (%rsi), %al
testb %al, %al
sete %cl
cmpl $0x701, %r13d           # imm = 0x701
setl %dl
testb %dl, %cl
jne 0x403d90
testb %al, %al
sete %al
testl %r14d, %r14d
setne %cl
andb %al, %cl
cmpl $0x800, %r14d           # imm = 0x800
sete %al
orb %cl, %al
cmpb $0x1, %al
jne 0x403b3c
addl $0x800, %edi            # imm = 0x800
cmpl 0x54(%rsp), %edi
jge 0x403d90
movq %rbp, %r14
movl %edi, %r13d
movl 0x24(%rsp), %eax
incl %eax
movl %eax, 0x24(%rsp)
movl %eax, %esi
shlq $0xb, %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x41f5d0
testl %eax, %eax
js 0x403da4
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
movq 0x28(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rcx
callq 0x41cda0
cmpq $0x800, %rax            # imm = 0x800
jne 0x403dad
movl $0x800, %edx            # imm = 0x800
movq 0x60(%rsp), %rdi
xorl %esi, %esi
callq 0x4010b8
cmpb $0x0, (%rbp)
je 0x403d90
cmpb $0x1, 0x20(%rbp)
jne 0x403b30
cmpb $0x0, 0x21(%rbp)
movq %rbp, %rsi
movl %r13d, %edi
movq %r14, %rbp
movl $0x0, %r14d
jne 0x403b3c
jmp 0x403d90
movq %rbp, %rsi
movl %r13d, %edi
movq %r14, %rbp
xorl %r14d, %r14d
movzbl 0x20(%rsi), %ecx
cmpl $0x2, %ecx
movq %rsi, 0x58(%rsp)
movl %edi, 0x14(%rsp)
jb 0x403bf9
cmpb $0x2, 0x19(%rsi)
je 0x403bf9
movq %rbp, 0x40(%rsp)
leal -0x1(%rcx), %eax
cmpb $0x31, 0x21(%rsi,%rax)
jne 0x403c01
leaq 0x21(%rsi), %rax
cmpb $0x3b, -0x3(%rcx,%rax)
jne 0x403c01
movq %rax, %r13
movq %rcx, %rbp
movl $0x400, %edx            # imm = 0x400
leaq 0xf4090(%rip), %rdi     # 0x4f7c20
xorl %esi, %esi
callq 0x4010b8
movl %ebp, %edx
leaq 0xf4080(%rip), %rdi     # 0x4f7c20
movq %r13, %rsi
callq 0x401048
callq 0x4040a7
cmpb $0x0, 0x120(%rsp)
je 0x403c0b
leaq 0xf3822(%rip), %rdi     # 0x4f73e0
leaq 0x120(%rsp), %rsi
callq 0x4010c8
testl %eax, %eax
movq 0x40(%rsp), %rbp
jne 0x403dc2
movq 0x58(%rsp), %rdx
movl 0xa(%rdx), %eax
addq %rax, %rbp
xorl %eax, %eax
cmpb 0x19(%rdx), %al
movl 0x34(%rsp), %ecx
jno 0x403c3c
movzbl (%rdx), %eax
addl %eax, %r14d
jmp 0x403975
movq %rbp, %r13
jmp 0x403d00
movq 0x40(%rsp), %r13
jmp 0x403d00
movq 0x58(%rsp), %rcx
movl 0x2(%rcx), %eax
movq %rax, 0x70(%rsp)
movl 0xa(%rcx), %r13d
xorl %eax, %eax
cmpb 0x19(%rcx), %al
jno 0x403c47
leaq 0x120(%rsp), %rdi
leaq 0xf37ae(%rip), %rsi     # 0x4f73e0
callq 0x401020
jmp 0x403d00
movq %rbp, %r13
movb $0x0, 0x120(%rsp)
leaq 0xf3792(%rip), %rbp     # 0x4f73e0
movq %rbp, %rdi
callq 0x4010f8
addl $-0x2, %eax
cltq
movb $0x0, (%rax,%rbp)
leaq 0xf3b9a(%rip), %rdi     # 0x4f7800
callq 0x4010f8
movq %rax, 0x40(%rsp)
cmpw $0x2f, 0xf3b88(%rip)    # 0x4f7800
je 0x403c8f
leaq 0xf3b7f(%rip), %rbp     # 0x4f7800
movq %rbp, %rdi
callq 0x4010f8
movw $0x2f, (%rax,%rbp)
leaq 0xf3b6a(%rip), %rdi     # 0x4f7800
leaq 0xf3743(%rip), %rsi     # 0x4f73e0
callq 0x401060
movl (%rbx), %eax
incl %eax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
movq 0x38(%rsp), %rdi
callq 0x42b260
movq %rax, %rbp
movl (%rbx), %ecx
leaq (%rcx,%rcx,2), %rdx
movq 0x70(%rsp), %rcx
movl %ecx, 0x8(%rax,%rdx,8)
movq %r13, 0x10(%rax,%rdx,8)
leaq 0xf3b2a(%rip), %rdi     # 0x4f7800
callq 0x4034b8
movl (%rbx), %ecx
leaq (%rcx,%rcx,2), %rdx
movq %rbp, 0x38(%rsp)
movq %rax, (%rbp,%rdx,8)
leal 0x1(%rcx), %eax
movl %eax, (%rbx)
movslq 0x40(%rsp), %rax
leaq 0xf3b04(%rip), %rcx     # 0x4f7800
movb $0x0, (%rax,%rcx)
movq 0x58(%rsp), %rax
movzbl (%rax), %eax
addl %eax, %r14d
movq %r13, %rbp
movl 0x34(%rsp), %ecx
jmp 0x403975
leaq 0xbf681(%rip), %rdi     # 0x4c339f
jmp 0x403d30
leaq 0xbf711(%rip), %rdi     # 0x4c3438
jmp 0x403d30
leaq 0xbf6df(%rip), %rdi     # 0x4c340f
callq 0x41d320
movl $0x2, %edx
movq 0x48(%rsp), %rcx
movq 0x8(%rsp), %r13
testl %edx, %edx
je 0x4037b0
jmp 0x403f10
xorl %ebp, %ebp
leaq 0xbf530(%rip), %rdi     # 0x4c328a
movl 0x24(%rsp), %esi
xorl %eax, %eax
callq 0x40e0a0
movl $0x2, %edx
testb %bpl, %bpl
movq 0x48(%rsp), %rcx
je 0x403d44
movl 0x6c(%rsp), %edx
andl $0x1, %edx
movq 0x80(%rsp), %rax
addl %edx, %eax
addl %ecx, %eax
incl %r14d
xorl %edx, %edx
movl %eax, %ecx
jmp 0x403d44
movq 0x8(%rsp), %r13
movl 0x18(%rsp), %r14d
movl $0x9, %edx
movb $0x1, %bpl
jmp 0x403d6a
leaq 0xbf68d(%rip), %rdi     # 0x4c3438
jmp 0x403db4
leaq 0xbf65b(%rip), %rdi     # 0x4c340f
callq 0x41d320
movl $0x2, %edx
xorl %ebp, %ebp
jmp 0x403ddf
xorl %ebp, %ebp
leaq 0xbf4ee(%rip), %rdi     # 0x4c32b9
leaq 0x120(%rsp), %rsi
xorl %eax, %eax
callq 0x40e0a0
movl $0x2, %edx
movq 0x8(%rsp), %r13
movl 0x18(%rsp), %r14d
jmp 0x403d6a
leaq 0xbf71f(%rip), %rdi     # 0x4c3514
jmp 0x403dfe
leaq 0xbf4ef(%rip), %rdi     # 0x4c32ed
callq 0x41d320
movb $-0x1, %bl
jmp 0x403eaa
leaq 0xbf6e1(%rip), %rdi     # 0x4c34f2
jmp 0x403e1d
leaq 0xbf6b7(%rip), %rdi     # 0x4c34d1
xorl %r12d, %r12d
xorl %ebx, %ebx
xorl %r13d, %r13d
callq 0x41d320
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq %r15, %rdi
callq 0x41c5d0
testq %r13, %r13
je 0x403e42
movq %r13, %rdi
callq 0x42af10
testq %rbx, %rbx
je 0x403e4f
movq %rbx, %rdi
callq 0x42af10
testq %r12, %r12
je 0x403e5c
movq %r12, %rdi
callq 0x42af10
testl %r14d, %r14d
js 0x403e97
movq 0xf45b8(%rip), %rbx     # 0x4f8420
movl %r14d, %r14d
shlq $0x4, %r14
addq $0x10, %r14
xorl %r15d, %r15d
movq 0x8(%rbx,%r15), %rdi
testq %rdi, %rdi
je 0x403e8e
callq 0x42af10
movq $0x0, 0x8(%rbx,%r15)
addq $0x10, %r15
cmpq %r15, %r14
jne 0x403e76
movq 0xf4582(%rip), %rdi     # 0x4f8420
movb $-0x1, %bl
testq %rdi, %rdi
je 0x403eaa
callq 0x42af10
movl %ebx, %eax
addq $0x1168, %rsp           # imm = 0x1168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbf5b2(%rip), %rdi     # 0x4c3477
jmp 0x403e1d
leaq 0xbf453(%rip), %rdi     # 0x4c3324
jmp 0x403e1a
leaq 0xbf469(%rip), %rdi     # 0x4c3346
jmp 0x403e1d
leaq 0xbf47a(%rip), %rdi     # 0x4c3363
xorl %r12d, %r12d
xorl %ebx, %ebx
jmp 0x403e22
leaq 0xbf487(%rip), %rdi     # 0x4c3381
xorl %r12d, %r12d
jmp 0x403f06
leaq 0xbf555(%rip), %rdi     # 0x4c345b
movq 0x28(%rsp), %rbx
jmp 0x403e22
cmpl $0x2, %edx
jne 0x4040a2
movq 0x28(%rsp), %rbx
jmp 0x403e2d
movq %r15, %rdi
callq 0x41c5d0
movq %r13, %rdi
callq 0x42af10
movq 0x28(%rsp), %rdi
callq 0x42af10
movq %r12, %rdi
callq 0x42af10
testl %r14d, %r14d
movq 0x78(%rsp), %r13
js 0x403f85
movq 0xf44ca(%rip), %r15     # 0x4f8420
movl %r14d, %r14d
shlq $0x4, %r14
addq $0x10, %r14
xorl %r12d, %r12d
movq 0x8(%r15,%r12), %rdi
testq %rdi, %rdi
je 0x403f7c
callq 0x42af10
movq $0x0, 0x8(%r15,%r12)
addq $0x10, %r12
cmpq %r12, %r14
jne 0x403f64
movq 0xf4494(%rip), %rdi     # 0x4f8420
testq %rdi, %rdi
je 0x403f96
callq 0x42af10
movl (%rbx), %r12d
leaq (,%r12,8), %rax
leaq (%rax,%rax,2), %rdi
callq 0x42abd0
movq %rax, (%r13)
testq %r12, %r12
movq 0x38(%rsp), %r13
je 0x404061
leaq 0x8(%r13), %rax
movq %rax, 0x18(%rsp)
xorl %r15d, %r15d
xorl %ebp, %ebp
movq 0x78(%rsp), %r14
cmpl $0x1, %r12d
adcl $0x0, %r12d
movq 0x18(%rsp), %rax
xorl %ecx, %ecx
movl %ebp, %edx
movl (%rax), %esi
movl %edx, %edi
leaq (%rdi,%rdi,2), %rdi
movl %ecx, %ebp
cmpl 0x8(%r13,%rdi,8), %esi
jb 0x403ff3
movl %edx, %ebp
incq %rcx
addq $0x18, %rax
movl %ebp, %edx
cmpq %rcx, %r12
jne 0x403fe0
movl %ebp, %eax
leaq (%rax,%rax,2), %r12
movq 0x10(%r13,%r12,8), %rax
movq (%r14), %rcx
leaq (,%r15,8), %rdx
leaq (%rdx,%rdx,2), %r13
movq %rax, 0x10(%rcx,%r13)
movq 0x38(%rsp), %rax
movl 0x8(%rax,%r12,8), %eax
movl %eax, 0x8(%rcx,%r13)
movq 0x38(%rsp), %rax
movq (%rax,%r12,8), %rdi
callq 0x4034b8
movq (%r14), %rcx
movq %rax, (%rcx,%r13)
movq 0x38(%rsp), %r13
movl $0xffffffff, 0x8(%r13,%r12,8) # imm = 0xFFFFFFFF
incq %r15
movl (%rbx), %r12d
cmpq %r12, %r15
jb 0x403fcf
cmpl $0x0, (%rbx)
je 0x40408e
xorl %r14d, %r14d
movq %r13, %r15
movq (%r15), %rdi
testq %rdi, %rdi
je 0x404080
callq 0x42af10
movq $0x0, (%r15)
incq %r14
movl (%rbx), %eax
addq $0x18, %r15
cmpq %rax, %r14
jb 0x40406c
testq %r13, %r13
je 0x40409b
movq %r13, %rdi
callq 0x42af10
xorl %ebx, %ebx
jmp 0x403eaa
jmp 0x403eaa