// File: /workspace/github_c_makefile_star2_O1/buptlxb[P]xRay/disasm/Routines_Disasm.c
// Function: FillSegmentsRegisters
void __bea_callspec__ FillSegmentsRegisters(PDISASM pMyDisasm)
{
    if (((*pMyDisasm).Prefix.LockPrefix == InUsePrefix) && !((*pMyDisasm).Argument1.ArgType & MEMORY_TYPE)) {
        (*pMyDisasm).Prefix.LockPrefix = InvalidPrefix;
    }
    if ((*pMyDisasm).Instruction.Category == GENERAL_PURPOSE_INSTRUCTION+STRING_INSTRUCTION) {
        (*pMyDisasm).Argument1.SegmentReg = ESReg;
        (*pMyDisasm).Argument2.SegmentReg = DSReg;
        /* =============== override affects Arg2 */
        if ((*pMyDisasm).Argument2.ArgType & MEMORY_TYPE) {
            if ((*pMyDisasm).Prefix.FSPrefix == InUsePrefix) {
                (*pMyDisasm).Argument2.SegmentReg = FSReg;
            }
            else if ((*pMyDisasm).Prefix.GSPrefix == InUsePrefix) {
                (*pMyDisasm).Argument2.SegmentReg = GSReg;
            }
            else if ((*pMyDisasm).Prefix.CSPrefix == InUsePrefix) {
                (*pMyDisasm).Argument2.SegmentReg = CSReg;
            }
            else if ((*pMyDisasm).Prefix.ESPrefix == InUsePrefix) {
                (*pMyDisasm).Argument2.SegmentReg = ESReg;
            }
            else if ((*pMyDisasm).Prefix.SSPrefix == InUsePrefix) {
                (*pMyDisasm).Argument2.SegmentReg = SSReg;
            }
            else {
                (*pMyDisasm).Argument2.SegmentReg = DSReg;
            }
        }
    }
    else {
        if ((*pMyDisasm).Argument1.ArgType & MEMORY_TYPE) {
            if (((*pMyDisasm).Argument1.Memory.BaseRegister == REG4) || ((*pMyDisasm).Argument1.Memory.BaseRegister == REG5)) {
                (*pMyDisasm).Argument1.SegmentReg = SSReg;
                /* ========== override is invalid here */
                if ((*pMyDisasm).Argument2.ArgType != MEMORY_TYPE) {
                    if ((*pMyDisasm).Prefix.FSPrefix == InUsePrefix) {
                        (*pMyDisasm).Argument1.SegmentReg = FSReg;
                        (*pMyDisasm).Prefix.FSPrefix = InvalidPrefix;
                    }
                    else if ((*pMyDisasm).Prefix.GSPrefix == InUsePrefix) {
                        (*pMyDisasm).Argument1.SegmentReg = GSReg;
                        (*pMyDisasm).Prefix.GSPrefix = InvalidPrefix;
                    }
                    else if ((*pMyDisasm).Prefix.CSPrefix == InUsePrefix) {
                        (*pMyDisasm).Argument1.SegmentReg = CSReg;
                        (*pMyDisasm).Prefix.CSPrefix = InvalidPrefix;
                    }
                    else if ((*pMyDisasm).Prefix.DSPrefix == InUsePrefix) {
                        (*pMyDisasm).Argument1.SegmentReg = DSReg;
                        (*pMyDisasm).Prefix.DSPrefix = InvalidPrefix;
                    }
                    else if ((*pMyDisasm).Prefix.ESPrefix == InUsePrefix) {
                        (*pMyDisasm).Argument1.SegmentReg = ESReg;
                        (*pMyDisasm).Prefix.ESPrefix = InvalidPrefix;
                    }
                    else if ((*pMyDisasm).Prefix.SSPrefix == InUsePrefix) {
                        (*pMyDisasm).Argument1.SegmentReg = SSReg;
                        (*pMyDisasm).Prefix.SSPrefix = InvalidPrefix;
                    }
                }
            }
            else {
                (*pMyDisasm).Argument1.SegmentReg = DSReg;
                /* ============= test if there is override */
                if ((*pMyDisasm).Prefix.FSPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument1.SegmentReg = FSReg;
                }
                else if ((*pMyDisasm).Prefix.GSPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument1.SegmentReg = GSReg;
                }
                else if ((*pMyDisasm).Prefix.CSPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument1.SegmentReg = CSReg;
                }
                else if ((*pMyDisasm).Prefix.ESPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument1.SegmentReg = ESReg;
                }
                else if ((*pMyDisasm).Prefix.SSPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument1.SegmentReg = SSReg;
                }
            }
        }

        if ((*pMyDisasm).Argument2.ArgType & MEMORY_TYPE) {
            if (((*pMyDisasm).Argument2.Memory.BaseRegister == REG4) || ((*pMyDisasm).Argument2.Memory.BaseRegister == REG5)) {
                (*pMyDisasm).Argument2.SegmentReg = SSReg;
                /* ========== override is invalid here */
                if ((*pMyDisasm).Prefix.FSPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument2.SegmentReg = FSReg;
                    (*pMyDisasm).Prefix.FSPrefix = InvalidPrefix;
                }
                else if ((*pMyDisasm).Prefix.GSPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument2.SegmentReg = GSReg;
                    (*pMyDisasm).Prefix.GSPrefix = InvalidPrefix;
                }
                else if ((*pMyDisasm).Prefix.CSPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument2.SegmentReg = CSReg;
                    (*pMyDisasm).Prefix.CSPrefix = InvalidPrefix;
                }
                else if ((*pMyDisasm).Prefix.DSPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument2.SegmentReg = DSReg;
                    (*pMyDisasm).Prefix.DSPrefix = InvalidPrefix;
                }
                else if ((*pMyDisasm).Prefix.ESPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument2.SegmentReg = ESReg;
                    (*pMyDisasm).Prefix.ESPrefix = InvalidPrefix;
                }
                else if ((*pMyDisasm).Prefix.SSPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument2.SegmentReg = SSReg;
                    (*pMyDisasm).Prefix.SSPrefix = InvalidPrefix;
                }
            }
            else {
                (*pMyDisasm).Argument2.SegmentReg = DSReg;
                /* ============= test if there is override */
                if ((*pMyDisasm).Prefix.FSPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument2.SegmentReg = FSReg;
                }
                else if ((*pMyDisasm).Prefix.GSPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument2.SegmentReg = GSReg;
                }
                else if ((*pMyDisasm).Prefix.CSPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument2.SegmentReg = CSReg;
                }
                else if ((*pMyDisasm).Prefix.ESPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument2.SegmentReg = ESReg;
                }
                else if ((*pMyDisasm).Prefix.SSPrefix == InUsePrefix) {
                    (*pMyDisasm).Argument2.SegmentReg = SSReg;
                }
            }
        }
    }
}

// Assembly:
cmpb $0x1, 0x1dc(%rdi)
jne 0x2bdac
testb $0x40, 0xdf(%rdi)
jne 0x2bdac
movb $0x4, 0x1dc(%rdi)
cmpl $0x10007, 0x60(%rdi)    # imm = 0x10007
jne 0x2be22
movl $0x1, 0x100(%rdi)
movl $0x2, 0x168(%rdi)
testb $0x40, 0x147(%rdi)
je 0x2bf8a
cmpb $0x1, 0x1e1(%rdi)
je 0x2bfee
cmpb $0x1, 0x1e3(%rdi)
je 0x2c01d
cmpb $0x1, 0x1e5(%rdi)
je 0x2c04c
cmpb $0x1, 0x1e4(%rdi)
je 0x2c07b
cmpb $0x1, 0x1e2(%rdi)
je 0x2c0b2
movl $0x2, 0x168(%rdi)
retq
testb $0x40, 0xdf(%rdi)
je 0x2bf81
movl 0xec(%rdi), %eax
cmpl $0x20, %eax
je 0x2be3f
cmpl $0x10, %eax
jne 0x2be78
movl $0x6, 0x100(%rdi)
cmpl $0x40000000, 0x144(%rdi) # imm = 0x40000000
je 0x2bf81
cmpb $0x1, 0x1e1(%rdi)
jne 0x2be9a
movl $0x3, 0x100(%rdi)
movb $0x4, 0x1e1(%rdi)
jmp 0x2bf81
movl $0x2, 0x100(%rdi)
cmpb $0x1, 0x1e1(%rdi)
jne 0x2beb9
movl $0x3, 0x100(%rdi)
jmp 0x2bf81
cmpb $0x1, 0x1e3(%rdi)
jne 0x2bed1
movl $0x4, 0x100(%rdi)
movb $0x4, 0x1e3(%rdi)
jmp 0x2bf81
cmpb $0x1, 0x1e3(%rdi)
jne 0x2bef0
movl $0x4, 0x100(%rdi)
jmp 0x2bf81
cmpb $0x1, 0x1e5(%rdi)
jne 0x2bf05
movl $0x5, 0x100(%rdi)
movb $0x4, 0x1e5(%rdi)
jmp 0x2bf81
cmpb $0x1, 0x1e5(%rdi)
jne 0x2bf21
movl $0x5, 0x100(%rdi)
jmp 0x2bf81
cmpb $0x1, 0x1e6(%rdi)
jne 0x2bf36
movl $0x2, 0x100(%rdi)
movb $0x4, 0x1e6(%rdi)
jmp 0x2bf81
cmpb $0x1, 0x1e4(%rdi)
jne 0x2bf52
movl $0x1, 0x100(%rdi)
jmp 0x2bf81
cmpb $0x1, 0x1e4(%rdi)
jne 0x2bf67
movl $0x1, 0x100(%rdi)
movb $0x4, 0x1e4(%rdi)
jmp 0x2bf81
cmpb $0x1, 0x1e2(%rdi)
jne 0x2bf81
movl $0x6, 0x100(%rdi)
jmp 0x2bf81
cmpb $0x1, 0x1e2(%rdi)
jne 0x2bf81
movl $0x6, 0x100(%rdi)
movb $0x4, 0x1e2(%rdi)
testb $0x40, 0x147(%rdi)
jne 0x2bf8b
retq
movl 0x154(%rdi), %eax
cmpl $0x20, %eax
je 0x2bf9b
cmpl $0x10, %eax
jne 0x2bfdb
movl $0x6, 0x168(%rdi)
cmpb $0x1, 0x1e1(%rdi)
jne 0x2bfc0
movl $0x3, 0x168(%rdi)
movb $0x4, 0x1e1(%rdi)
retq
cmpb $0x1, 0x1e3(%rdi)
jne 0x2bff9
movl $0x4, 0x168(%rdi)
movb $0x4, 0x1e3(%rdi)
retq
movl $0x2, 0x168(%rdi)
cmpb $0x1, 0x1e1(%rdi)
jne 0x2c014
movl $0x3, 0x168(%rdi)
retq
cmpb $0x1, 0x1e5(%rdi)
jne 0x2c028
movl $0x5, 0x168(%rdi)
movb $0x4, 0x1e5(%rdi)
retq
cmpb $0x1, 0x1e3(%rdi)
jne 0x2c043
movl $0x4, 0x168(%rdi)
retq
cmpb $0x1, 0x1e6(%rdi)
jne 0x2c057
movl $0x2, 0x168(%rdi)
movb $0x4, 0x1e6(%rdi)
retq
cmpb $0x1, 0x1e5(%rdi)
jne 0x2c072
movl $0x5, 0x168(%rdi)
retq
cmpb $0x1, 0x1e4(%rdi)
jne 0x2c086
movl $0x1, 0x168(%rdi)
movb $0x4, 0x1e4(%rdi)
retq
cmpb $0x1, 0x1e4(%rdi)
jne 0x2c0a5
movl $0x1, 0x168(%rdi)
retq
cmpb $0x1, 0x1e2(%rdi)
jne 0x2bf8a
movl $0x6, 0x168(%rdi)
movb $0x4, 0x1e2(%rdi)
retq
cmpb $0x1, 0x1e2(%rdi)
jne 0x2bf8a
movl $0x6, 0x168(%rdi)
retq