// File: olly-larkin[P]mips-parser/src/instructionList.cpp
// Function: R_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)
uint32_t R_TYPE(std::vector<std::string>& argVec, const std::vector<OP_TYPE>& opcodes, int fn, int pc) {
    uint32_t returnNum = fn;
    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 shAmt:
                int32_t shAmtNum;
                if (!validIntStr(argVec[i+1], shAmtNum))
                    exitError("Invalid instruction argument \"" + giveStr(argVec) + "\" on instruction number " + std::to_string(pc+1), 5);
                returnNum = returnNum | ((shAmtNum & 0x1F) << 6);
                break;
            case $d:
                returnNum = returnNum | ((regMap[argVec[i+1]] & 0x1F) << 11);
                break;
            case $t:
                returnNum = returnNum | ((regMap[argVec[i+1]] & 0x1F) << 16);
                break;
            case $s:
                returnNum = returnNum | ((regMap[argVec[i+1]] & 0x1F) << 21);
                break;
            default:
                break;
        }
    }
    return returnNum;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x1c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x10ee0
movl $0x0, -0x3c(%rbp)
movslq -0x3c(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10f00
movq %rax, %rcx
movq -0x1f0(%rbp), %rax
cmpq %rcx, %rax
jae 0xcd52
movq -0x10(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
callq 0x10f20
cmpl $0x0, (%rax)
je 0xcd18
movq -0x10(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
callq 0x10f20
cmpl $0x1, (%rax)
je 0xcd18
movq -0x10(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
callq 0x10f20
cmpl $0x2, (%rax)
jne 0xcd42
movl -0x3c(%rbp), %eax
incl %eax
movl %eax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x10f40
jmp 0xcd2f
jmp 0xcd42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xd2c4
jmp 0xcd44
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xccbf
movq -0x8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xcb20
movb %al, -0x1f1(%rbp)
jmp 0xcd67
movb -0x1f1(%rbp), %al
testb $0x1, %al
jne 0xcef8
jmp 0xcd77
movq -0x8(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
callq 0xc070
jmp 0xcd89
leaq -0xd0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0xca30
jmp 0xcd9e
leaq 0x66e4(%rip), %rsi      # 0x13489
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rdx
callq 0x10f70
jmp 0xcdba
leaq 0x6446(%rip), %rdx      # 0x13207
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x5a30
jmp 0xcdd6
movl -0x18(%rbp), %esi
incl %esi
leaq -0x108(%rbp), %rdi
callq 0x10fc0
jmp 0xcde9
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0x108(%rbp), %rdx
callq 0x7810
jmp 0xce02
leaq -0x70(%rbp), %rdi
movl $0x5, %esi
callq 0xc9e0
jmp 0xce12
leaq -0x70(%rbp), %rdi
callq 0x31a0
leaq -0x108(%rbp), %rdi
callq 0x31a0
leaq -0x90(%rbp), %rdi
callq 0x31a0
leaq -0xb0(%rbp), %rdi
callq 0x31a0
leaq -0xd0(%rbp), %rdi
callq 0x31a0
leaq -0xe8(%rbp), %rdi
callq 0x5c60
jmp 0xcef8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xcee7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xcedb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xcecf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xcec3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xceb7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x31a0
leaq -0x108(%rbp), %rdi
callq 0x31a0
leaq -0x90(%rbp), %rdi
callq 0x31a0
leaq -0xb0(%rbp), %rdi
callq 0x31a0
leaq -0xd0(%rbp), %rdi
callq 0x31a0
leaq -0xe8(%rbp), %rdi
callq 0x5c60
jmp 0xd2c4
movl $0x0, -0x10c(%rbp)
movslq -0x10c(%rbp), %rax
movq %rax, -0x200(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10f00
movq %rax, %rcx
movq -0x200(%rbp), %rax
cmpq %rcx, %rax
jae 0xd2a3
movq -0x10(%rbp), %rdi
movslq -0x10c(%rbp), %rsi
callq 0x10f20
movl (%rax), %eax
movq %rax, -0x208(%rbp)
subq $0x3, %rax
ja 0xd28b
movq -0x208(%rbp), %rax
leaq 0x640f(%rip), %rcx      # 0x1336c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
movl -0x10c(%rbp), %eax
incl %eax
movslq %eax, %rsi
callq 0x7c20
movq %rax, %rsi
leaq -0x130(%rbp), %rdi
callq 0x3120
jmp 0xcf8b
leaq -0x130(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x5fb0
movb %al, -0x209(%rbp)
jmp 0xcfa6
movb -0x209(%rbp), %al
xorb $-0x1, %al
movb %al, -0x20a(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x31a0
movb -0x20a(%rbp), %al
testb $0x1, %al
jne 0xcfcf
jmp 0xd17c
movq -0x8(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
callq 0xc070
jmp 0xcfe1
leaq -0x1b0(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0xca30
jmp 0xcff6
leaq 0x64a5(%rip), %rsi      # 0x134a2
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rdx
callq 0x10f70
jmp 0xd012
leaq 0x61ee(%rip), %rdx      # 0x13207
leaq -0x170(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x5a30
jmp 0xd02e
movl -0x18(%rbp), %esi
incl %esi
leaq -0x1e8(%rbp), %rdi
callq 0x10fc0
jmp 0xd041
leaq -0x150(%rbp), %rdi
leaq -0x170(%rbp), %rsi
leaq -0x1e8(%rbp), %rdx
callq 0x7810
jmp 0xd05d
leaq -0x150(%rbp), %rdi
movl $0x5, %esi
callq 0xc9e0
jmp 0xd070
leaq -0x150(%rbp), %rdi
callq 0x31a0
leaq -0x1e8(%rbp), %rdi
callq 0x31a0
leaq -0x170(%rbp), %rdi
callq 0x31a0
leaq -0x190(%rbp), %rdi
callq 0x31a0
leaq -0x1b0(%rbp), %rdi
callq 0x31a0
leaq -0x1c8(%rbp), %rdi
callq 0x5c60
jmp 0xd17c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x31a0
jmp 0xd2c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xd16b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xd15f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xd153
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xd147
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xd13b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x31a0
leaq -0x1e8(%rbp), %rdi
callq 0x31a0
leaq -0x170(%rbp), %rdi
callq 0x31a0
leaq -0x190(%rbp), %rdi
callq 0x31a0
leaq -0x1b0(%rbp), %rdi
callq 0x31a0
leaq -0x1c8(%rbp), %rdi
callq 0x5c60
jmp 0xd2c4
movl -0x1c(%rbp), %eax
movl -0x110(%rbp), %ecx
andl $0x1f, %ecx
shll $0x6, %ecx
orl %ecx, %eax
movl %eax, -0x1c(%rbp)
jmp 0xd28d
movl -0x1c(%rbp), %eax
movl %eax, -0x21c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10c(%rbp), %eax
incl %eax
movslq %eax, %rsi
callq 0x7c20
movq %rax, %rsi
leaq 0xe114(%rip), %rdi      # 0x1b2d0
callq 0x74c0
movq %rax, -0x218(%rbp)
jmp 0xd1ca
movl -0x21c(%rbp), %eax
movq -0x218(%rbp), %rcx
movl (%rcx), %ecx
andl $0x1f, %ecx
shll $0xb, %ecx
orl %ecx, %eax
movl %eax, -0x1c(%rbp)
jmp 0xd28d
movl -0x1c(%rbp), %eax
movl %eax, -0x22c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10c(%rbp), %eax
incl %eax
movslq %eax, %rsi
callq 0x7c20
movq %rax, %rsi
leaq 0xe0c0(%rip), %rdi      # 0x1b2d0
callq 0x74c0
movq %rax, -0x228(%rbp)
jmp 0xd21e
movl -0x22c(%rbp), %eax
movq -0x228(%rbp), %rcx
movl (%rcx), %ecx
andl $0x1f, %ecx
shll $0x10, %ecx
orl %ecx, %eax
movl %eax, -0x1c(%rbp)
jmp 0xd28d
movl -0x1c(%rbp), %eax
movl %eax, -0x23c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10c(%rbp), %eax
incl %eax
movslq %eax, %rsi
callq 0x7c20
movq %rax, %rsi
leaq 0xe06f(%rip), %rdi      # 0x1b2d0
callq 0x74c0
movq %rax, -0x238(%rbp)
jmp 0xd26f
movl -0x23c(%rbp), %eax
movq -0x238(%rbp), %rcx
movl (%rcx), %ecx
andl $0x1f, %ecx
shll $0x15, %ecx
orl %ecx, %eax
movl %eax, -0x1c(%rbp)
jmp 0xd28d
jmp 0xd28d
jmp 0xd28f
movl -0x10c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10c(%rbp)
jmp 0xcf02
movl -0x1c(%rbp), %eax
movl %eax, -0x240(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x110e0
movl -0x240(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x110e0
movq -0x48(%rbp), %rdi
callq 0x3420
nopw %cs:(%rax,%rax)