// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
movb 0x4(%rdi), %r11b
testb %r11b, %r11b
movl $0x8000, %eax           # imm = 0x8000
movl $0x80, %ecx
cmovnel %eax, %ecx
movzbl 0x1(%rdx), %eax
shrl $0x3, %eax
andl $0x7, %eax
leaq 0x14f0(%rip), %rdx      # 0x7578
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movl (%rdi), %edx
testl %edx, %edx
je 0x61fd
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x62bc
movslq 0x8(%rdi), %r8
addq (%rax), %r8
jmp 0x62bf
movl (%rdi), %edx
testl %edx, %edx
je 0x61a4
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x621b
movslq 0x8(%rdi), %r8
addq (%rax), %r8
jmp 0x621e
movl (%rdi), %r8d
testl %r8d, %r8d
je 0x61c2
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x6247
movslq 0x8(%rdi), %r9
addq (%rax), %r9
jmp 0x624a
movl (%rdi), %edx
testl %edx, %edx
je 0x61df
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x6273
movslq 0x8(%rdi), %r8
addq (%rax), %r8
jmp 0x6276
testl %esi, %esi
jle 0x6826
movl (%rdi), %ecx
testl %ecx, %ecx
je 0x629f
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x64f8
movslq 0x8(%rdi), %r8
addq (%rax), %r8
jmp 0x64fb
testl %esi, %esi
jle 0x6826
movl (%rdi), %r8d
testl %r8d, %r8d
je 0x62e8
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x651a
movslq 0x8(%rdi), %r9
addq (%rax), %r9
jmp 0x651d
testl %esi, %esi
jle 0x6826
movl (%rdi), %r8d
testl %r8d, %r8d
je 0x6305
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x6546
movslq 0x8(%rdi), %r9
addq (%rax), %r9
jmp 0x6549
movslq 0x8(%rdi), %rax
testb %r11b, %r11b
je 0x6322
leaq 0x123008(%rip), %r8     # 0x1291c0
movzwl (%r8,%rax,2), %ebx
jmp 0x6330
movslq 0x8(%rdi), %rax
testb %r11b, %r11b
je 0x637e
leaq 0x122fea(%rip), %rdx    # 0x1291c0
movzwl (%rdx,%rax,2), %edx
jmp 0x638c
movslq 0x8(%rdi), %rax
testb %r11b, %r11b
je 0x6423
leaq 0x122fcd(%rip), %r8     # 0x1291c0
movzwl (%r8,%rax,2), %ebx
jmp 0x6431
movslq 0x8(%rdi), %rax
testb %r11b, %r11b
je 0x6459
leaq 0x122faf(%rip), %r8     # 0x1291c0
movzwl (%r8,%rax,2), %ebx
jmp 0x6467
xorl %r8d, %r8d
testq %r8, %r8
je 0x623f
movzbl (%r8), %ebx
testb %r11b, %r11b
je 0x6330
movzbl 0x1(%r8), %eax
shll $0x8, %eax
orl %eax, %ebx
jmp 0x6330
movl 0x8(%rdi), %ebx
jmp 0x6330
xorl %r9d, %r9d
testq %r9, %r9
je 0x626b
movzbl (%r9), %edx
testb %r11b, %r11b
je 0x638c
movzbl 0x1(%r9), %eax
shll $0x8, %eax
orl %eax, %edx
jmp 0x638c
movl 0x8(%rdi), %edx
jmp 0x638c
xorl %r8d, %r8d
testq %r8, %r8
je 0x6297
movzbl (%r8), %ebx
testb %r11b, %r11b
je 0x6431
movzbl 0x1(%r8), %eax
shll $0x8, %eax
orl %eax, %ebx
jmp 0x6431
movl 0x8(%rdi), %ebx
jmp 0x6431
movslq 0x8(%rdi), %rax
testb %r11b, %r11b
je 0x6572
leaq 0x122f0d(%rip), %rdx    # 0x1291c0
movzwl (%rdx,%rax,2), %edx
jmp 0x6580
xorl %r8d, %r8d
testq %r8, %r8
je 0x62e0
movzbl (%r8), %ebx
testb %r11b, %r11b
je 0x6467
movzbl 0x1(%r8), %eax
shll $0x8, %eax
orl %eax, %ebx
jmp 0x6467
movl 0x8(%rdi), %ebx
jmp 0x6467
movslq 0x8(%rdi), %rax
testb %r11b, %r11b
je 0x665d
leaq 0x122ec4(%rip), %rdx    # 0x1291c0
movzwl (%rdx,%rax,2), %edx
jmp 0x666b
movslq 0x8(%rdi), %rax
testb %r11b, %r11b
je 0x6745
leaq 0x122ea7(%rip), %rdx    # 0x1291c0
movzwl (%rdx,%rax,2), %edx
jmp 0x6753
leaq 0x122ea7(%rip), %r8     # 0x1291d0
movq (%r8,%rax,8), %rax
movzbl (%rax), %ebx
testl %esi, %esi
jle 0x6499
movb 0x122ed9(%rip), %r8b    # 0x129218
movl %r8d, %r9d
movl %ebx, %r10d
movl %r10d, %r8d
andb $0x1, %r8b
movl %ebx, %eax
sarl %eax
testb $0x1, %r9b
movl $0x0, %ebx
cmovnel %ecx, %ebx
orl %eax, %ebx
decl %esi
jne 0x633f
testl %ecx, %r10d
setne %al
cmpb %al, %r9b
setne 0x122e9e(%rip)          # 0x129210
movb %r8b, 0x122e9f(%rip)    # 0x129218
jmp 0x6499
leaq 0x122e4b(%rip), %rdx    # 0x1291d0
movq (%rdx,%rax,8), %rax
movzbl (%rax), %edx
testl %esi, %esi
jle 0x63af
movl %edx, %eax
sarl %eax
movl %edx, %r9d
andl $0x1, %r9d
movl %r9d, %edx
negl %edx
andl %ecx, %edx
orl %eax, %edx
decl %esi
jne 0x6390
movb %r9b, 0x122e69(%rip)    # 0x129218
shrl %ecx
testl %ecx, %edx
setne %al
cmpb %al, 0x122e5c(%rip)     # 0x129218
setne 0x122e4d(%rip)          # 0x129210
testl %r8d, %r8d
je 0x63da
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x63f3
movslq 0x8(%rdi), %rcx
addq (%rax), %rcx
jmp 0x63f5
movslq 0x8(%rdi), %rax
testb %r11b, %r11b
je 0x6411
leaq 0x122dd6(%rip), %rcx    # 0x1291c0
movw %dx, (%rcx,%rax,2)
jmp 0x6826
xorl %ecx, %ecx
testq %rcx, %rcx
je 0x6826
movb %dl, (%rcx)
testb %r11b, %r11b
je 0x6826
movb %dh, 0x1(%rcx)
jmp 0x6826
leaq 0x122db8(%rip), %rcx    # 0x1291d0
movq (%rcx,%rax,8), %rax
movb %dl, (%rax)
jmp 0x6826
leaq 0x122da6(%rip), %r8     # 0x1291d0
movq (%r8,%rax,8), %rax
movzbl (%rax), %ebx
testl %esi, %esi
jle 0x6487
movb 0x122ddc(%rip), %r8b    # 0x129218
movl %ebx, %eax
movzbl %r8b, %r8d
testl %ecx, %ebx
leal (%r8,%rax,2), %ebx
setne %r8b
decl %esi
jne 0x643c
movb %r8b, 0x122dc1(%rip)    # 0x129218
jmp 0x6487
leaq 0x122d70(%rip), %r8     # 0x1291d0
movq (%r8,%rax,8), %rax
movzbl (%rax), %ebx
testl %esi, %esi
jle 0x6487
movl %ebx, %r8d
xorl %eax, %eax
testl %ecx, %ebx
setne %al
leal (%rax,%r8,2), %ebx
decl %esi
jne 0x646b
testl %ecx, %r8d
setne 0x122d91(%rip)          # 0x129218
testl %ecx, %ebx
setne %al
cmpb %al, 0x122d86(%rip)     # 0x129218
setne 0x122d77(%rip)          # 0x129210
testl %edx, %edx
je 0x64af
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x64c8
movslq 0x8(%rdi), %rcx
addq (%rax), %rcx
jmp 0x64ca
movslq 0x8(%rdi), %rax
testb %r11b, %r11b
je 0x64e6
leaq 0x122d01(%rip), %rcx    # 0x1291c0
movw %bx, (%rcx,%rax,2)
jmp 0x6826
xorl %ecx, %ecx
testq %rcx, %rcx
je 0x6826
movb %bl, (%rcx)
testb %r11b, %r11b
je 0x6826
movb %bh, 0x1(%rcx)
jmp 0x6826
leaq 0x122ce3(%rip), %rcx    # 0x1291d0
movq (%rcx,%rax,8), %rax
movb %bl, (%rax)
jmp 0x6826
xorl %r8d, %r8d
testq %r8, %r8
je 0x6515
movzbl (%r8), %edx
testb %r11b, %r11b
je 0x6580
movzbl 0x1(%r8), %eax
shll $0x8, %eax
orl %eax, %edx
jmp 0x6580
movl 0x8(%rdi), %edx
jmp 0x6580
xorl %r9d, %r9d
testq %r9, %r9
je 0x653e
movzbl (%r9), %edx
testb %r11b, %r11b
je 0x666b
movzbl 0x1(%r9), %eax
shll $0x8, %eax
orl %eax, %edx
jmp 0x666b
movl 0x8(%rdi), %edx
jmp 0x666b
xorl %r9d, %r9d
testq %r9, %r9
je 0x656a
movzbl (%r9), %edx
testb %r11b, %r11b
je 0x6753
movzbl 0x1(%r9), %eax
shll $0x8, %eax
orl %eax, %edx
jmp 0x6753
movl 0x8(%rdi), %edx
jmp 0x6753
leaq 0x122c57(%rip), %rdx    # 0x1291d0
movq (%rdx,%rax,8), %rax
movzbl (%rax), %edx
movswl %dx, %eax
movsbl %dl, %edx
testb %r11b, %r11b
cmovnel %eax, %edx
cmpl $0x1, %esi
je 0x65a8
cmpl $0x3, %esi
movl $0x2, %r8d
cmovgel %esi, %r8d
decl %r8d
sarl %edx
decl %r8d
jne 0x65a1
movl %edx, %ebx
sarl %ebx
movl %ebx, %eax
shll $0x18, %eax
movsbl %bl, %esi
movl %ebx, %r8d
shll $0x10, %r8d
testb %r11b, %r11b
movl %esi, %r9d
cmovnel %ebx, %r9d
cmovel %eax, %r8d
cmpl %ebx, %r9d
setne 0x122c3d(%rip)          # 0x129210
movzbl %sil, %eax
shrl $0x1f, %r9d
testl %r8d, %r8d
sete 0x122c30(%rip)          # 0x129215
movb %r9b, 0x122c28(%rip)    # 0x129214
leaq 0x122c2d(%rip), %rsi    # 0x129220
movb (%rax,%rsi), %al
movb %al, 0x122c1b(%rip)     # 0x129217
testl %ecx, %ecx
je 0x6612
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x6628
movslq 0x8(%rdi), %rcx
addq (%rax), %rcx
jmp 0x662a
movslq 0x8(%rdi), %rax
testb %r11b, %r11b
je 0x663b
leaq 0x122b9e(%rip), %rcx    # 0x1291c0
movw %bx, (%rcx,%rax,2)
jmp 0x6648
xorl %ecx, %ecx
testq %rcx, %rcx
je 0x6648
movb %bl, (%rcx)
testb %r11b, %r11b
je 0x6648
movb %bh, 0x1(%rcx)
jmp 0x6648
leaq 0x122b8e(%rip), %rcx    # 0x1291d0
movq (%rcx,%rax,8), %rax
movb %bl, (%rax)
andb $0x1, %dl
movb %dl, 0x122bc7(%rip)     # 0x129218
movb $0x0, 0x122bb8(%rip)    # 0x129210
jmp 0x6826
leaq 0x122b6c(%rip), %rdx    # 0x1291d0
movq (%rdx,%rax,8), %rax
movzbl (%rax), %edx
cmpl $0x2, %esi
movl $0x1, %r9d
cmovgel %esi, %r9d
movl %edx, %esi
leal (%rsi,%rsi), %edx
decl %r9d
jne 0x6678
movl %esi, %eax
shll $0x19, %eax
movl %eax, %r9d
sarl $0x18, %r9d
movl %esi, %r10d
shll $0x11, %r10d
movl %r10d, %ebx
sarl $0x10, %ebx
testb %r11b, %r11b
cmovel %r9d, %ebx
cmovel %eax, %r10d
cmpl %edx, %ebx
setne 0x122b61(%rip)          # 0x129210
shrl $0x1f, %ebx
testl %r10d, %r10d
sete 0x122b59(%rip)          # 0x129215
movl %edx, %eax
andl $0xfe, %eax
movb %bl, 0x122b4b(%rip)     # 0x129214
leaq 0x122b50(%rip), %r9     # 0x129220
movb (%rax,%r9), %al
movb %al, 0x122b3d(%rip)     # 0x129217
testl %r8d, %r8d
je 0x66f1
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x6707
movslq 0x8(%rdi), %rdi
addq (%rax), %rdi
jmp 0x6709
movslq 0x8(%rdi), %rax
testb %r11b, %r11b
je 0x671a
leaq 0x122abf(%rip), %rdi    # 0x1291c0
movw %dx, (%rdi,%rax,2)
jmp 0x6727
xorl %edi, %edi
testq %rdi, %rdi
je 0x6727
movb %dl, (%rdi)
testb %r11b, %r11b
je 0x6727
movb %dh, 0x1(%rdi)
jmp 0x6727
leaq 0x122aaf(%rip), %rdi    # 0x1291d0
movq (%rdi,%rax,8), %rax
movb %dl, (%rax)
testl %ecx, %esi
setne %al
setne 0x122ae5(%rip)          # 0x129218
testl %ecx, %edx
setne %cl
xorb %al, %cl
movb %cl, 0x122ad0(%rip)     # 0x129210
jmp 0x6826
leaq 0x122a84(%rip), %rdx    # 0x1291d0
movq (%rdx,%rax,8), %rax
movzbl (%rax), %edx
cmpl $0x1, %esi
je 0x676f
cmpl $0x3, %esi
movl $0x2, %r9d
cmovgel %esi, %r9d
decl %r9d
sarl %edx
decl %r9d
jne 0x6768
movl %edx, %eax
sarl %eax
movl %eax, %ebx
shll $0x18, %ebx
movsbl %al, %esi
movl %eax, %r9d
shll $0x10, %r9d
movswl %ax, %r10d
testb %r11b, %r11b
cmovel %esi, %r10d
cmovel %ebx, %r9d
cmpl %eax, %r10d
setne 0x122a75(%rip)          # 0x129210
shrl $0x1f, %r10d
testl %r9d, %r9d
sete 0x122a6c(%rip)          # 0x129215
movb %r10b, 0x122a64(%rip)   # 0x129214
movzbl %sil, %esi
leaq 0x122a65(%rip), %r9     # 0x129220
movb (%rsi,%r9), %sil
movb %sil, 0x122a51(%rip)    # 0x129217
testl %r8d, %r8d
je 0x67dd
movq 0x10(%rdi), %r8
testq %r8, %r8
je 0x67f3
movslq 0x8(%rdi), %rsi
addq (%r8), %rsi
jmp 0x67f5
movslq 0x8(%rdi), %rsi
testb %r11b, %r11b
je 0x6806
leaq 0x1229d3(%rip), %rdi    # 0x1291c0
movw %ax, (%rdi,%rsi,2)
jmp 0x6813
xorl %esi, %esi
testq %rsi, %rsi
je 0x6813
movb %al, (%rsi)
testb %r11b, %r11b
je 0x6813
movb %ah, 0x1(%rsi)
jmp 0x6813
leaq 0x1229c3(%rip), %rdi    # 0x1291d0
movq (%rdi,%rsi,8), %rsi
movb %al, (%rsi)
movl %edx, %eax
andb $0x1, %al
movb %al, 0x1229fb(%rip)     # 0x129218
testl %ecx, %edx
setne 0x1229ea(%rip)          # 0x129210
popq %rbx
retq