// File: /workspace/github_cpp_makefile_star2_O2/olly-larkin[P]mips-parser/src/instructionList.cpp
// Function: I_TYPE(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, std::vector<OP_TYPE, std::allocator<OP_TYPE>> const&, int, int, bool)
uint32_t I_TYPE(std::vector<std::string>& argVec, const std::vector<OP_TYPE>& opcodes, int op, int pc, bool branch) {
    uint32_t returnNum = (op << 26) & 0xFC000000;
    int32_t immediate = 0;
    std::vector<int> index;
    for(int i = 0; i < opcodes.size(); ++i) {
        if (opcodes[i] == $s || opcodes[i] == $t || opcodes[i] == $d)
            index.push_back(i+1);
    }
    if (!regCheck(argVec, index))
        exitError("Invalid register input \"" + giveStr(argVec) + "\" on instruction number " + std::to_string(pc+1), 5);
    for(int i = 0; i < opcodes.size(); ++i) {
        switch(opcodes[i]) {
            case imm:
                if (branch && labelReturn(argVec[i+1], immediate)) {
                    immediate = immediate - ((pc+1)*4 + 0x10000000);
                    immediate = immediate >> 2;

                } else {
                    if (!validIntStr(argVec[i+1], immediate))
                        exitError("Invalid instruction argument \"" + giveStr(argVec) + "\" on instruction number " + std::to_string(pc+1), 5);
                }
                returnNum = returnNum | (immediate & 0xFFFF);
                break;
            case $t:
                returnNum = returnNum | ((regMap[argVec[i+1]] & 0x1F) << 16);
                break;
            case $s:
                returnNum = returnNum | ((regMap[argVec[i+1]] & 0x1F) << 21);
                break;
            case regMem:
                int offset, reg;
                if (!regMemSeperator(argVec[i+1], offset, reg))
                    exitError("Invalid instruction argument \"" + giveStr(argVec) + "\" on instruction number " + std::to_string(i+1), 5);
                returnNum = returnNum | (offset & 0xFFFF) | ((reg & 0x1F) << 21);
                break;
            default:
                break;
        }
    }
    return returnNum;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movl %r8d, -0x48(%rbp)
movq %rcx, -0x40(%rbp)
movq %rsi, %r13
movq %rdi, -0x38(%rbp)
shll $0x1a, %edx
movl %edx, -0x2c(%rbp)
andl $0x0, -0x30(%rbp)
leaq -0x130(%rbp), %rbx
andq $0x0, 0x10(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
xorl %r14d, %r14d
leaq -0x70(%rbp), %r12
movq (%r13), %rax
movq 0x8(%r13), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jbe 0x6603
cmpl $0x3, (%rax,%r14,4)
jae 0x65fe
incq %r14
movl %r14d, -0x70(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x89e8
jmp 0x65cf
incq %r14
jmp 0x65cf
leaq -0x130(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x6107
testb %al, %al
je 0x690d
movq -0x40(%rbp), %rax
leal (,%rax,4), %eax
movl %eax, -0x44(%rbp)
pushq $0x20
popq %r14
xorl %ebx, %ebx
leaq -0x110(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
movq (%r13), %rax
movq 0x8(%r13), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rbx, %rcx
jbe 0x67d5
movl (%rax,%rbx,4), %eax
cmpq $0x5, %rax
ja 0x67c9
leaq 0x2d13(%rip), %rcx      # 0x937c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x38(%rbp), %rax
movq (%rax), %rsi
addq %r14, %rsi
leaq 0x7bcd(%rip), %rdi      # 0xe250
callq 0x493a
movl (%rax), %eax
andl $0x1f, %eax
shll $0x15, %eax
jmp 0x6717
cmpb $0x0, -0x48(%rbp)
je 0x6778
movq -0x38(%rbp), %rax
movq (%rax), %rsi
addq %r14, %rsi
leaq -0x1d8(%rbp), %rdi
callq 0x2280
leaq -0x1d8(%rbp), %r15
movq %r15, %rdi
leaq -0x30(%rbp), %rsi
callq 0x4753
movl %eax, %r12d
movq %r15, %rdi
callq 0x2120
testb %r12b, %r12b
leaq -0x110(%rbp), %rdx
je 0x6778
movl -0x30(%rbp), %eax
subl -0x44(%rbp), %eax
addl $0xeffffffc, %eax       # imm = 0xEFFFFFFC
sarl $0x2, %eax
movl %eax, -0x30(%rbp)
jmp 0x67bc
movq -0x38(%rbp), %rax
movq (%rax), %rsi
addq %r14, %rsi
leaq 0x7b46(%rip), %rdi      # 0xe250
callq 0x493a
movl (%rax), %eax
andl $0x1f, %eax
shll $0x10, %eax
orl %eax, -0x2c(%rbp)
jmp 0x6768
movq -0x38(%rbp), %rax
movq (%rax), %rsi
addq %r14, %rsi
callq 0x2280
leaq -0xf0(%rbp), %r15
movq %r15, %rdi
leaq -0x50(%rbp), %rsi
leaq -0x4c(%rbp), %rdx
callq 0x6b02
movl %eax, %r12d
movq %r15, %rdi
callq 0x2120
testb %r12b, %r12b
je 0x67f6
movzwl -0x50(%rbp), %eax
movl -0x4c(%rbp), %ecx
andl $0x1f, %ecx
shll $0x15, %ecx
orl %eax, %ecx
orl %ecx, -0x2c(%rbp)
leaq -0x110(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
jmp 0x67c9
movq -0x38(%rbp), %rax
movq (%rax), %rsi
addq %r14, %rsi
movq %rdx, %rdi
callq 0x2280
leaq -0x110(%rbp), %r15
movq %r15, %rdi
leaq -0x30(%rbp), %rsi
callq 0x3f5c
movl %eax, %r12d
movq %r15, %rdi
callq 0x2120
testb %r12b, %r12b
je 0x6881
movzwl -0x30(%rbp), %eax
leaq -0x110(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
movzwl %ax, %eax
orl %eax, -0x2c(%rbp)
incq %rbx
addq $0x20, %r14
jmp 0x663d
leaq -0x130(%rbp), %rdi
callq 0x89d4
movl -0x2c(%rbp), %eax
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x148(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5d5c
leaq -0xb0(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x6066
leaq 0x2c82(%rip), %rsi      # 0x94a2
leaq -0xd0(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
callq 0x8759
leaq 0x29cd(%rip), %rdx      # 0x9207
leaq -0x70(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3e83
incq %rbx
leaq -0x90(%rbp), %rdi
movl %ebx, %esi
callq 0x8787
leaq -0x198(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x4a7a
leaq -0x198(%rbp), %rdi
pushq $0x5
popq %rsi
callq 0x6038
leaq -0x160(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5d5c
leaq -0xb0(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x6066
leaq 0x2bf7(%rip), %rsi      # 0x94a2
leaq -0xd0(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
callq 0x8759
leaq 0x2942(%rip), %rdx      # 0x9207
leaq -0x70(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3e83
movq -0x40(%rbp), %rsi
incl %esi
leaq -0x90(%rbp), %rdi
callq 0x8787
leaq -0x1b8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x4a7a
leaq -0x1b8(%rbp), %rdi
pushq $0x5
popq %rsi
callq 0x6038
leaq -0x178(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x5d5c
leaq -0xb0(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x6066
leaq 0x2b52(%rip), %rsi      # 0x9489
leaq -0xd0(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
callq 0x8759
leaq 0x28b6(%rip), %rdx      # 0x9207
leaq -0x70(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3e83
movq -0x40(%rbp), %rsi
incl %esi
leaq -0x90(%rbp), %rdi
callq 0x8787
leaq -0x1f8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x4a7a
leaq -0x1f8(%rbp), %rdi
pushq $0x5
popq %rsi
callq 0x6038
movq %rax, %rbx
leaq -0x1f8(%rbp), %rdi
callq 0x2120
jmp 0x69ad
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x2120
jmp 0x69be
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x2120
jmp 0x69cc
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x2120
jmp 0x6a21
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
callq 0x2120
jmp 0x69ee
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x2120
jmp 0x6a32
movq %rax, %rbx
leaq -0x198(%rbp), %rdi
callq 0x2120
jmp 0x6a10
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x2120
jmp 0x6a40
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x2120
jmp 0x6a4e
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x2120
jmp 0x6a5a
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x2120
jmp 0x6a6b
movq %rax, %rbx
leaq -0x178(%rbp), %rdi
jmp 0x6ab5
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x2120
jmp 0x6a7e
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x2120
jmp 0x6a8f
jmp 0x6aeb
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x2120
jmp 0x6aa2
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x2120
jmp 0x6aae
jmp 0x6aeb
movq %rax, %rbx
leaq -0x160(%rbp), %rdi
jmp 0x6ab5
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
callq 0x3ef4
jmp 0x6aee
jmp 0x6aeb
movq %rax, %rbx
leaq -0x1d8(%rbp), %rdi
jmp 0x6ae2
jmp 0x6aeb
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
jmp 0x6ae2
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x2120
jmp 0x6aee
jmp 0x6aeb
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0x89d4
movq %rbx, %rdi
callq 0x2330