// File: /workspace/github_c_makefile_star2_O0/Jesskas[P]decompisas/source/disassembler/x86.c
// Function: parsePrefix
int parsePrefix(uint8_t byte){
    int numOfBytesHandled = 0;
    switch (byte) {
        case 0xF0: // LOCK
            numOfBytesHandled++;
            printf("[Unhandled Prefix 'Lock']");
            break;
        case 0xF2: // REPNE/REPNZ
            numOfBytesHandled++;
            printf("[Unhandled Prefix 'Repn{e,z}']");
            break;
        case 0xF3: // REP or REPE/REPZ
            numOfBytesHandled++;
            printf("[Unhandled Prefix 'Rep{,e,z}']");
            //struct Instruction instr = { 0 };
            //instr.instructionPrefix[0] = byte;
            /*
            Some of what I've seen;
            F3 A6 = repe cmpsb

            */
            break;

        //
        // TODO: unhanded prefixes.
        // will cause disassemby failures.
        //
        // Segment overrides:
        case 0x26:
            numOfBytesHandled++;
            printf("(ES) ");
            break;
        case 0x2E:
            numOfBytesHandled++;
            printf("(CS) ");
            // printf("[Unhandled branch not taken/mandatory) ");
            break;
        case 0x36:
            numOfBytesHandled++;
            printf("(SS) ");
            break;
        case 0x3E:
            numOfBytesHandled++;
            printf("(DS) ");
            break;
        case 0x64:
            numOfBytesHandled++;
            printf("(FS) ");
            break;
        case 0x65:
            numOfBytesHandled++;
            printf("(GS) ");
            break;
        // Others:
        case 0x66:
            numOfBytesHandled++;
            printf("(Unhanded Prefix 'Mandatory')");
            break;
        case 0x67:
            numOfBytesHandled++;
            printf("[Unhandled Prefix 0x67]");
            break;
        default:
            return 0;
    }

    return numOfBytesHandled;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movb %dil, %al
movb %al, -0x5(%rbp)
movl $0x0, -0xc(%rbp)
movzbl -0x5(%rbp), %eax
movl %eax, -0x10(%rbp)
subl $0x26, %eax
je 0x9b24
jmp 0x9a47
movl -0x10(%rbp), %eax
subl $0x2e, %eax
je 0x9b40
jmp 0x9a55
movl -0x10(%rbp), %eax
subl $0x36, %eax
je 0x9b5c
jmp 0x9a63
movl -0x10(%rbp), %eax
subl $0x3e, %eax
je 0x9b78
jmp 0x9a71
movl -0x10(%rbp), %eax
subl $0x64, %eax
je 0x9b91
jmp 0x9a7f
movl -0x10(%rbp), %eax
subl $0x65, %eax
je 0x9baa
jmp 0x9a8d
movl -0x10(%rbp), %eax
subl $0x66, %eax
je 0x9bc3
jmp 0x9a9b
movl -0x10(%rbp), %eax
subl $0x67, %eax
je 0x9bdc
jmp 0x9aa9
movl -0x10(%rbp), %eax
subl $0xf0, %eax
je 0x9ad0
jmp 0x9ab5
movl -0x10(%rbp), %eax
subl $0xf2, %eax
je 0x9aec
jmp 0x9ac1
movl -0x10(%rbp), %eax
subl $0xf3, %eax
je 0x9b08
jmp 0x9bf5
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x5175(%rip), %rdi      # 0xec55
movb $0x0, %al
callq 0x1050
jmp 0x9bfe
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x5173(%rip), %rdi      # 0xec6f
movb $0x0, %al
callq 0x1050
jmp 0x9bfe
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x5176(%rip), %rdi      # 0xec8e
movb $0x0, %al
callq 0x1050
jmp 0x9bfe
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x5179(%rip), %rdi      # 0xecad
movb $0x0, %al
callq 0x1050
jmp 0x9bfe
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x5163(%rip), %rdi      # 0xecb3
movb $0x0, %al
callq 0x1050
jmp 0x9bfe
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x514d(%rip), %rdi      # 0xecb9
movb $0x0, %al
callq 0x1050
jmp 0x9bfe
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x5137(%rip), %rdi      # 0xecbf
movb $0x0, %al
callq 0x1050
jmp 0x9bfe
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x5124(%rip), %rdi      # 0xecc5
movb $0x0, %al
callq 0x1050
jmp 0x9bfe
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x5111(%rip), %rdi      # 0xeccb
movb $0x0, %al
callq 0x1050
jmp 0x9bfe
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x50fe(%rip), %rdi      # 0xecd1
movb $0x0, %al
callq 0x1050
jmp 0x9bfe
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x5103(%rip), %rdi      # 0xecef
movb $0x0, %al
callq 0x1050
jmp 0x9bfe
movl $0x0, -0x4(%rbp)
jmp 0x9c04
movl -0xc(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)