// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x15b0, %rsp           # imm = 0x15B0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movq $0x0, -0xc0(%rbp)
movl $0x0, -0x904(%rbp)
leaq -0x4e0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x401020
movq $0x0, -0x910(%rbp)
movq $0x0, -0x918(%rbp)
movq $0x0, -0x920(%rbp)
movl $0xffffffff, -0x112c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x1134(%rbp)
movq $0x0, 0xf4cea(%rip) # 0x4f9420
movq $0x0, 0xf4ce7(%rip) # 0x4f9428
movq $0x0, 0xf4ce4(%rip) # 0x4f9430
movl $0x0, 0xf4ce2(%rip)     # 0x4f9438
leaq -0x4e0(%rbp), %rdi
callq 0x405880
leaq -0x4e0(%rbp), %rdi
callq 0x4010f0
movl %eax, -0xb4(%rbp)
leaq -0x4e0(%rbp), %rdx
leaq 0xf4cbe(%rip), %rdi     # 0x4f9440
addq $0x4, %rdi
leaq 0xbf91e(%rip), %rsi     # 0x4c40ab
movb $0x0, %al
callq 0x410050
leaq 0xf4ca5(%rip), %rdi     # 0x4f9440
addq $0x4, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x466d70
cmpl $0x0, %eax
jge 0x4047c7
leaq 0xbfab7(%rip), %rdi     # 0x4c426e
movb $0x0, %al
callq 0x40ff80
movb $-0x1, -0x1(%rbp)
jmp 0x405874
movq -0x80(%rbp), %rax
movl %eax, 0xf4c6f(%rip)     # 0x4f9440
movl $0x0, 0xf5089(%rip)     # 0x4f9864
leaq -0x4e0(%rbp), %rdi
leaq 0xbf858(%rip), %rsi     # 0x4c4041
callq 0x41ea50
movq %rax, -0x1148(%rbp)
cmpq $0x0, -0x1148(%rbp)
jne 0x404816
leaq 0xbfaa0(%rip), %rdi     # 0x4c42a6
movb $0x0, %al
callq 0x40ff80
movb $-0x1, -0x1(%rbp)
jmp 0x405874
movq -0x1148(%rbp), %rdi
movl $0x8800, %esi           # imm = 0x8800
xorl %edx, %edx
callq 0x421310
cmpl $0x0, %eax
jge 0x404841
leaq 0xbfaa9(%rip), %rdi     # 0x4c42de
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movq -0x1148(%rbp), %rcx
leaq -0x1120(%rbp), %rdi
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x41ec80
cmpq $0x800, %rax            # imm = 0x800
je 0x404879
leaq 0xbfa94(%rip), %rdi     # 0x4c4301
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movzbl -0x1120(%rbp), %eax
cmpl $0x2, %eax
jne 0x4048a6
leaq -0x1120(%rbp), %rdi
addq $0x1, %rdi
leaq 0xbfa8c(%rip), %rsi     # 0x4c4323
movl $0x5, %edx
callq 0x401080
cmpl $0x0, %eax
je 0x4048b9
leaq 0xbfa7c(%rip), %rdi     # 0x4c4329
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
leaq -0x1120(%rbp), %rdi
addq $0x8c, %rdi
callq 0x405960
movl %eax, -0x1138(%rbp)
leaq -0x1120(%rbp), %rdi
addq $0x84, %rdi
callq 0x4059b0
movl %eax, -0x113c(%rbp)
movq -0x1148(%rbp), %rdi
movl -0x1138(%rbp), %eax
shll $0xb, %eax
movl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x421310
cmpl $0x0, %eax
jge 0x40491e
leaq 0xbfa55(%rip), %rdi     # 0x4c4367
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movl $0x10010, %edi          # imm = 0x10010
callq 0x42c910
movq %rax, 0xf4af1(%rip)     # 0x4f9420
cmpq $0x0, 0xf4ae9(%rip)     # 0x4f9420
jne 0x40494c
leaq 0xbfa45(%rip), %rdi     # 0x4c4385
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movq 0xf4acd(%rip), %rdi     # 0x4f9420
xorl %esi, %esi
movl $0x10010, %edx          # imm = 0x10010
callq 0x4010b0
movl -0x113c(%rbp), %eax
addl $0x7ff, %eax            # imm = 0x7FF
shrl $0xb, %eax
shll $0xb, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x42c910
movq %rax, -0x910(%rbp)
cmpq $0x0, -0x910(%rbp)
jne 0x40499d
leaq 0xbfa17(%rip), %rdi     # 0x4c43a8
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movl $0x1000, %edi           # imm = 0x1000
callq 0x42c910
movq %rax, -0x918(%rbp)
cmpq $0x0, -0x918(%rbp)
jne 0x4049cb
leaq 0xbfa07(%rip), %rdi     # 0x4c43c6
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movl $0x40000, %edi          # imm = 0x40000
callq 0x42c910
movq %rax, -0x920(%rbp)
cmpq $0x0, -0x920(%rbp)
jne 0x4049f9
leaq 0xbf9f8(%rip), %rdi     # 0x4c43e5
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movq -0x910(%rbp), %rdi
movl -0x113c(%rbp), %eax
movl %eax, %edx
movq -0x1148(%rbp), %rcx
movl $0x1, %esi
callq 0x41ec80
movl -0x113c(%rbp), %ecx
cmpq %rcx, %rax
je 0x404a37
leaq 0xbf9d9(%rip), %rdi     # 0x4c4404
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movb $0x0, 0xf3dc2(%rip)     # 0x4f8800
movq $0x0, 0xf49df(%rip) # 0x4f9428
movq $0x0, 0xf49dc(%rip) # 0x4f9430
movl $0x0, 0xf49da(%rip)     # 0x4f9438
movl $0x0, -0x112c(%rbp)
movq 0xf49b1(%rip), %rax     # 0x4f9420
movslq -0x112c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movl -0x1134(%rbp), %eax
cmpl -0x113c(%rbp), %eax
jae 0x40542d
movq -0x910(%rbp), %rdi
movl -0x1134(%rbp), %eax
addq %rax, %rdi
callq 0x4059d0
movl %eax, -0x114c(%rbp)
cmpl $0x0, -0x114c(%rbp)
jne 0x404ad2
movl -0x1134(%rbp), %eax
shrl $0xb, %eax
shll $0xb, %eax
addl $0x800, %eax            # imm = 0x800
movl %eax, -0x1134(%rbp)
movl -0x1134(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x1134(%rbp)
movq -0x910(%rbp), %rdi
movl -0x1134(%rbp), %eax
addq %rax, %rdi
callq 0x405960
movl %eax, -0x1130(%rbp)
movl -0x1134(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x1134(%rbp)
movq -0x910(%rbp), %rdi
movl -0x1134(%rbp), %eax
addq %rax, %rdi
callq 0x4059d0
movl %eax, -0x1150(%rbp)
movl -0x1134(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x1134(%rbp)
leaq 0xf40e4(%rip), %rdi     # 0x4f8c20
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x4010b0
movq -0x910(%rbp), %rsi
movl -0x1134(%rbp), %eax
addq %rax, %rsi
movl -0x114c(%rbp), %eax
movl %eax, %edx
leaq 0xf40b9(%rip), %rdi     # 0x4f8c20
callq 0x401040
leaq 0xf40ad(%rip), %rdi     # 0x4f8c20
leaq 0xf3866(%rip), %rsi     # 0x4f83e0
callq 0x405a00
cmpl $0x1000, -0x112c(%rbp)  # imm = 0x1000
jl 0x404ba3
leaq 0xbf88f(%rip), %rdi     # 0x4c4421
movl $0x1000, %esi           # imm = 0x1000
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
leaq 0xf3836(%rip), %rdi     # 0x4f83e0
callq 0x4010f0
movq %rax, %rdi
addq $0x2, %rdi
callq 0x42c910
movq %rax, %rcx
movq 0xf485b(%rip), %rax     # 0x4f9420
movslq -0x112c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq 0xf4842(%rip), %rax     # 0x4f9420
movslq -0x112c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
jne 0x404c06
leaq 0xbf843(%rip), %rdi     # 0x4c443d
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movq 0xf4813(%rip), %rax     # 0x4f9420
movslq -0x112c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
leaq 0xc6ef6(%rip), %rsi     # 0x4cbb1c
callq 0x401020
movq 0xf47ee(%rip), %rax     # 0x4f9420
movslq -0x112c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
leaq 0xf3795(%rip), %rsi     # 0x4f83e0
callq 0x401058
movl -0x1150(%rbp), %ecx
movq 0xf47c3(%rip), %rax     # 0x4f9420
movslq -0x112c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x112c(%rbp), %esi
leaq 0xf3b86(%rip), %rdi     # 0x4f8800
callq 0x406070
leaq -0x900(%rbp), %rdi
leaq 0xf3b73(%rip), %rsi     # 0x4f8800
callq 0x401058
movslq -0x904(%rbp), %rax
movb $0x0, -0x900(%rbp,%rax)
movl $0x0, -0x1154(%rbp)
movq $0x0, -0x1160(%rbp)
movb $0x0, -0x1580(%rbp)
movl $0x0, -0x1584(%rbp)
movl $0x0, -0x1588(%rbp)
movq -0x1148(%rbp), %rdi
movl -0x1130(%rbp), %eax
movl %eax, %esi
shlq $0xb, %rsi
xorl %edx, %edx
callq 0x421310
cmpl $0x0, %eax
jge 0x404d03
leaq 0xbf770(%rip), %rdi     # 0x4c4467
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movq -0x918(%rbp), %rdi
addq $0x800, %rdi            # imm = 0x800
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x4010b0
movq -0x918(%rbp), %rdi
movq -0x1148(%rbp), %rcx
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x41ec80
cmpq $0x800, %rax            # imm = 0x800
je 0x404d55
leaq 0xbf742(%rip), %rdi     # 0x4c448b
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movl $0x0, -0x158c(%rbp)
cmpl $0x0, -0x1584(%rbp)
jne 0x404e15
movq -0x918(%rbp), %rax
movslq -0x158c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x1128(%rbp)
movq -0x1128(%rbp), %rax
movzbl 0x20(%rax), %eax
cmpl $0x1, %eax
jne 0x404dfa
movq -0x1128(%rbp), %rax
movzbl 0x21(%rax), %eax
cmpl $0x0, %eax
jne 0x404dfa
movl -0x1130(%rbp), %eax
movq %rax, -0x15a8(%rbp)
movq -0x1128(%rbp), %rdi
addq $0x2, %rdi
callq 0x405960
movl %eax, %ecx
movq -0x15a8(%rbp), %rax
movslq %ecx, %rcx
cmpq %rcx, %rax
jne 0x404dfa
movq -0x1128(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x2, %eax
jne 0x404dfa
movq -0x1128(%rbp), %rdi
addq $0xa, %rdi
callq 0x4059b0
movl %eax, -0x1588(%rbp)
jmp 0x404e13
movl -0x1130(%rbp), %esi
leaq 0xbf6ae(%rip), %rdi     # 0x4c44b5
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
jmp 0x404e15
movl $0x0, -0x1590(%rbp)
cmpl $0x0, -0x1590(%rbp)
je 0x404e9c
movl $0x0, -0x1590(%rbp)
movl -0x158c(%rbp), %eax
subl $0x800, %eax            # imm = 0x800
movl %eax, -0x158c(%rbp)
movq -0x918(%rbp), %rdi
movq -0x918(%rbp), %rsi
addq $0x800, %rsi            # imm = 0x800
movl $0x800, %edx            # imm = 0x800
callq 0x401040
movq -0x918(%rbp), %rdi
addq $0x800, %rdi            # imm = 0x800
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x4010b0
movl -0x1130(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1130(%rbp)
movl -0x1584(%rbp), %eax
addl $0x800, %eax            # imm = 0x800
movl %eax, -0x1584(%rbp)
movl -0x1584(%rbp), %eax
cmpl -0x1588(%rbp), %eax
jl 0x404eaf
jmp 0x4053ea
movq -0x918(%rbp), %rax
movslq -0x158c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x1128(%rbp)
movq -0x1128(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x404f84
movq -0x1128(%rbp), %rax
movzbl (%rax), %eax
addl -0x158c(%rbp), %eax
cmpl $0x800, %eax            # imm = 0x800
jle 0x404f84
leaq 0xbf5e8(%rip), %rdi     # 0x4c44e4
movb $0x0, %al
callq 0x40ff80
movq -0x1148(%rbp), %rdi
movl -0x1130(%rbp), %eax
shll $0xb, %eax
addl $0x800, %eax            # imm = 0x800
movl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x421310
cmpl $0x0, %eax
jge 0x404f3b
leaq 0xbf538(%rip), %rdi     # 0x4c4467
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movq -0x918(%rbp), %rdi
addq $0x800, %rdi            # imm = 0x800
movq -0x1148(%rbp), %rcx
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x41ec80
cmpq $0x800, %rax            # imm = 0x800
je 0x404f7a
leaq 0xbf51d(%rip), %rdi     # 0x4c448b
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movl $0x1, -0x1590(%rbp)
movq -0x1128(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x404faa
movl $0x800, %eax            # imm = 0x800
subl -0x158c(%rbp), %eax
cmpl $0xff, %eax
jle 0x404faa
jmp 0x4053ea
movq -0x1128(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x404fc2
cmpl $0x0, -0x158c(%rbp)
jne 0x404fd2
cmpl $0x800, -0x158c(%rbp)   # imm = 0x800
jne 0x4050de
movl -0x1130(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1130(%rbp)
movl -0x1584(%rbp), %eax
addl $0x800, %eax            # imm = 0x800
movl %eax, -0x1584(%rbp)
movl -0x1584(%rbp), %eax
cmpl -0x1588(%rbp), %eax
jl 0x405005
jmp 0x4053ea
movq -0x1148(%rbp), %rdi
movl -0x1130(%rbp), %eax
movl %eax, %esi
shlq $0xb, %rsi
xorl %edx, %edx
callq 0x421310
cmpl $0x0, %eax
jge 0x405037
leaq 0xbf43c(%rip), %rdi     # 0x4c4467
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movq -0x918(%rbp), %rdi
movq -0x1148(%rbp), %rcx
movl $0x1, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x41ec80
cmpq $0x800, %rax            # imm = 0x800
je 0x40506f
leaq 0xbf428(%rip), %rdi     # 0x4c448b
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movq -0x918(%rbp), %rdi
addq $0x800, %rdi            # imm = 0x800
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x4010b0
movl $0x0, -0x158c(%rbp)
movq -0x918(%rbp), %rax
movslq -0x158c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x1128(%rbp)
movq -0x1128(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x4050d7
movq -0x1128(%rbp), %rax
movzbl 0x20(%rax), %eax
cmpl $0x1, %eax
jne 0x4050dc
movq -0x1128(%rbp), %rax
cmpb $0x0, 0x21(%rax)
jne 0x4050dc
jmp 0x4053ea
jmp 0x4050de
movq -0x1128(%rbp), %rax
movzbl 0x20(%rax), %eax
cmpl $0x1, %eax
jle 0x4053cf
movq -0x1128(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x2, %eax
je 0x4053cf
movq -0x1128(%rbp), %rax
movq -0x1128(%rbp), %rcx
movzbl 0x20(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl 0x21(%rax,%rcx), %eax
cmpl $0x31, %eax
jne 0x4053cf
movq -0x1128(%rbp), %rax
movq -0x1128(%rbp), %rcx
movzbl 0x20(%rcx), %ecx
subl $0x3, %ecx
movslq %ecx, %rcx
movzbl 0x21(%rax,%rcx), %eax
cmpl $0x3b, %eax
jne 0x4053cf
leaq 0xf3ac7(%rip), %rdi     # 0x4f8c20
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x4010b0
movq -0x1128(%rbp), %rsi
addq $0x21, %rsi
movq -0x1128(%rbp), %rax
movzbl 0x20(%rax), %eax
movl %eax, %edx
leaq 0xf3a9c(%rip), %rdi     # 0x4f8c20
callq 0x401040
leaq 0xf3a90(%rip), %rdi     # 0x4f8c20
leaq 0xf3249(%rip), %rsi     # 0x4f83e0
callq 0x405a00
cmpb $0x0, -0x1580(%rbp)
je 0x405231
leaq -0x1580(%rbp), %rsi
leaq 0xf3229(%rip), %rdi     # 0x4f83e0
callq 0x4010c0
cmpl $0x0, %eax
je 0x4051db
leaq -0x1580(%rbp), %rsi
leaq 0xbf35d(%rip), %rdi     # 0x4c452c
movb $0x0, %al
callq 0x40ff80
jmp 0x405756
movq -0x1128(%rbp), %rdi
addq $0xa, %rdi
callq 0x4059b0
movl %eax, %eax
addq -0x1160(%rbp), %rax
movq %rax, -0x1160(%rbp)
movq -0x1128(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x80, %eax
jne 0x405228
movq -0x1128(%rbp), %rax
movzbl (%rax), %eax
addl -0x158c(%rbp), %eax
movl %eax, -0x158c(%rbp)
jmp 0x404e1f
movb $0x0, -0x1580(%rbp)
jmp 0x4052a2
movq -0x1128(%rbp), %rdi
addq $0x2, %rdi
callq 0x4059b0
movl %eax, -0x1154(%rbp)
movq -0x1128(%rbp), %rdi
addq $0xa, %rdi
callq 0x4059b0
movl %eax, %eax
movq %rax, -0x1160(%rbp)
movq -0x1128(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x80, %eax
jne 0x4052a0
leaq -0x1580(%rbp), %rdi
leaq 0xf3160(%rip), %rsi     # 0x4f83e0
callq 0x401020
movq -0x1128(%rbp), %rax
movzbl (%rax), %eax
addl -0x158c(%rbp), %eax
movl %eax, -0x158c(%rbp)
jmp 0x404e1f
jmp 0x4052a2
leaq 0xf3137(%rip), %rdi     # 0x4f83e0
callq 0x4010f0
movl %eax, -0x1594(%rbp)
movl -0x1594(%rbp), %eax
subl $0x2, %eax
movslq %eax, %rcx
leaq 0xf3119(%rip), %rax     # 0x4f83e0
movb $0x0, (%rax,%rcx)
leaq 0xf352e(%rip), %rdi     # 0x4f8800
callq 0x4010f0
movl %eax, -0x1594(%rbp)
leaq 0xf351c(%rip), %rdi     # 0x4f8800
leaq 0xc6831(%rip), %rsi     # 0x4cbb1c
callq 0x4010c0
cmpl $0x0, %eax
je 0x405308
leaq 0xf3504(%rip), %rdi     # 0x4f8800
leaq 0xc6819(%rip), %rsi     # 0x4cbb1c
callq 0x401058
leaq 0xf34f1(%rip), %rdi     # 0x4f8800
leaq 0xf30ca(%rip), %rsi     # 0x4f83e0
callq 0x401058
movq -0xc0(%rbp), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movl %eax, %eax
imulq $0x18, %rax, %rsi
callq 0x42cfa0
movq %rax, -0xc0(%rbp)
movl -0x1154(%rbp), %ecx
movq -0xc0(%rbp), %rax
movq -0x20(%rbp), %rdx
movl (%rdx), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0x1160(%rbp), %rcx
movq -0xc0(%rbp), %rax
movq -0x20(%rbp), %rdx
movl (%rdx), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
leaq 0xf3480(%rip), %rdi     # 0x4f8800
callq 0x404620
movq %rax, %rcx
movq -0xc0(%rbp), %rax
movq -0x20(%rbp), %rdx
movl (%rdx), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movslq -0x904(%rbp), %rax
movb $0x0, -0x900(%rbp,%rax)
movslq -0x1594(%rbp), %rcx
leaq 0xf3435(%rip), %rax     # 0x4f8800
movb $0x0, (%rax,%rcx)
movq -0x1128(%rbp), %rax
movzbl (%rax), %eax
addl -0x158c(%rbp), %eax
movl %eax, -0x158c(%rbp)
jmp 0x404e1f
movl -0x114c(%rbp), %eax
addl -0x1134(%rbp), %eax
movl %eax, -0x1134(%rbp)
movl -0x114c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x405419
movl -0x1134(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1134(%rbp)
movl -0x112c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x112c(%rbp)
jmp 0x404a85
cmpq $0x0, -0x1148(%rbp)
je 0x405443
movq -0x1148(%rbp), %rdi
callq 0x41e4b0
cmpl $0x0, 0xf3fee(%rip)     # 0x4f9438
je 0x40546d
cmpq $0x0, 0xf3fd4(%rip)     # 0x4f9428
je 0x40546d
movq 0xf3fcb(%rip), %rdi     # 0x4f9428
callq 0x41e4b0
movq $0x0, 0xf3fbb(%rip) # 0x4f9428
cmpq $0x0, -0x910(%rbp)
je 0x405483
movq -0x910(%rbp), %rdi
callq 0x42cc50
cmpq $0x0, -0x918(%rbp)
je 0x405499
movq -0x918(%rbp), %rdi
callq 0x42cc50
cmpq $0x0, -0x920(%rbp)
je 0x4054af
movq -0x920(%rbp), %rdi
callq 0x42cc50
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0x112c(%rbp), %eax
jg 0x405531
movq 0xf3f52(%rip), %rax     # 0x4f9420
movslq -0xb4(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x40551e
movq 0xf3f36(%rip), %rax     # 0x4f9420
movslq -0xb4(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x42cc50
movq 0xf3f18(%rip), %rax     # 0x4f9420
movslq -0xb4(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
jmp 0x405520
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x4054b9
cmpq $0x0, 0xf3ee7(%rip)     # 0x4f9420
je 0x405547
movq 0xf3ede(%rip), %rdi     # 0x4f9420
callq 0x42cc50
movq -0x20(%rbp), %rax
movl (%rax), %eax
imulq $0x18, %rax, %rdi
callq 0x42c910
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x15a0(%rbp)
movl $0x0, -0x159c(%rbp)
movl -0x159c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x4056b0
movl $0x0, -0x1598(%rbp)
movl -0x1598(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x4055ed
movq -0xc0(%rbp), %rax
movl -0x1598(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0xc0(%rbp), %rcx
movl -0x15a0(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jae 0x4055da
movl -0x1598(%rbp), %eax
movl %eax, -0x15a0(%rbp)
jmp 0x4055dc
movl -0x1598(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1598(%rbp)
jmp 0x405590
movq -0xc0(%rbp), %rax
movl -0x15a0(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x159c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movq -0xc0(%rbp), %rax
movl -0x15a0(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x159c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0xc0(%rbp), %rax
movl -0x15a0(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x404620
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl -0x159c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0xc0(%rbp), %rax
movl -0x15a0(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
movl -0x159c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x159c(%rbp)
jmp 0x405574
movl $0x0, -0x159c(%rbp)
movl -0x159c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x40572c
movq -0xc0(%rbp), %rax
movl -0x159c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x405719
movq -0xc0(%rbp), %rax
movl -0x159c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x42cc50
movq -0xc0(%rbp), %rax
movl -0x159c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq $0x0, (%rax)
jmp 0x40571b
movl -0x159c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x159c(%rbp)
jmp 0x4056ba
cmpq $0x0, -0xc0(%rbp)
je 0x40574d
movq -0xc0(%rbp), %rdi
callq 0x42cc50
movq $0x0, -0xc0(%rbp)
movb $0x0, -0x1(%rbp)
jmp 0x405874
cmpq $0x0, -0x1148(%rbp)
je 0x40576c
movq -0x1148(%rbp), %rdi
callq 0x41e4b0
cmpl $0x0, 0xf3cc5(%rip)     # 0x4f9438
je 0x405796
cmpq $0x0, 0xf3cab(%rip)     # 0x4f9428
je 0x405796
movq 0xf3ca2(%rip), %rdi     # 0x4f9428
callq 0x41e4b0
movq $0x0, 0xf3c92(%rip) # 0x4f9428
cmpq $0x0, -0x910(%rbp)
je 0x4057ac
movq -0x910(%rbp), %rdi
callq 0x42cc50
cmpq $0x0, -0x918(%rbp)
je 0x4057c2
movq -0x918(%rbp), %rdi
callq 0x42cc50
cmpq $0x0, -0x920(%rbp)
je 0x4057d8
movq -0x920(%rbp), %rdi
callq 0x42cc50
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0x112c(%rbp), %eax
jg 0x40585a
movq 0xf3c29(%rip), %rax     # 0x4f9420
movslq -0xb4(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x405847
movq 0xf3c0d(%rip), %rax     # 0x4f9420
movslq -0xb4(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x42cc50
movq 0xf3bef(%rip), %rax     # 0x4f9420
movslq -0xb4(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
jmp 0x405849
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x4057e2
cmpq $0x0, 0xf3bbe(%rip)     # 0x4f9420
je 0x405870
movq 0xf3bb5(%rip), %rdi     # 0x4f9420
callq 0x42cc50
movb $-0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x15b0, %rsp           # imm = 0x15B0
popq %rbp
retq