// File: /workspace/github_c_makefile_star2_O0/aremmell[P]libsir/tests/tests.c
// Function: sirtest_filesystem
bool sirtest_filesystem(void) {
    INIT(si, SIRL_ALL, 0, 0, 0);
    bool pass = si_init;

    /* Wine version */
    TEST_MSG("Running under Wine: %s",
            get_wineversion() ? get_wineversion() : "no");

    /* current working directory. */
    char* cwd = _sir_getcwd();
    _sir_eqland(pass, NULL != cwd);
    TEST_MSG("_sir_getcwd: '%s'", PRN_STR(cwd));

    if (NULL != cwd) {
        /* path to this binary file. */
        char* filename = _sir_getappfilename();
        _sir_eqland(pass, NULL != filename);
        TEST_MSG("_sir_getappfilename: '%s'", PRN_STR(filename));

        if (NULL != filename) {
            /* _sir_get[base|dir]name() can potentially modify filename,
             * so make a copy for each call. */
            char* filename2 = strndup(filename, strnlen(filename, SIR_MAXPATH));
            _sir_eqland(pass, NULL != filename2);

            if (NULL != filename2) {
                /* filename, stripped of directory component(s). */
                char* _basename = _sir_getbasename(filename2);
                TEST_MSG("_sir_getbasename: '%s'", PRN_STR(_basename));

                if (!_basename) {
                    pass = false;
                } else {
                    /* the last strlen(_basename) chars of filename should match. */
                    size_t len    = strnlen(_basename, SIR_MAXPATH);
                    size_t offset = strnlen(filename, SIR_MAXPATH) - len;
                    size_t n      = 0;

                    while (n < len) {
                        if (filename[offset++] != _basename[n++]) {
                            pass = false;
                            break;
                        }
                    }
                }
            }

            /* directory this binary file resides in. */
            char* appdir = _sir_getappdir();
            _sir_eqland(pass, NULL != appdir);
            TEST_MSG("_sir_getappdir: '%s'", PRN_STR(appdir));

            /* _sir_get[base|dir]name can potentially modify filename,
             * so make a copy for each call. */
            char* filename3 = strndup(filename, strnlen(filename, SIR_MAXPATH));
            _sir_eqland(pass, NULL != filename3);

            if (NULL != appdir && NULL != filename3) {
                /* should yield the same result as _sir_getappdir(). */
                char* _dirname = _sir_getdirname(filename3);
                TEST_MSG("_sir_getdirname: '%s'", PRN_STR(_dirname));

                _sir_eqland(pass, 0 == strncmp(filename, appdir, strnlen(appdir, SIR_MAXPATH)));
                _sir_eqland(pass, NULL != _dirname &&
                    0 == strncmp(filename, _dirname, strnlen(_dirname, SIR_MAXPATH)));
            }

            _sir_safefree(&appdir);
            _sir_safefree(&filename);
            _sir_safefree(&filename2);
            _sir_safefree(&filename3);
        }

        _sir_safefree(&cwd);
    }

    /* this next section doesn't really yield any useful boolean pass/fail
     * information, but could be helpful to review manually. */
    char* dubious_dirnames[] = {
#if !defined(__WIN__)
        "/foo",
        "/foo/",
        "/foo/bar",
        "/foo/bar/bad:filename",
        "/",
        ""
#else /* __WIN__ */
        "C:\\foo",
        "C:\\foo\\",
        "C:\\foo\\bar",
        "C:\\foo\\bar\\bad:>filename",
        "C:\\",
        "//network-share/myfolder",
        ""
#endif
    };

    for (size_t n = 0; n < _sir_countof(dubious_dirnames); n++) {
        char* tmp = strndup(dubious_dirnames[n], strnlen(dubious_dirnames[n], SIR_MAXPATH));
        if (NULL != tmp) {
            TEST_MSG("_sir_getdirname(" SIR_WHITE("'%s'") ") = " SIR_WHITE("'%s'") "",
                tmp, _sir_getdirname(tmp));
            _sir_safefree(&tmp);
        }
    }

    char* dubious_filenames[] = {
#if !defined(__WIN__)
        "foo/bar/file-or-directory",
        "/foo/bar/file-or-directory",
        "/foo/bar/illegal:filename",
        "/",
        ""
#else /* __WIN__ */
        "foo\\bar\\file.with.many.full.stops",
        "C:\\foo\\bar\\poorly-renamed.txt.pdf",
        "C:\\foo\\bar\\illegal>filename.txt",
        "C:\\",
        "\\Program Files\\foo.bar",
        ""
#endif
    };

    for (size_t n = 0; n < _sir_countof(dubious_filenames); n++) {
        char* tmp = strndup(dubious_filenames[n], strnlen(dubious_filenames[n], SIR_MAXPATH));
        if (NULL != tmp) {
            TEST_MSG("_sir_getbasename(" SIR_WHITE("'%s'") ") = " SIR_WHITE("'%s'") "",
                tmp, _sir_getbasename(tmp));
            _sir_safefree(&tmp);
        }
    }

    /* absolute/relative paths. */
    static const struct {
        const char* const path;
        bool abs;
    } abs_or_rel_paths[] = {
        {"this/is/relative", false},
        {"relative", false},
        {"./relative", false},
        {"../../relative", false},
#if !defined(__WIN__)
        {"/usr/local/bin", true},
        {"/", true},
        {"/home/foo/.config", true},
        {"~/.config", true}
#else /* __WIN__ */
        {"D:\\absolute", true},
        {"C:\\Program Files\\FooBar", true},
        {"C:\\", true},
        {"\\absolute", true},
#endif
    };

    for (size_t n = 0; n < _sir_countof(abs_or_rel_paths); n++) {
        bool relative = false;
        bool ret      = _sir_ispathrelative(abs_or_rel_paths[n].path, &relative);

        if (relative == abs_or_rel_paths[n].abs) {
            pass = false;
            TEST_MSG(SIR_RED("_sir_ispathrelative('%s') = %s"), abs_or_rel_paths[n].path,
                relative ? "true" : "false");
        } else {
            TEST_MSG(SIR_GREEN("_sir_ispathrelative('%s') = %s"), abs_or_rel_paths[n].path,
                relative ? "true" : "false");
        }

        _sir_eqland(pass, ret);
        if (!ret) {
            bool unused = print_test_error(false, false);
            SIR_UNUSED(unused);
        }
    }

    /* file existence. */
    static const struct {
        const char* const path;
        bool exists;
    } real_or_not[] = {
        {"../foobarbaz", false},
        {"foobarbaz", false},
#if !defined(__WIN__)
        {"/", true},
# if !defined(__HAIKU__)
        {"/usr/bin", true},
# else
        {"/bin", true},
# endif
        {"/dev", true},
#else /* __WIN__ */
        {"C:\\Windows", true},
        {"C:\\Program Files", true},
        {"\\", true},
        {".\\", true},
        {"..\\", true},
#endif
        {"../../LICENSES/MIT.txt", true},
        {"../../msvs/libsir.sln", true},
        {"./", true},
        {"../", true},
        {"file.exists", true}
    };

    for (size_t n = 0; n < _sir_countof(real_or_not); n++) {
        bool exists = false;
        bool ret    = _sir_pathexists(real_or_not[n].path, &exists, SIR_PATH_REL_TO_APP);

        if (exists != real_or_not[n].exists) {
            pass = false;
            TEST_MSG(SIR_RED("_sir_pathexists('%s') = %s"), real_or_not[n].path,
                exists ? "true" : "false");
        } else {
            TEST_MSG(SIR_GREEN("_sir_pathexists('%s') = %s"), real_or_not[n].path,
                exists ? "true" : "false");
        }

        _sir_eqland(pass, ret);
        if (!ret) {
            bool unused = print_test_error(false, false);
            SIR_UNUSED(unused);
        }
    }

    /* checking file descriptors. */
    static int bad_fds[] = {
        0,
        1,
        2,
        1234
    };

    if (get_wineversion()) {
        bad_fds[3] = 0;
    }

    for (size_t n = 0; n < _sir_countof(bad_fds); n++) {
        if (_sir_validfd(bad_fds[n])) {
            pass = false;
            TEST_MSG(SIR_RED("_sir_validfd(%d) = true"), bad_fds[n]);
        } else {
            TEST_MSG(SIR_GREEN("_sir_validfd(%d) = false"), bad_fds[n]);
        }
    }

    FILE* f = NULL;
    bool ret = _sir_openfile(&f, "file.exists", "r", SIR_PATH_REL_TO_APP);
    if (!ret) {
        pass = false;
        HANDLE_OS_ERROR(true, "fopen(%s) failed!", "file.exists");
    } else {
        int fd = fileno(f);
        if (!_sir_validfd(fd)) {
            pass = false;
            TEST_MSG(SIR_RED("_sir_validfd(%d) = false"), fd);
        } else {
            TEST_MSG(SIR_GREEN("_sir_validfd(%d) = true"), fd);
        }
    }

    _sir_safefclose(&f);

    _sir_eqland(pass, sir_cleanup());
    return PRINT_RESULT_RETURN(pass);
}

// Assembly:
subq $0x2e8, %rsp            # imm = 0x2E8
leaq 0x1e0(%rsp), %rdi
xorl %esi, %esi
movl $0x108, %edx            # imm = 0x108
callq 0x4210
movl $0x100000, 0x1e4(%rsp) # imm = 0x100000
movw $0xff, 0x1e0(%rsp)
movl $0x100000, 0x1ec(%rsp) # imm = 0x100000
movw $0x0, 0x1e8(%rsp)
leaq 0x10a2b(%rip), %rdi     # 0x1d2c7
xorl %esi, %esi
leaq 0x12df4(%rip), %rdx     # 0x1f699
leaq 0x10c81(%rip), %rcx     # 0x1d52d
movl $0x610, %r8d            # imm = 0x610
callq 0x5ce0
testb $0x1, %al
jne 0xc8bd
jmp 0xc8e0
leaq 0x1e0(%rsp), %rdi
addq $0xe8, %rdi
movl $0x20, %ecx
leaq 0x109ef(%rip), %rdx     # 0x1d2c7
movq %rcx, %rsi
callq 0x14f50
movb $0x0, 0x1df(%rsp)
leaq 0x1e0(%rsp), %rdi
callq 0xf560
andb $0x1, %al
movb %al, 0x1df(%rsp)
movb 0x1df(%rsp), %al
andb $0x1, %al
movb %al, 0x1de(%rsp)
callq 0xd510
cmpq $0x0, %rax
je 0xc928
callq 0xd510
movq %rax, 0xc0(%rsp)
jmp 0xc939
leaq 0x12d96(%rip), %rax     # 0x1f6c5
movq %rax, 0xc0(%rsp)
jmp 0xc939
movq 0xc0(%rsp), %rsi
leaq 0x12d64(%rip), %rdi     # 0x1f6ac
movb $0x0, %al
callq 0x4180
callq 0x13ec0
movq %rax, 0x1d0(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpq 0x1d0(%rsp), %rcx
movb %al, 0xbf(%rsp)
je 0xc97f
movb 0x1de(%rsp), %al
movb %al, 0xbf(%rsp)
movb 0xbf(%rsp), %al
andb $0x1, %al
movb %al, 0x1de(%rsp)
cmpq $0x0, 0x1d0(%rsp)
je 0xc9ac
movq 0x1d0(%rsp), %rax
movq %rax, 0xb0(%rsp)
jmp 0xc9bd
leaq 0x12d29(%rip), %rax     # 0x1f6dc
movq %rax, 0xb0(%rsp)
jmp 0xc9bd
movq 0xb0(%rsp), %rsi
leaq 0x12cfc(%rip), %rdi     # 0x1f6c8
movb $0x0, %al
callq 0x4180
xorl %eax, %eax
cmpq 0x1d0(%rsp), %rax
je 0xce7d
callq 0x13f20
movq %rax, 0x1c8(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpq 0x1c8(%rsp), %rcx
movb %al, 0xaf(%rsp)
je 0xca13
movb 0x1de(%rsp), %al
movb %al, 0xaf(%rsp)
movb 0xaf(%rsp), %al
andb $0x1, %al
movb %al, 0x1de(%rsp)
cmpq $0x0, 0x1c8(%rsp)
je 0xca40
movq 0x1c8(%rsp), %rax
movq %rax, 0xa0(%rsp)
jmp 0xca51
leaq 0x12c95(%rip), %rax     # 0x1f6dc
movq %rax, 0xa0(%rsp)
jmp 0xca51
movq 0xa0(%rsp), %rsi
leaq 0x12c95(%rip), %rdi     # 0x1f6f5
movb $0x0, %al
callq 0x4180
xorl %eax, %eax
cmpq 0x1c8(%rsp), %rax
je 0xce70
movq 0x1c8(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x1c8(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x4230
movq 0x90(%rsp), %rdi
movq %rax, %rsi
callq 0x42a0
movq %rax, 0x1c0(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpq 0x1c0(%rsp), %rcx
movb %al, 0x9f(%rsp)
je 0xcad4
movb 0x1de(%rsp), %al
movb %al, 0x9f(%rsp)
movb 0x9f(%rsp), %al
andb $0x1, %al
movb %al, 0x1de(%rsp)
xorl %eax, %eax
cmpq 0x1c0(%rsp), %rax
je 0xcc19
movq 0x1c0(%rsp), %rdi
callq 0x141d0
movq %rax, 0x1b8(%rsp)
cmpq $0x0, 0x1b8(%rsp)
je 0xcb26
movq 0x1b8(%rsp), %rax
movq %rax, 0x88(%rsp)
jmp 0xcb37
leaq 0x12baf(%rip), %rax     # 0x1f6dc
movq %rax, 0x88(%rsp)
jmp 0xcb37
movq 0x88(%rsp), %rsi
leaq 0x12bcb(%rip), %rdi     # 0x1f711
movb $0x0, %al
callq 0x4180
cmpq $0x0, 0x1b8(%rsp)
jne 0xcb65
movb $0x0, 0x1de(%rsp)
jmp 0xcc17
movq 0x1b8(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x4230
movq %rax, 0x1b0(%rsp)
movq 0x1c8(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x4230
subq 0x1b0(%rsp), %rax
movq %rax, 0x1a8(%rsp)
movq $0x0, 0x1a0(%rsp)
movq 0x1a0(%rsp), %rax
cmpq 0x1b0(%rsp), %rax
jae 0xcc15
movq 0x1c8(%rsp), %rax
movq 0x1a8(%rsp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, 0x1a8(%rsp)
movsbl (%rax,%rcx), %eax
movq 0x1b8(%rsp), %rcx
movq 0x1a0(%rsp), %rdx
movq %rdx, %rsi
addq $0x1, %rsi
movq %rsi, 0x1a0(%rsp)
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0xcc13
movb $0x0, 0x1de(%rsp)
jmp 0xcc15
jmp 0xcbad
jmp 0xcc17
jmp 0xcc19
callq 0x14230
movq %rax, 0x198(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpq 0x198(%rsp), %rcx
movb %al, 0x87(%rsp)
je 0xcc49
movb 0x1de(%rsp), %al
movb %al, 0x87(%rsp)
movb 0x87(%rsp), %al
andb $0x1, %al
movb %al, 0x1de(%rsp)
cmpq $0x0, 0x198(%rsp)
je 0xcc73
movq 0x198(%rsp), %rax
movq %rax, 0x78(%rsp)
jmp 0xcc81
leaq 0x12a62(%rip), %rax     # 0x1f6dc
movq %rax, 0x78(%rsp)
jmp 0xcc81
movq 0x78(%rsp), %rsi
leaq 0x12a9d(%rip), %rdi     # 0x1f72a
movb $0x0, %al
callq 0x4180
movq 0x1c8(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x1c8(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x4230
movq 0x68(%rsp), %rdi
movq %rax, %rsi
callq 0x42a0
movq %rax, 0x190(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpq 0x190(%rsp), %rcx
movb %al, 0x77(%rsp)
je 0xcce5
movb 0x1de(%rsp), %al
movb %al, 0x77(%rsp)
movb 0x77(%rsp), %al
andb $0x1, %al
movb %al, 0x1de(%rsp)
xorl %eax, %eax
cmpq 0x198(%rsp), %rax
je 0xce3c
xorl %eax, %eax
cmpq 0x190(%rsp), %rax
je 0xce3c
movq 0x190(%rsp), %rdi
callq 0x142d0
movq %rax, 0x188(%rsp)
cmpq $0x0, 0x188(%rsp)
je 0xcd41
movq 0x188(%rsp), %rax
movq %rax, 0x60(%rsp)
jmp 0xcd4f
leaq 0x12994(%rip), %rax     # 0x1f6dc
movq %rax, 0x60(%rsp)
jmp 0xcd4f
movq 0x60(%rsp), %rsi
leaq 0x129e6(%rip), %rdi     # 0x1f741
movb $0x0, %al
callq 0x4180
movq 0x1c8(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x198(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x198(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x4230
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq %rax, %rdx
callq 0x4090
movl %eax, %edx
xorl %eax, %eax
xorl %ecx, %ecx
cmpl %edx, %ecx
movb %al, 0x5f(%rsp)
jne 0xcdb9
movb 0x1de(%rsp), %al
movb %al, 0x5f(%rsp)
movb 0x5f(%rsp), %al
andb $0x1, %al
movb %al, 0x1de(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpq 0x188(%rsp), %rcx
movb %al, 0x47(%rsp)
je 0xce2f
movq 0x1c8(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x188(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x188(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x4230
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %rax, %rdx
callq 0x4090
movl %eax, %edx
xorl %eax, %eax
xorl %ecx, %ecx
cmpl %edx, %ecx
movb %al, 0x47(%rsp)
jne 0xce2f
movb 0x1de(%rsp), %al
movb %al, 0x47(%rsp)
movb 0x47(%rsp), %al
andb $0x1, %al
movb %al, 0x1de(%rsp)
leaq 0x198(%rsp), %rdi
callq 0x14490
leaq 0x1c8(%rsp), %rdi
callq 0x14490
leaq 0x1c0(%rsp), %rdi
callq 0x14490
leaq 0x190(%rsp), %rdi
callq 0x14490
leaq 0x1d0(%rsp), %rdi
callq 0x14490
leaq 0x150(%rsp), %rdi
leaq 0x1ac44(%rip), %rsi     # 0x27ad0
movl $0x30, %edx
callq 0x4340
movq $0x0, 0x148(%rsp)
cmpq $0x6, 0x148(%rsp)
jae 0xcf59
movq 0x148(%rsp), %rax
movq 0x150(%rsp,%rax,8), %rax
movq %rax, 0x28(%rsp)
movq 0x148(%rsp), %rax
movq 0x150(%rsp,%rax,8), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x4230
movq 0x28(%rsp), %rdi
movq %rax, %rsi
callq 0x42a0
movq %rax, 0x140(%rsp)
xorl %eax, %eax
cmpq 0x140(%rsp), %rax
je 0xcf3e
movq 0x140(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x140(%rsp), %rdi
callq 0x142d0
movq 0x20(%rsp), %rsi
movq %rax, %rdx
leaq 0x12859(%rip), %rdi     # 0x1f783
movb $0x0, %al
callq 0x4180
leaq 0x140(%rsp), %rdi
callq 0x14490
jmp 0xcf40
movq 0x148(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x148(%rsp)
jmp 0xcea2
leaq 0x110(%rsp), %rdi
leaq 0x1ab98(%rip), %rsi     # 0x27b00
movl $0x28, %edx
callq 0x4340
movq $0x0, 0x108(%rsp)
cmpq $0x5, 0x108(%rsp)
jae 0xd035
movq 0x108(%rsp), %rax
movq 0x110(%rsp,%rax,8), %rax
movq %rax, 0x18(%rsp)
movq 0x108(%rsp), %rax
movq 0x110(%rsp,%rax,8), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x4230
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x42a0
movq %rax, 0x100(%rsp)
xorl %eax, %eax
cmpq 0x100(%rsp), %rax
je 0xd01a
movq 0x100(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x100(%rsp), %rdi
callq 0x141d0
movq 0x10(%rsp), %rsi
movq %rax, %rdx
leaq 0x127f9(%rip), %rdi     # 0x1f7ff
movb $0x0, %al
callq 0x4180
leaq 0x100(%rsp), %rdi
callq 0x14490
jmp 0xd01c
movq 0x108(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x108(%rsp)
jmp 0xcf7e
movq $0x0, 0xf8(%rsp)
cmpq $0x8, 0xf8(%rsp)
jae 0xd1a5
movb $0x0, 0xf7(%rsp)
movq 0xf8(%rsp), %rcx
leaq 0x1aac9(%rip), %rax     # 0x27b30
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
leaq 0xf7(%rsp), %rsi
callq 0x14330
andb $0x1, %al
movb %al, 0xf6(%rsp)
movb 0xf7(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movq 0xf8(%rsp), %rdx
leaq 0x1aa8e(%rip), %rcx     # 0x27b30
shlq $0x4, %rdx
addq %rdx, %rcx
movb 0x8(%rcx), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0xd103
movb $0x0, 0x1de(%rsp)
movq 0xf8(%rsp), %rcx
leaq 0x1aa63(%rip), %rax     # 0x27b30
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movb 0xf7(%rsp), %cl
leaq 0x127e7(%rip), %rdx     # 0x1f8cc
leaq 0x127db(%rip), %rax     # 0x1f8c7
testb $0x1, %cl
cmovneq %rax, %rdx
leaq 0x12798(%rip), %rdi     # 0x1f892
movb $0x0, %al
callq 0x4180
jmp 0xd146
movq 0xf8(%rsp), %rcx
leaq 0x1aa1e(%rip), %rax     # 0x27b30
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movb 0xf7(%rsp), %cl
leaq 0x127a2(%rip), %rdx     # 0x1f8cc
leaq 0x12796(%rip), %rax     # 0x1f8c7
testb $0x1, %cl
cmovneq %rax, %rdx
leaq 0x12793(%rip), %rdi     # 0x1f8d2
movb $0x0, %al
callq 0x4180
xorl %eax, %eax
testb $0x1, 0xf6(%rsp)
movb %al, 0xf(%rsp)
je 0xd161
movb 0x1de(%rsp), %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
andb $0x1, %al
movb %al, 0x1de(%rsp)
testb $0x1, 0xf6(%rsp)
jne 0xd18a
xorl %esi, %esi
movl %esi, %edi
callq 0x4da0
andb $0x1, %al
movb %al, 0xf5(%rsp)
jmp 0xd18c
movq 0xf8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xf8(%rsp)
jmp 0xd041
movq $0x0, 0xe8(%rsp)
cmpq $0xa, 0xe8(%rsp)
jae 0xd31a
movb $0x0, 0xe7(%rsp)
movq 0xe8(%rsp), %rcx
leaq 0x1a9d9(%rip), %rax     # 0x27bb0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
leaq 0xe7(%rsp), %rsi
movl $0x2, %edx
callq 0x13b90
andb $0x1, %al
movb %al, 0xe6(%rsp)
movb 0xe7(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movq 0xe8(%rsp), %rdx
leaq 0x1a999(%rip), %rcx     # 0x27bb0
shlq $0x4, %rdx
addq %rdx, %rcx
movb 0x8(%rcx), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0xd278
movb $0x0, 0x1de(%rsp)
movq 0xe8(%rsp), %rcx
leaq 0x1a96e(%rip), %rax     # 0x27bb0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movb 0xe7(%rsp), %cl
leaq 0x12672(%rip), %rdx     # 0x1f8cc
leaq 0x12666(%rip), %rax     # 0x1f8c7
testb $0x1, %cl
cmovneq %rax, %rdx
leaq 0x126f0(%rip), %rdi     # 0x1f95f
movb $0x0, %al
callq 0x4180
jmp 0xd2bb
movq 0xe8(%rsp), %rcx
leaq 0x1a929(%rip), %rax     # 0x27bb0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movb 0xe7(%rsp), %cl
leaq 0x1262d(%rip), %rdx     # 0x1f8cc
leaq 0x12621(%rip), %rax     # 0x1f8c7
testb $0x1, %cl
cmovneq %rax, %rdx
leaq 0x126dc(%rip), %rdi     # 0x1f990
movb $0x0, %al
callq 0x4180
xorl %eax, %eax
testb $0x1, 0xe6(%rsp)
movb %al, 0xe(%rsp)
je 0xd2d6
movb 0x1de(%rsp), %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
andb $0x1, %al
movb %al, 0x1de(%rsp)
testb $0x1, 0xe6(%rsp)
jne 0xd2ff
xorl %esi, %esi
movl %esi, %edi
callq 0x4da0
andb $0x1, %al
movb %al, 0xe5(%rsp)
jmp 0xd301
movq 0xe8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xe8(%rsp)
jmp 0xd1b1
callq 0xd510
cmpq $0x0, %rax
je 0xd32f
movl $0x0, 0x1b3bd(%rip)     # 0x286ec
movq $0x0, 0xd8(%rsp)
cmpq $0x4, 0xd8(%rsp)
jae 0xd3cc
movq 0xd8(%rsp), %rcx
leaq 0x1b387(%rip), %rax     # 0x286e0
movl (%rax,%rcx,4), %edi
callq 0x14590
testb $0x1, %al
jne 0xd367
jmp 0xd391
movb $0x0, 0x1de(%rsp)
movq 0xd8(%rsp), %rcx
leaq 0x1b362(%rip), %rax     # 0x286e0
movl (%rax,%rcx,4), %esi
leaq 0x12639(%rip), %rdi     # 0x1f9c1
movb $0x0, %al
callq 0x4180
jmp 0xd3b1
movq 0xd8(%rsp), %rcx
leaq 0x1b340(%rip), %rax     # 0x286e0
movl (%rax,%rcx,4), %esi
leaq 0x12645(%rip), %rdi     # 0x1f9ef
movb $0x0, %al
callq 0x4180
jmp 0xd3b3
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd8(%rsp)
jmp 0xd33b
movq $0x0, 0xd0(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0x1256c(%rip), %rsi     # 0x1f953
leaq 0x13d91(%rip), %rdx     # 0x2117f
movl $0x2, %ecx
callq 0x13c90
andb $0x1, %al
movb %al, 0xcf(%rsp)
testb $0x1, 0xcf(%rsp)
jne 0xd452
movb $0x0, 0x1de(%rsp)
callq 0x4070
movl (%rax), %edi
leaq 0x12278(%rip), %rsi     # 0x1f699
leaq 0x10105(%rip), %rdx     # 0x1d52d
movl $0x707, %ecx            # imm = 0x707
callq 0x10780
leaq 0x125e5(%rip), %rdi     # 0x1fa1e
leaq 0x12513(%rip), %rsi     # 0x1f953
movb $0x0, %al
callq 0x4180
xorl %esi, %esi
movl %esi, %edi
callq 0x4da0
jmp 0xd4ac
movq 0xd0(%rsp), %rdi
callq 0x4380
movl %eax, 0xc8(%rsp)
movl 0xc8(%rsp), %edi
callq 0x14590
testb $0x1, %al
jne 0xd495
movb $0x0, 0x1de(%rsp)
movl 0xc8(%rsp), %esi
leaq 0x125bb(%rip), %rdi     # 0x1fa47
movb $0x0, %al
callq 0x4180
jmp 0xd4aa
movl 0xc8(%rsp), %esi
leaq 0x125d3(%rip), %rdi     # 0x1fa76
movb $0x0, %al
callq 0x4180
jmp 0xd4ac
leaq 0xd0(%rsp), %rdi
callq 0x14530
callq 0xf580
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0xd(%rsp)
jne 0xd4cd
jmp 0xd4d8
movb 0x1de(%rsp), %al
movb %al, 0xd(%rsp)
movb 0xd(%rsp), %al
andb $0x1, %al
movb %al, 0x1de(%rsp)
movb 0x1de(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
andb $0x1, %al
addq $0x2e8, %rsp            # imm = 0x2E8
retq
nopw %cs:(%rax,%rax)