// File: 7shi[P]8086run/v1/main.cpp
// Function: Operand::set(int, bool, int, SReg*)
inline void set(int type, bool w, int v, SReg *seg) {
        this->type = type;
        this->w = w;
        switch (type) {
            case Ptr:
                this->seg = seg ? seg : &DS;
                this->v = uint16_t(v);
                break;
            case ModRM + 0:
                this->seg = seg ? seg : &DS;
                this->v = uint16_t(BX + SI + v);
                break;
            case ModRM + 1:
                this->seg = seg ? seg : &DS;
                this->v = uint16_t(BX + DI + v);
                break;
            case ModRM + 2:
                this->seg = seg ? seg : &SS;
                this->v = uint16_t(BP + SI + v);
                break;
            case ModRM + 3:
                this->seg = seg ? seg : &SS;
                this->v = uint16_t(BP + DI + v);
                break;
            case ModRM + 4:
                this->seg = seg ? seg : &DS;
                this->v = uint16_t(SI + v);
                break;
            case ModRM + 5:
                this->seg = seg ? seg : &DS;
                this->v = uint16_t(DI + v);
                break;
            case ModRM + 6:
                this->seg = seg ? seg : &SS;
                this->v = uint16_t(BP + v);
                break;
            case ModRM + 7:
                this->seg = seg ? seg : &DS;
                this->v = uint16_t(BX + v);
                break;
            default:
                this->seg = NULL;
                this->v = v;
                break;
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
andb $0x1, %al
movb %al, -0xd(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0xc(%rbp), %ecx
movl %ecx, (%rax)
movb -0xd(%rbp), %cl
andb $0x1, %cl
movb %cl, 0x4(%rax)
movl -0xc(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x8, %eax
ja 0x6b5a
movq -0x28(%rbp), %rax
leaq 0x1c91(%rip), %rcx      # 0x8570
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpq $0x0, -0x20(%rbp)
je 0x68f9
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x690a
leaq 0x124a30(%rip), %rax    # 0x12b330
addq $0x30, %rax
movq %rax, -0x38(%rbp)
jmp 0x690a
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl -0x14(%rbp), %ecx
movzwl %cx, %ecx
movl %ecx, 0x8(%rax)
jmp 0x6b6c
cmpq $0x0, -0x20(%rbp)
je 0x6935
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x6946
leaq 0x1249f4(%rip), %rax    # 0x12b330
addq $0x30, %rax
movq %rax, -0x40(%rbp)
jmp 0x6946
movq -0x30(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, 0x10(%rax)
movzwl 0x12487d(%rip), %ecx    # 0x12b1d6
movzwl 0x12487c(%rip), %edx    # 0x12b1dc
addl %edx, %ecx
addl -0x14(%rbp), %ecx
movzwl %cx, %ecx
movl %ecx, 0x8(%rax)
jmp 0x6b6c
cmpq $0x0, -0x20(%rbp)
je 0x6981
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x6992
leaq 0x1249a8(%rip), %rax    # 0x12b330
addq $0x30, %rax
movq %rax, -0x48(%rbp)
jmp 0x6992
movq -0x30(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, 0x10(%rax)
movzwl 0x124831(%rip), %ecx    # 0x12b1d6
movzwl 0x124832(%rip), %edx    # 0x12b1de
addl %edx, %ecx
addl -0x14(%rbp), %ecx
movzwl %cx, %ecx
movl %ecx, 0x8(%rax)
jmp 0x6b6c
cmpq $0x0, -0x20(%rbp)
je 0x69cd
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x69de
leaq 0x12495c(%rip), %rax    # 0x12b330
addq $0x20, %rax
movq %rax, -0x50(%rbp)
jmp 0x69de
movq -0x30(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, 0x10(%rax)
movzwl 0x1247e9(%rip), %ecx    # 0x12b1da
movzwl 0x1247e4(%rip), %edx    # 0x12b1dc
addl %edx, %ecx
addl -0x14(%rbp), %ecx
movzwl %cx, %ecx
movl %ecx, 0x8(%rax)
jmp 0x6b6c
cmpq $0x0, -0x20(%rbp)
je 0x6a19
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x6a2a
leaq 0x124910(%rip), %rax    # 0x12b330
addq $0x20, %rax
movq %rax, -0x58(%rbp)
jmp 0x6a2a
movq -0x30(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, 0x10(%rax)
movzwl 0x12479d(%rip), %ecx    # 0x12b1da
movzwl 0x12479a(%rip), %edx    # 0x12b1de
addl %edx, %ecx
addl -0x14(%rbp), %ecx
movzwl %cx, %ecx
movl %ecx, 0x8(%rax)
jmp 0x6b6c
cmpq $0x0, -0x20(%rbp)
je 0x6a65
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x6a76
leaq 0x1248c4(%rip), %rax    # 0x12b330
addq $0x30, %rax
movq %rax, -0x60(%rbp)
jmp 0x6a76
movq -0x30(%rbp), %rax
movq -0x60(%rbp), %rcx
movq %rcx, 0x10(%rax)
movzwl 0x124753(%rip), %ecx    # 0x12b1dc
addl -0x14(%rbp), %ecx
movzwl %cx, %ecx
movl %ecx, 0x8(%rax)
jmp 0x6b6c
cmpq $0x0, -0x20(%rbp)
je 0x6aa8
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x6ab9
leaq 0x124881(%rip), %rax    # 0x12b330
addq $0x30, %rax
movq %rax, -0x68(%rbp)
jmp 0x6ab9
movq -0x30(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rcx, 0x10(%rax)
movzwl 0x124712(%rip), %ecx    # 0x12b1de
addl -0x14(%rbp), %ecx
movzwl %cx, %ecx
movl %ecx, 0x8(%rax)
jmp 0x6b6c
cmpq $0x0, -0x20(%rbp)
je 0x6aeb
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x6afc
leaq 0x12483e(%rip), %rax    # 0x12b330
addq $0x20, %rax
movq %rax, -0x70(%rbp)
jmp 0x6afc
movq -0x30(%rbp), %rax
movq -0x70(%rbp), %rcx
movq %rcx, 0x10(%rax)
movzwl 0x1246cb(%rip), %ecx    # 0x12b1da
addl -0x14(%rbp), %ecx
movzwl %cx, %ecx
movl %ecx, 0x8(%rax)
jmp 0x6b6c
cmpq $0x0, -0x20(%rbp)
je 0x6b2b
movq -0x20(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x6b3c
leaq 0x1247fe(%rip), %rax    # 0x12b330
addq $0x30, %rax
movq %rax, -0x78(%rbp)
jmp 0x6b3c
movq -0x30(%rbp), %rax
movq -0x78(%rbp), %rcx
movq %rcx, 0x10(%rax)
movzwl 0x124687(%rip), %ecx    # 0x12b1d6
addl -0x14(%rbp), %ecx
movzwl %cx, %ecx
movl %ecx, 0x8(%rax)
jmp 0x6b6c
movq -0x30(%rbp), %rax
movq $0x0, 0x10(%rax)
movl -0x14(%rbp), %ecx
movl %ecx, 0x8(%rax)
popq %rbp
retq
nop