// File: /workspace/github_cpp_makefile_star2_O3/7shi[P]8086run/v1/main.cpp
// Function: shift(Operand*, int, unsigned char*)
inline void shift(Operand *opr, int c, uint8_t *p) {
    int val, m = opr->w ? 0x8000 : 0x80;
    switch ((p[1] >> 3) & 7) {
        case 0: // rol
            val = opr->u();
            for (int i = 0; i < c; ++i)
                val = (val << 1) | (CF = val & m);
            OF = CF ^ bool(val & m);
            *opr = val;
            break;
        case 1: // ror
            val = opr->u();
            for (int i = 0; i < c; ++i)
                val = (val >> 1) | ((CF = val & 1) ? m : 0);
            OF = CF ^ bool(val & (m >> 1));
            *opr = val;
            break;
        case 2: // rcl
            val = opr->u();
            for (int i = 0; i < c; ++i) {
                val = (val << 1) | CF;
                CF = val & (m << 1);
            }
            OF = CF ^ bool(val & m);
            *opr = val;
            break;
        case 3: // rcr
            val = opr->u();
            for (int i = 0; i < c; ++i) {
                bool f1 = val & 1, f2 = val & m;
                val = (val >> 1) | (CF ? m : 0);
                OF = CF ^ f2;
                CF = f1;
            }
            *opr = val;
            break;
        case 4: // shl/sal
            if (c > 0) {
                val = opr->u();
                for (int i = 0; i < c; ++i) {
                    val <<= 1;
                }
                *opr = opr->setf(val);
                CF = val & (m << 1);
                OF = CF != bool(val & m);
            }
            break;
        case 5: // shr
            if (c > 0) {
                val = opr->u();
                for (int i = 1; i < c; ++i) {
                    val >>= 1;
                }
                *opr = opr->setf(val >> 1);
                CF = val & 1;
                OF = val & m;
            }
            break;
        case 7: // sar
            if (c > 0) {
                val = **opr;
                for (int i = 1; i < c; ++i) {
                    val >>= 1;
                }
                *opr = opr->setf(val >> 1);
                CF = val & 1;
                OF = false;
            }
            break;
    }
}

// Assembly:
pushq %rbp
pushq %rbx
movb 0x4(%rdi), %al
testb %al, %al
movl $0x8000, %ecx           # imm = 0x8000
movl $0x80, %r8d
cmovnel %ecx, %r8d
movzbl 0x1(%rdx), %ecx
shrl $0x3, %ecx
andl $0x7, %ecx
leaq 0x122d(%rip), %rdx      # 0x7568
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl (%rdi), %r9d
movl 0x8(%rdi), %edx
movslq %edx, %rcx
testl %r9d, %r9d
je 0x654e
movq 0x10(%rdi), %r10
testq %r10, %r10
je 0x66c9
movq (%r10), %r10
testq %r10, %r10
je 0x66c9
testb %al, %al
je 0x66c4
movzwl (%r10,%rcx), %edx
jmp 0x66c9
movl (%rdi), %r9d
movl 0x8(%rdi), %edx
movslq %edx, %rcx
testl %r9d, %r9d
je 0x6506
movq 0x10(%rdi), %r10
testq %r10, %r10
je 0x65fb
movq (%r10), %r10
testq %r10, %r10
je 0x65fb
testb %al, %al
je 0x65f6
movzwl (%r10,%rcx), %edx
jmp 0x65fb
movl (%rdi), %r9d
movl 0x8(%rdi), %edx
movslq %edx, %rcx
testl %r9d, %r9d
je 0x651e
movq 0x10(%rdi), %r10
testq %r10, %r10
je 0x664f
movq (%r10), %r10
testq %r10, %r10
je 0x664f
testb %al, %al
je 0x664a
movzwl (%r10,%rcx), %edx
jmp 0x664f
movl (%rdi), %r9d
movl 0x8(%rdi), %edx
movslq %edx, %rcx
testl %r9d, %r9d
je 0x6536
movq 0x10(%rdi), %r10
testq %r10, %r10
je 0x6693
movq (%r10), %r10
testq %r10, %r10
je 0x6693
testb %al, %al
je 0x668e
movzwl (%r10,%rcx), %edx
jmp 0x6693
testl %esi, %esi
jle 0x699e
movl (%rdi), %edx
movl 0x8(%rdi), %r8d
movslq %r8d, %rbp
testl %edx, %edx
je 0x6566
movq 0x10(%rdi), %rcx
testq %rcx, %rcx
je 0x679d
movq (%rcx), %r9
testq %r9, %r9
je 0x679d
testb %al, %al
je 0x6798
movzwl (%r9,%rbp), %r8d
jmp 0x679d
testl %esi, %esi
jle 0x699e
movl (%rdi), %r9d
movl 0x8(%rdi), %ebx
movslq %ebx, %rdx
testl %r9d, %r9d
je 0x657f
movq 0x10(%rdi), %rcx
testq %rcx, %rcx
je 0x6852
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x6852
testb %al, %al
je 0x684e
movzwl (%rcx,%rdx), %ebx
jmp 0x6852
testl %esi, %esi
jle 0x699e
movl (%rdi), %r10d
movl 0x8(%rdi), %r9d
movslq %r9d, %rbp
testl %r10d, %r10d
je 0x6597
movq 0x10(%rdi), %rcx
testq %rcx, %rcx
je 0x68ff
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x68ff
testb %al, %al
je 0x68fa
movzwl (%rcx,%rbp), %r9d
jmp 0x68ff
testb %al, %al
je 0x65b0
leaq 0x123cab(%rip), %rdx    # 0x12a1c0
movzwl (%rdx,%rcx,2), %edx
jmp 0x65fb
testb %al, %al
je 0x65c0
leaq 0x123c93(%rip), %rdx    # 0x12a1c0
movzwl (%rdx,%rcx,2), %edx
jmp 0x664f
testb %al, %al
je 0x65d0
leaq 0x123c7b(%rip), %rdx    # 0x12a1c0
movzwl (%rdx,%rcx,2), %edx
jmp 0x6693
testb %al, %al
je 0x65e3
leaq 0x123c63(%rip), %rdx    # 0x12a1c0
movzwl (%rdx,%rcx,2), %edx
jmp 0x66c9
testb %al, %al
je 0x6760
leaq 0x123c4b(%rip), %rcx    # 0x12a1c0
movzwl (%rcx,%rbp,2), %r8d
jmp 0x679d
testb %al, %al
je 0x6771
leaq 0x123c32(%rip), %rcx    # 0x12a1c0
movzwl (%rcx,%rdx,2), %ebx
jmp 0x6852
testb %al, %al
je 0x6784
leaq 0x123c1a(%rip), %rcx    # 0x12a1c0
movzwl (%rcx,%rbp,2), %r9d
jmp 0x68ff
leaq 0x123c19(%rip), %rdx    # 0x12a1d0
movq (%rdx,%rcx,8), %rdx
movzbl (%rdx), %edx
jmp 0x65fb
leaq 0x123c09(%rip), %rdx    # 0x12a1d0
movq (%rdx,%rcx,8), %rdx
movzbl (%rdx), %edx
jmp 0x664f
leaq 0x123bf9(%rip), %rdx    # 0x12a1d0
movq (%rdx,%rcx,8), %rdx
movzbl (%rdx), %edx
jmp 0x6693
leaq 0x123be6(%rip), %rdx    # 0x12a1d0
movq (%rdx,%rcx,8), %rdx
movzbl (%rdx), %edx
jmp 0x66c9
movzbl (%r10,%rcx), %edx
testl %esi, %esi
jle 0x6708
movb 0x123c0e(%rip), %r10b   # 0x12a218
movl %r10d, %r11d
movl %edx, %ebx
movl %ebx, %r10d
andb $0x1, %r10b
movl %edx, %ebp
sarl %ebp
testb $0x1, %r11b
movl $0x0, %edx
cmovnel %r8d, %edx
orl %ebp, %edx
decl %esi
jne 0x660a
testl %r8d, %ebx
setne %sil
cmpb %sil, %r11b
setne 0x123bd2(%rip)          # 0x12a210
movb %r10b, 0x123bd3(%rip)   # 0x12a218
jmp 0x6708
movzbl (%r10,%rcx), %edx
testl %esi, %esi
jle 0x6678
movl %edx, %r11d
sarl %r11d
movl %edx, %r10d
andl $0x1, %r10d
movl %r10d, %edx
negl %edx
andl %r8d, %edx
orl %r11d, %edx
decl %esi
jne 0x6653
movb %r10b, 0x123ba2(%rip)   # 0x12a218
jmp 0x667f
movb 0x123b99(%rip), %r10b   # 0x12a218
shrl %r8d
testl %r8d, %edx
setne %sil
cmpb %sil, %r10b
jmp 0x6701
movzbl (%r10,%rcx), %edx
movb 0x123b7e(%rip), %r10b   # 0x12a218
testl %esi, %esi
jle 0x66b8
movzbl %r10b, %r10d
testl %r8d, %edx
leal (%r10,%rdx,2), %edx
setne %r10b
decl %esi
jne 0x669e
movb %r10b, 0x123b60(%rip)   # 0x12a218
testl %r8d, %edx
setne %sil
cmpb %sil, %r10b
jmp 0x6701
movzbl (%r10,%rcx), %edx
testl %esi, %esi
jle 0x66f0
movl %edx, %r10d
xorl %edx, %edx
testl %r8d, %r10d
setne %dl
leal (%rdx,%r10,2), %edx
decl %esi
jne 0x66cd
testl %r8d, %r10d
setne %sil
setne 0x123b2a(%rip)          # 0x12a218
jmp 0x66f7
movb 0x123b21(%rip), %sil    # 0x12a218
testl %r8d, %edx
setne %r8b
cmpb %r8b, %sil
setne 0x123b08(%rip)          # 0x12a210
testl %r9d, %r9d
je 0x673a
movq 0x10(%rdi), %rsi
testq %rsi, %rsi
je 0x699e
movq (%rsi), %rsi
testq %rsi, %rsi
je 0x699e
movb %dl, (%rsi,%rcx)
testb %al, %al
je 0x699e
movb %dh, 0x1(%rsi,%rcx)
jmp 0x699e
testb %al, %al
je 0x674e
leaq 0x123a7b(%rip), %rax    # 0x12a1c0
movw %dx, (%rax,%rcx,2)
jmp 0x699e
leaq 0x123a7b(%rip), %rax    # 0x12a1d0
movq (%rax,%rcx,8), %rax
movb %dl, (%rax)
jmp 0x699e
leaq 0x123a69(%rip), %rcx    # 0x12a1d0
movq (%rcx,%rbp,8), %rcx
movzbl (%rcx), %r8d
jmp 0x679d
leaq 0x123a58(%rip), %rcx    # 0x12a1d0
movq (%rcx,%rdx,8), %rcx
movzbl (%rcx), %ebx
jmp 0x6852
leaq 0x123a45(%rip), %rcx    # 0x12a1d0
movq (%rcx,%rbp,8), %rcx
movzbl (%rcx), %r9d
jmp 0x68ff
movzbl (%r9,%rbp), %r8d
movswl %r8w, %ecx
movsbl %r8b, %r8d
testb %al, %al
cmovnel %ecx, %r8d
cmpl $0x1, %esi
je 0x67b9
decl %esi
sarl %r8d
decl %esi
jne 0x67b2
movl %r8d, %ecx
sarl %ecx
movl %ecx, %ebx
shll $0x18, %ebx
movl %ecx, %esi
shll $0x10, %esi
testb %al, %al
cmovel %ebx, %esi
cmovnel %ecx, %ebx
shrl $0x1f, %ebx
testl %esi, %esi
sete 0x123a39(%rip)          # 0x12a215
movb %bl, 0x123a32(%rip)     # 0x12a214
movzbl %cl, %esi
leaq 0x123a34(%rip), %r9     # 0x12a220
movb (%rsi,%r9), %sil
movb %sil, 0x123a20(%rip)    # 0x12a217
testl %edx, %edx
je 0x6819
movq 0x10(%rdi), %rdx
testq %rdx, %rdx
je 0x6837
movq (%rdx), %rdx
testq %rdx, %rdx
je 0x6837
movb %cl, (%rdx,%rbp)
testb %al, %al
je 0x6837
movb %ch, 0x1(%rdx,%rbp)
jmp 0x6837
testb %al, %al
je 0x682a
leaq 0x12399c(%rip), %rax    # 0x12a1c0
movw %cx, (%rax,%rbp,2)
jmp 0x6837
leaq 0x12399f(%rip), %rax    # 0x12a1d0
movq (%rax,%rbp,8), %rax
movb %cl, (%rax)
andb $0x1, %r8b
movb %r8b, 0x1239d6(%rip)    # 0x12a218
movb $0x0, 0x1239c7(%rip)    # 0x12a210
jmp 0x699e
movzbl (%rcx,%rdx), %ebx
movl %ebx, %r10d
leal (%r10,%r10), %ebx
decl %esi
jne 0x6852
movl %eax, %ecx
xorb $0x1, %cl
shlb $0x3, %cl
orb $0x11, %cl
movl %r10d, %esi
shll %cl, %esi
movl %esi, %ecx
shrl $0x1f, %ecx
testl %esi, %esi
sete 0x12399a(%rip)          # 0x12a215
movl %ebx, %esi
andl $0xfe, %esi
movb %cl, 0x12398b(%rip)     # 0x12a214
leaq 0x123990(%rip), %rcx    # 0x12a220
movb (%rsi,%rcx), %cl
movb %cl, 0x12397e(%rip)     # 0x12a217
testl %r9d, %r9d
je 0x68bc
movq 0x10(%rdi), %rcx
testq %rcx, %rcx
je 0x68da
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x68da
movb %bl, (%rcx,%rdx)
testb %al, %al
je 0x68da
movb %bh, 0x1(%rcx,%rdx)
jmp 0x68da
testb %al, %al
je 0x68cd
leaq 0x1238f9(%rip), %rax    # 0x12a1c0
movw %bx, (%rax,%rdx,2)
jmp 0x68da
leaq 0x1238fc(%rip), %rax    # 0x12a1d0
movq (%rax,%rdx,8), %rax
movb %bl, (%rax)
testl %r8d, %r10d
setne %al
setne 0x123931(%rip)          # 0x12a218
testl %r8d, %ebx
setne %cl
xorb %al, %cl
movb %cl, 0x12391b(%rip)     # 0x12a210
jmp 0x699e
movzbl (%rcx,%rbp), %r9d
cmpl $0x1, %esi
je 0x690d
decl %esi
sarl %r9d
decl %esi
jne 0x6906
movl %r9d, %edx
sarl %edx
movl %eax, %ecx
xorb $0x1, %cl
shlb $0x3, %cl
orb $0x10, %cl
movl %edx, %ebx
shll %cl, %ebx
movl %ebx, %ecx
shrl $0x1f, %ecx
testl %ebx, %ebx
sete 0x1238e6(%rip)          # 0x12a215
movb %cl, 0x1238df(%rip)     # 0x12a214
movzbl %dl, %ecx
leaq 0x1238e1(%rip), %rsi    # 0x12a220
movb (%rcx,%rsi), %cl
movb %cl, 0x1238cf(%rip)     # 0x12a217
testl %r10d, %r10d
je 0x696b
movq 0x10(%rdi), %rcx
testq %rcx, %rcx
je 0x6989
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x6989
movb %dl, (%rcx,%rbp)
testb %al, %al
je 0x6989
movb %dh, 0x1(%rcx,%rbp)
jmp 0x6989
testb %al, %al
je 0x697c
leaq 0x12384a(%rip), %rax    # 0x12a1c0
movw %dx, (%rax,%rbp,2)
jmp 0x6989
leaq 0x12384d(%rip), %rax    # 0x12a1d0
movq (%rax,%rbp,8), %rax
movb %dl, (%rax)
movl %r9d, %eax
andb $0x1, %al
movb %al, 0x123884(%rip)     # 0x12a218
testl %r8d, %r9d
setne 0x123872(%rip)          # 0x12a210
popq %rbx
popq %rbp
retq
nop