// File: /workspace/github_c_makefile_star2_O0/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfsreader.c
// Function: probeCbmdosFsOptions
SOEXPORT int probeCbmdosFsOptions(CbmdosFsOptions *options, const D64 *d64)
{
    CbmdosFsOptions probeopts = CFO_DEFAULT;
    if (options->flags & CFF_RECOVER)
    {
	probeopts.flags |= CFF_RECOVER;
    }

    uint8_t bamprobedolphin[5][21] = {{ 0 }};
    uint8_t bamprobespeed[5][21] = {{ 0 }};

    const uint8_t *bam = Sector_rcontent(D64_rsector(d64, 18, 0));
    if (D64_tracks(d64) > 35)
    {
	if (bam[2] == 0x50)
	{
	    probeopts.flags |= CFF_PROLOGICDOSBAM;
	    for (uint8_t trackno = 36; trackno < 41; ++trackno)
	    {
		uint8_t sectors = Track_sectors(D64_rtrack(d64, trackno));
		parseTrackBam(bamprobespeed[trackno-36],
			sectors, bam + 4*trackno);
	    }
	}
	else
	{
	    int dolphinok = 1;
	    int speedok = 1;
	    for (uint8_t trackno = 36; trackno < 41; ++trackno)
	    {
		uint8_t sectors = Track_sectors(D64_rtrack(d64, trackno));
		if (parseTrackBam(bamprobedolphin[trackno-36],
			    sectors, bam + 0x1c + 4*trackno) < 0)
		{
		    dolphinok = 0;
		}
		if (parseTrackBam(bamprobespeed[trackno-36],
			    sectors, bam + 0x30 + 4*trackno) < 0)
		{
		    speedok = 0;
		}
	    }
	    if (dolphinok)
	    {
		probeopts.flags |= CFF_DOLPHINDOSBAM;
	    }
	    if (speedok)
	    {
		probeopts.flags |= CFF_SPEEDDOSBAM;
	    }
	}
    }

    const Sector *dirsect = D64_rsector(d64, 18, 1);

    uint8_t rdmap[42][21] = { { 0 } };
    rdmap[17][0] = 1;
    rdmap[17][1] = 1;

    int firstfile = 1;
    while (dirsect)
    {
        const uint8_t *dirbytes = Sector_rcontent(dirsect);
        for (uint8_t dirpos = 0; dirpos < 8; ++dirpos)
        {
            const uint8_t *direntry = dirbytes + dirpos * 0x20;
            if (direntry[2])
            {
                CbmdosFileType type = direntry[2] & 0xf;
		if (type < CFT_DEL || type > CFT_REL)
		{
		    logmsg(L_ERROR, "probeCbmdosFsOptions: invalid file type "
			    "found.");
		    if (probeopts.flags & CFF_RECOVER) goto nextfile;
		    return -1;
		}
		if (type != CFT_DEL)
		{
		    uint8_t track = direntry[3];
		    uint8_t sector = direntry[4];
                    if (track == 18)
                    {
                        if (sector == 0 || sector == 1)
                        {
                            track = 0;
                        }
                        else if (firstfile)
                        {
                            probeopts.flags |= CFF_TALLOC_PREFDIRTRACK;
                        }
                    }
                    int doingsidesects = 0;
		    while (track)
		    {
			if (track > 40)
			{
			    probeopts.flags &= ~CFF_40TRACK;
			    probeopts.flags |= CFF_42TRACK;
			}
			else if (track > 35 && !(probeopts.flags & CFF_42TRACK))
			{
			    probeopts.flags |= CFF_40TRACK;
			}
			else if (track == 18)
			{
			    probeopts.flags |= CFF_FILESONDIRTRACK;
			}
			const Sector *filesector = D64_rsector(
				d64, track, sector);
			if (!filesector)
			{
			    logfmt(L_ERROR, "probeCbmdosFsOptions: "
				    "non-existent sector %d/%d found.",
				    track, sector);
			    if (probeopts.flags & CFF_RECOVER) goto nextfile;
			    return -1;
			}
                        if (rdmap[track-1][sector])
                        {
			    logmsg(L_ERROR, "probeCbmdosFsOptions: "
				    "corrupt filesystem, sector used twice.");
			    if (probeopts.flags & CFF_RECOVER) goto nextfile;
			    return -1;
                        }
                        rdmap[track-1][sector] = 1;
			const uint8_t *sectorbytes = Sector_rcontent(
				D64_rsector(d64, track, sector));
			track = sectorbytes[0];
			sector = sectorbytes[1];
                        if (!track && !doingsidesects && type == CFT_REL)
                        {
                            doingsidesects = 1;
                            track = direntry[0x15];
                            sector = direntry[0x16];
                        }
		    }
		}
nextfile:
		firstfile = 0;
            }
        }
        if (dirbytes[0])
        {
            dirsect = D64_rsector(d64, dirbytes[0], dirbytes[1]);
            if (!dirsect)
            {
                logfmt(L_ERROR, "probeCbmdosFsOptions: Non-existent sector "
			"%d/%d found.", dirbytes[0], dirbytes[1]);
		if (probeopts.flags & CFF_RECOVER) goto done;
		return -1;
            }
	    if (rdmap[dirbytes[0]-1][dirbytes[1]])
            {
                logmsg(L_ERROR, "probeCbmdosFsOptions: corrupt filesystem, "
			"sector used twice.");
                if (!(probeopts.flags & CFF_RECOVER)) return -1;
            }
	    if (dirbytes[0] > 40)
	    {
		probeopts.flags &= ~CFF_40TRACK;
		probeopts.flags |= CFF_42TRACK;
	    }
	    else if (dirbytes[0] > 35 && !(probeopts.flags & CFF_42TRACK))
	    {
		probeopts.flags |= CFF_40TRACK;
	    }
	    else if (dirbytes[0] != 18)
	    {
		probeopts.flags |= CFF_ALLOWLONGDIR;
	    }
	    rdmap[dirbytes[0]-1][dirbytes[1]] = 1;
        }
        else dirsect = 0;
    }

    if ((probeopts.flags & CFF_DOLPHINDOSBAM)
	    && memcmp(rdmap+35, bamprobedolphin, sizeof bamprobedolphin))
    {
	probeopts.flags &= ~CFF_DOLPHINDOSBAM;
    }
    if ((probeopts.flags & CFF_SPEEDDOSBAM)
	    && memcmp(rdmap+35, bamprobespeed, sizeof bamprobespeed))
    {
	probeopts.flags &= ~CFF_SPEEDDOSBAM;
    }
    if ((probeopts.flags & CFF_PROLOGICDOSBAM)
	    && memcmp(rdmap+35, bamprobespeed, sizeof bamprobespeed))
    {
	probeopts.flags &= ~CFF_PROLOGICDOSBAM;
    }

    int hasfreeblocks = 0;
    for (uint8_t trackno = 1;
	    trackno < (D64_type(d64) == D64_STANDARD ? 36 : 41); ++trackno)
    {
	uint8_t sectors = Track_sectors(D64_rtrack(d64, trackno));
	for (uint8_t sectno = 0; sectno < sectors; ++sectno)
	{
	    if (!rdmap[trackno-1][sectno])
	    {
		hasfreeblocks = 1;
		goto checkzerofree;
	    }
	}
    }

checkzerofree:
    if (hasfreeblocks)
    {
	int zerofree = 1;
	for (uint8_t trackno = 1; trackno < 36; ++trackno)
	{
	    if (bam[4*trackno])
	    {
		zerofree = 0;
		break;
	    }
	}

	if (D64_type(d64) == D64_STANDARD)
	{
	    if (zerofree) probeopts.flags |= CFF_ZEROFREE;
	}
	else if (zerofree)
	{
	    if (probeopts.flags & CFF_PROLOGICDOSBAM)
	    {
		for (uint8_t trackno = 36; trackno < 41; ++trackno)
		{
		    if (bam[4*trackno])
		    {
			zerofree = 0;
			break;
		    }
		}
		if (zerofree) probeopts.flags |= CFF_ZEROFREE;
	    }
	    else
	    {
		int havedolphin = 0;
		int havespeed = 0;
		if (!memcmp(rdmap+35, bamprobedolphin,
			sizeof bamprobedolphin))
		{
		    havedolphin = 1;
		    for (uint8_t trackno = 36; trackno < 41; ++trackno)
		    {
			if (bam[4*trackno + 0x1c])
			{
			    zerofree = 0;
			    break;
			}
		    }
		}
		if (!memcmp(rdmap+35, bamprobespeed,
			    sizeof bamprobespeed))
		{
		    havespeed = 1;
		    for (uint8_t trackno = 36; trackno < 41; ++trackno)
		    {
			if (bam[4*trackno + 0x30])
			{
			    zerofree = 0;
			    break;
			}
		    }
		}
		if (zerofree)
		{
		    probeopts.flags |= CFF_ZEROFREE;
		    if (havedolphin) probeopts.flags |= CFF_DOLPHINDOSBAM;
		    if (havespeed) probeopts.flags |= CFF_SPEEDDOSBAM;
		}
	    }
	}
    }

done:
    memcpy(options, &probeopts, sizeof probeopts);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x500, %rsp            # imm = 0x500
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq 0xdf4e(%rip), %rax      # 0x18fe8
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0xb0bc
movl -0x20(%rbp), %eax
orl $0x100, %eax            # imm = 0x100
movl %eax, -0x20(%rbp)
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x69, %edx
callq 0x5340
leaq -0x100(%rbp), %rdi
xorl %esi, %esi
movl $0x69, %edx
callq 0x5340
movq -0x18(%rbp), %rdi
movl $0x12, %esi
xorl %edx, %edx
callq 0x50c0
movq %rax, %rdi
callq 0x56d0
movq %rax, -0x108(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5630
movzbl %al, %eax
cmpl $0x23, %eax
jle 0xb2e2
movq -0x108(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x50, %eax
jne 0xb1b8
movl -0x20(%rbp), %eax
orl $0x40, %eax
movl %eax, -0x20(%rbp)
movb $0x24, -0x109(%rbp)
movzbl -0x109(%rbp), %eax
cmpl $0x29, %eax
jge 0xb1b3
movq -0x18(%rbp), %rdi
movzbl -0x109(%rbp), %esi
callq 0x5050
movq %rax, %rdi
callq 0x57b0
movb %al, -0x10a(%rbp)
movzbl -0x109(%rbp), %eax
subl $0x24, %eax
cltq
leaq -0x100(%rbp), %rdi
imulq $0x15, %rax, %rax
addq %rax, %rdi
movb -0x10a(%rbp), %al
movq -0x108(%rbp), %rdx
movzbl -0x109(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
addq %rcx, %rdx
movzbl %al, %esi
callq 0xaf10
movb -0x109(%rbp), %al
addb $0x1, %al
movb %al, -0x109(%rbp)
jmp 0xb13a
jmp 0xb2e0
movl $0x1, -0x110(%rbp)
movl $0x1, -0x114(%rbp)
movb $0x24, -0x115(%rbp)
movzbl -0x115(%rbp), %eax
cmpl $0x29, %eax
jge 0xb2ba
movq -0x18(%rbp), %rdi
movzbl -0x115(%rbp), %esi
callq 0x5050
movq %rax, %rdi
callq 0x57b0
movb %al, -0x116(%rbp)
movzbl -0x115(%rbp), %eax
subl $0x24, %eax
cltq
leaq -0x90(%rbp), %rdi
imulq $0x15, %rax, %rax
addq %rax, %rdi
movb -0x116(%rbp), %al
movq -0x108(%rbp), %rdx
addq $0x1c, %rdx
movzbl -0x115(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
addq %rcx, %rdx
movzbl %al, %esi
callq 0xaf10
cmpl $0x0, %eax
jge 0xb253
movl $0x0, -0x110(%rbp)
movzbl -0x115(%rbp), %eax
subl $0x24, %eax
cltq
leaq -0x100(%rbp), %rdi
imulq $0x15, %rax, %rax
addq %rax, %rdi
movb -0x116(%rbp), %al
movq -0x108(%rbp), %rdx
addq $0x30, %rdx
movzbl -0x115(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
addq %rcx, %rdx
movzbl %al, %esi
callq 0xaf10
cmpl $0x0, %eax
jge 0xb2a5
movl $0x0, -0x114(%rbp)
jmp 0xb2a7
movb -0x115(%rbp), %al
addb $0x1, %al
movb %al, -0x115(%rbp)
jmp 0xb1d3
cmpl $0x0, -0x110(%rbp)
je 0xb2cc
movl -0x20(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x114(%rbp)
je 0xb2de
movl -0x20(%rbp), %eax
orl $0x20, %eax
movl %eax, -0x20(%rbp)
jmp 0xb2e0
jmp 0xb2e2
movq -0x18(%rbp), %rdi
movl $0x12, %esi
movl $0x1, %edx
callq 0x50c0
movq %rax, -0x120(%rbp)
leaq -0x4a0(%rbp), %rdi
xorl %esi, %esi
movl $0x372, %edx            # imm = 0x372
callq 0x5340
movb $0x1, -0x33b(%rbp)
movb $0x1, -0x33a(%rbp)
movl $0x1, -0x4a4(%rbp)
cmpq $0x0, -0x120(%rbp)
je 0xb7e6
movq -0x120(%rbp), %rdi
callq 0x56d0
movq %rax, -0x4b0(%rbp)
movb $0x0, -0x4b1(%rbp)
movzbl -0x4b1(%rbp), %eax
cmpl $0x8, %eax
jge 0xb661
movq -0x4b0(%rbp), %rax
movzbl -0x4b1(%rbp), %ecx
shll $0x5, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x4c0(%rbp)
movq -0x4c0(%rbp), %rax
cmpb $0x0, 0x2(%rax)
je 0xb64c
movq -0x4c0(%rbp), %rax
movzbl 0x2(%rax), %eax
andl $0xf, %eax
movl %eax, -0x4c4(%rbp)
cmpl $0x0, -0x4c4(%rbp)
jb 0xb3b4
cmpl $0x4, -0x4c4(%rbp)
jbe 0xb3e3
movl $0x1, %edi
leaq 0x8a0b(%rip), %rsi      # 0x13dcb
callq 0x5a60
movl -0x20(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0xb3d7
jmp 0xb642
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xbbd4
cmpl $0x0, -0x4c4(%rbp)
je 0xb640
movq -0x4c0(%rbp), %rax
movb 0x3(%rax), %al
movb %al, -0x4c5(%rbp)
movq -0x4c0(%rbp), %rax
movb 0x4(%rax), %al
movb %al, -0x4c6(%rbp)
movzbl -0x4c5(%rbp), %eax
cmpl $0x12, %eax
jne 0xb455
movzbl -0x4c6(%rbp), %eax
cmpl $0x0, %eax
je 0xb434
movzbl -0x4c6(%rbp), %eax
cmpl $0x1, %eax
jne 0xb43d
movb $0x0, -0x4c5(%rbp)
jmp 0xb453
cmpl $0x0, -0x4a4(%rbp)
je 0xb451
movl -0x20(%rbp), %eax
orl $0x1000, %eax           # imm = 0x1000
movl %eax, -0x20(%rbp)
jmp 0xb453
jmp 0xb455
movl $0x0, -0x4cc(%rbp)
cmpb $0x0, -0x4c5(%rbp)
je 0xb63e
movzbl -0x4c5(%rbp), %eax
cmpl $0x28, %eax
jle 0xb48c
movl -0x20(%rbp), %eax
andl $-0x5, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
orl $0x8, %eax
movl %eax, -0x20(%rbp)
jmp 0xb4c7
movzbl -0x4c5(%rbp), %eax
cmpl $0x23, %eax
jle 0xb4ae
movl -0x20(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0xb4ae
movl -0x20(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x20(%rbp)
jmp 0xb4c5
movzbl -0x4c5(%rbp), %eax
cmpl $0x12, %eax
jne 0xb4c3
movl -0x20(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x20(%rbp)
jmp 0xb4c5
jmp 0xb4c7
movq -0x18(%rbp), %rdi
movb -0x4c5(%rbp), %al
movzbl %al, %esi
movzbl -0x4c6(%rbp), %edx
callq 0x50c0
movq %rax, -0x4d8(%rbp)
cmpq $0x0, -0x4d8(%rbp)
jne 0xb530
movzbl -0x4c5(%rbp), %edx
movzbl -0x4c6(%rbp), %ecx
movl $0x1, %edi
leaq 0x88ef(%rip), %rsi      # 0x13dfa
movb $0x0, %al
callq 0x5ab0
movl -0x20(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0xb524
jmp 0xb642
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xbbd4
movzbl -0x4c5(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x4a0(%rbp), %rax
imulq $0x15, %rcx, %rcx
addq %rcx, %rax
movzbl -0x4c6(%rbp), %ecx
cmpb $0x0, (%rax,%rcx)
je 0xb587
movl $0x1, %edi
leaq 0x88cd(%rip), %rsi      # 0x13e31
callq 0x5a60
movl -0x20(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0xb57b
jmp 0xb642
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xbbd4
movzbl -0x4c5(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x4a0(%rbp), %rax
imulq $0x15, %rcx, %rcx
addq %rcx, %rax
movzbl -0x4c6(%rbp), %ecx
movb $0x1, (%rax,%rcx)
movq -0x18(%rbp), %rdi
movb -0x4c5(%rbp), %al
movzbl %al, %esi
movzbl -0x4c6(%rbp), %edx
callq 0x50c0
movq %rax, %rdi
callq 0x56d0
movq %rax, -0x4e0(%rbp)
movq -0x4e0(%rbp), %rax
movb (%rax), %al
movb %al, -0x4c5(%rbp)
movq -0x4e0(%rbp), %rax
movb 0x1(%rax), %al
movb %al, -0x4c6(%rbp)
cmpb $0x0, -0x4c5(%rbp)
jne 0xb639
cmpl $0x0, -0x4cc(%rbp)
jne 0xb639
cmpl $0x4, -0x4c4(%rbp)
jne 0xb639
movl $0x1, -0x4cc(%rbp)
movq -0x4c0(%rbp), %rax
movb 0x15(%rax), %al
movb %al, -0x4c5(%rbp)
movq -0x4c0(%rbp), %rax
movb 0x16(%rax), %al
movb %al, -0x4c6(%rbp)
jmp 0xb45f
jmp 0xb640
jmp 0xb642
movl $0x0, -0x4a4(%rbp)
jmp 0xb64e
movb -0x4b1(%rbp), %al
addb $0x1, %al
movb %al, -0x4b1(%rbp)
jmp 0xb34f
movq -0x4b0(%rbp), %rax
cmpb $0x0, (%rax)
je 0xb7d6
movq -0x18(%rbp), %rdi
movq -0x4b0(%rbp), %rax
movb (%rax), %cl
movq -0x4b0(%rbp), %rax
movzbl %cl, %esi
movzbl 0x1(%rax), %edx
callq 0x50c0
movq %rax, -0x120(%rbp)
cmpq $0x0, -0x120(%rbp)
jne 0xb6e8
movq -0x4b0(%rbp), %rax
movzbl (%rax), %edx
movq -0x4b0(%rbp), %rax
movzbl 0x1(%rax), %ecx
movl $0x1, %edi
leaq 0x87ab(%rip), %rsi      # 0x13e6e
movb $0x0, %al
callq 0x5ab0
movl -0x20(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0xb6dc
jmp 0xbbc2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xbbd4
movq -0x4b0(%rbp), %rax
movzbl (%rax), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x4a0(%rbp), %rax
imulq $0x15, %rcx, %rcx
addq %rcx, %rax
movq -0x4b0(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
cmpb $0x0, (%rax,%rcx)
je 0xb743
movl $0x1, %edi
leaq 0x870e(%rip), %rsi      # 0x13e31
callq 0x5a60
movl -0x20(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
jne 0xb741
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xbbd4
jmp 0xb743
movq -0x4b0(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x28, %eax
jle 0xb766
movl -0x20(%rbp), %eax
andl $-0x5, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
orl $0x8, %eax
movl %eax, -0x20(%rbp)
jmp 0xb7a7
movq -0x4b0(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x23, %eax
jle 0xb78b
movl -0x20(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0xb78b
movl -0x20(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x20(%rbp)
jmp 0xb7a5
movq -0x4b0(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x12, %eax
je 0xb7a3
movl -0x20(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xb7a5
jmp 0xb7a7
movq -0x4b0(%rbp), %rax
movzbl (%rax), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x4a0(%rbp), %rax
imulq $0x15, %rcx, %rcx
addq %rcx, %rax
movq -0x4b0(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
movb $0x1, (%rax,%rcx)
jmp 0xb7e1
movq $0x0, -0x120(%rbp)
jmp 0xb327
movl -0x20(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0xb81e
leaq -0x4a0(%rbp), %rdi
addq $0x2df, %rdi            # imm = 0x2DF
leaq -0x90(%rbp), %rsi
movl $0x69, %edx
callq 0x53f0
cmpl $0x0, %eax
je 0xb81e
movl -0x20(%rbp), %eax
andl $-0x11, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0xb856
leaq -0x4a0(%rbp), %rdi
addq $0x2df, %rdi            # imm = 0x2DF
leaq -0x100(%rbp), %rsi
movl $0x69, %edx
callq 0x53f0
cmpl $0x0, %eax
je 0xb856
movl -0x20(%rbp), %eax
andl $-0x21, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0xb88e
leaq -0x4a0(%rbp), %rdi
addq $0x2df, %rdi            # imm = 0x2DF
leaq -0x100(%rbp), %rsi
movl $0x69, %edx
callq 0x53f0
cmpl $0x0, %eax
je 0xb88e
movl -0x20(%rbp), %eax
andl $-0x41, %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x4e4(%rbp)
movb $0x1, -0x4e5(%rbp)
movzbl -0x4e5(%rbp), %eax
movl %eax, -0x500(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5480
movl %eax, %esi
movl -0x500(%rbp), %eax
movl $0x29, %ecx
movl $0x24, %edx
cmpl $0x0, %esi
cmovel %edx, %ecx
cmpl %ecx, %eax
jge 0xb967
movq -0x18(%rbp), %rdi
movzbl -0x4e5(%rbp), %esi
callq 0x5050
movq %rax, %rdi
callq 0x57b0
movb %al, -0x4e6(%rbp)
movb $0x0, -0x4e7(%rbp)
movzbl -0x4e7(%rbp), %eax
movzbl -0x4e6(%rbp), %ecx
cmpl %ecx, %eax
jge 0xb952
movzbl -0x4e5(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x4a0(%rbp), %rax
imulq $0x15, %rcx, %rcx
addq %rcx, %rax
movzbl -0x4e7(%rbp), %ecx
cmpb $0x0, (%rax,%rcx)
jne 0xb940
movl $0x1, -0x4e4(%rbp)
jmp 0xb969
jmp 0xb942
movb -0x4e7(%rbp), %al
addb $0x1, %al
movb %al, -0x4e7(%rbp)
jmp 0xb8fa
jmp 0xb954
movb -0x4e5(%rbp), %al
addb $0x1, %al
movb %al, -0x4e5(%rbp)
jmp 0xb89f
jmp 0xb969
cmpl $0x0, -0x4e4(%rbp)
je 0xbbc0
movl $0x1, -0x4ec(%rbp)
movb $0x1, -0x4ed(%rbp)
movzbl -0x4ed(%rbp), %eax
cmpl $0x24, %eax
jge 0xb9cb
movq -0x108(%rbp), %rax
movzbl -0x4ed(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
cmpb $0x0, (%rax,%rcx)
je 0xb9b9
movl $0x0, -0x4ec(%rbp)
jmp 0xb9cb
jmp 0xb9bb
movb -0x4ed(%rbp), %al
addb $0x1, %al
movb %al, -0x4ed(%rbp)
jmp 0xb987
movq -0x18(%rbp), %rdi
callq 0x5480
cmpl $0x0, %eax
jne 0xb9f2
cmpl $0x0, -0x4ec(%rbp)
je 0xb9ed
movl -0x20(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x20(%rbp)
jmp 0xbbbe
cmpl $0x0, -0x4ec(%rbp)
je 0xbbbc
movl -0x20(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0xba6e
movb $0x24, -0x4ee(%rbp)
movzbl -0x4ee(%rbp), %eax
cmpl $0x29, %eax
jge 0xba55
movq -0x108(%rbp), %rax
movzbl -0x4ee(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
cmpb $0x0, (%rax,%rcx)
je 0xba43
movl $0x0, -0x4ec(%rbp)
jmp 0xba55
jmp 0xba45
movb -0x4ee(%rbp), %al
addb $0x1, %al
movb %al, -0x4ee(%rbp)
jmp 0xba11
cmpl $0x0, -0x4ec(%rbp)
je 0xba69
movl -0x20(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x20(%rbp)
jmp 0xbbba
movl $0x0, -0x4f4(%rbp)
movl $0x0, -0x4f8(%rbp)
leaq -0x4a0(%rbp), %rdi
addq $0x2df, %rdi            # imm = 0x2DF
leaq -0x90(%rbp), %rsi
movl $0x69, %edx
callq 0x53f0
cmpl $0x0, %eax
jne 0xbb00
movl $0x1, -0x4f4(%rbp)
movb $0x24, -0x4f9(%rbp)
movzbl -0x4f9(%rbp), %eax
cmpl $0x29, %eax
jge 0xbafe
movq -0x108(%rbp), %rax
movzbl -0x4f9(%rbp), %ecx
shll $0x2, %ecx
addl $0x1c, %ecx
movslq %ecx, %rcx
cmpb $0x0, (%rax,%rcx)
je 0xbaec
movl $0x0, -0x4ec(%rbp)
jmp 0xbafe
jmp 0xbaee
movb -0x4f9(%rbp), %al
addb $0x1, %al
movb %al, -0x4f9(%rbp)
jmp 0xbab7
jmp 0xbb00
leaq -0x4a0(%rbp), %rdi
addq $0x2df, %rdi            # imm = 0x2DF
leaq -0x100(%rbp), %rsi
movl $0x69, %edx
callq 0x53f0
cmpl $0x0, %eax
jne 0xbb7e
movl $0x1, -0x4f8(%rbp)
movb $0x24, -0x4fa(%rbp)
movzbl -0x4fa(%rbp), %eax
cmpl $0x29, %eax
jge 0xbb7c
movq -0x108(%rbp), %rax
movzbl -0x4fa(%rbp), %ecx
shll $0x2, %ecx
addl $0x30, %ecx
movslq %ecx, %rcx
cmpb $0x0, (%rax,%rcx)
je 0xbb6a
movl $0x0, -0x4ec(%rbp)
jmp 0xbb7c
jmp 0xbb6c
movb -0x4fa(%rbp), %al
addb $0x1, %al
movb %al, -0x4fa(%rbp)
jmp 0xbb35
jmp 0xbb7e
cmpl $0x0, -0x4ec(%rbp)
je 0xbbb8
movl -0x20(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x4f4(%rbp)
je 0xbba4
movl -0x20(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x4f8(%rbp)
je 0xbbb6
movl -0x20(%rbp), %eax
orl $0x20, %eax
movl %eax, -0x20(%rbp)
jmp 0xbbb8
jmp 0xbbba
jmp 0xbbbc
jmp 0xbbbe
jmp 0xbbc0
jmp 0xbbc2
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x500, %rsp            # imm = 0x500
popq %rbp
retq