#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ addbyte(int);
void SAR_B_IMM(int reg, int count) {
  if (reg & 0x10) {
    addbyte(0x44);
    addbyte(0x89);
    addbyte(0xc0 | 0 | ((reg & 7) << 3));
    addbyte(0xc0);
    addbyte(0xf8 | 4);
    addbyte(count);
    addbyte(0x41);
    addbyte(0x89);
    addbyte(0xc0 | (0 << 3) | (reg & 7));
  } else {
    if (reg & 8)
      addbyte(0x41);
    addbyte(0xc0);
    addbyte(0xc0 | (reg & 7) | 0x38);
    addbyte(count);
  }
}


x86 assembly (clang, -O0):
<SAR_B_IMM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     119b <SAR_B_IMM+0x8b>
mov    $0x44,%edi
call   1030 <addbyte@plt>
mov    $0x89,%edi
call   1030 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
shl    $0x3,%edi
or     $0xc0,%edi
call   1030 <addbyte@plt>
mov    $0xc0,%edi
call   1030 <addbyte@plt>
mov    $0xfc,%edi
call   1030 <addbyte@plt>
mov    -0x8(%rbp),%edi
call   1030 <addbyte@plt>
mov    $0x41,%edi
call   1030 <addbyte@plt>
mov    $0x89,%edi
call   1030 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
or     $0xc0,%edi
call   1030 <addbyte@plt>
jmp    11da <SAR_B_IMM+0xca>
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11b4 <SAR_B_IMM+0xa4>
mov    $0x41,%edi
call   1030 <addbyte@plt>
mov    $0xc0,%edi
call   1030 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
or     $0xc0,%edi
or     $0x38,%edi
call   1030 <addbyte@plt>
mov    -0x8(%rbp),%edi
call   1030 <addbyte@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SAR_B_IMM>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
test   $0x10,%bl
jne    1145 <SAR_B_IMM+0x35>
test   $0x8,%bl
je     112b <SAR_B_IMM+0x1b>
mov    $0x41,%edi
call   1030 <addbyte@plt>
mov    $0xc0,%edi
call   1030 <addbyte@plt>
or     $0xf8,%ebx
movzbl %bl,%edi
call   1030 <addbyte@plt>
jmp    119f <SAR_B_IMM+0x8f>
mov    $0x44,%edi
call   1030 <addbyte@plt>
mov    $0x89,%edi
call   1030 <addbyte@plt>
and    $0x7,%ebx
lea    0xc0(,%rbx,8),%edi
call   1030 <addbyte@plt>
mov    $0xc0,%edi
call   1030 <addbyte@plt>
mov    $0xfc,%edi
call   1030 <addbyte@plt>
mov    %ebp,%edi
call   1030 <addbyte@plt>
mov    $0x41,%edi
call   1030 <addbyte@plt>
mov    $0x89,%edi
call   1030 <addbyte@plt>
or     $0xc0,%ebx
mov    %ebx,%ebp
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <addbyte@plt>

LLVM IR (-O0):
define void @SAR_B_IMM(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = and i32 %5, 16
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %26
8: ; preds = %2
%9 = call i32 @addbyte(i32 68)
%10 = call i32 @addbyte(i32 137)
%11 = load i32, i32* %3
%12 = and i32 %11, 7
%13 = shl i32 %12, 3
%14 = or i32 192, %13
%15 = call i32 @addbyte(i32 %14)
%16 = call i32 @addbyte(i32 192)
%17 = call i32 @addbyte(i32 252)
%18 = load i32, i32* %4
%19 = call i32 @addbyte(i32 %18)
%20 = call i32 @addbyte(i32 65)
%21 = call i32 @addbyte(i32 137)
%22 = load i32, i32* %3
%23 = and i32 %22, 7
%24 = or i32 192, %23
%25 = call i32 @addbyte(i32 %24)
br label %41
26: ; preds = %2
%27 = load i32, i32* %3
%28 = and i32 %27, 8
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 @addbyte(i32 65)
br label %32
32: ; preds = %30, %26
%33 = call i32 @addbyte(i32 192)
%34 = load i32, i32* %3
%35 = and i32 %34, 7
%36 = or i32 192, %35
%37 = or i32 %36, 56
%38 = call i32 @addbyte(i32 %37)
%39 = load i32, i32* %4
%40 = call i32 @addbyte(i32 %39)
br label %41
41: ; preds = %32, %8
ret void
}

LLVM IR (-O2):
define void @SAR_B_IMM(i32 %0, i32 %1) {
%3 = and i32 %0, 16
%4 = icmp eq i32 %3, 0
br i1 %4, label %18, label %5
5: ; preds = %2
%6 = tail call i32 @addbyte(i32 68)
%7 = tail call i32 @addbyte(i32 137)
%8 = and i32 %0, 7
%9 = shl nuw nsw i32 %8, 3
%10 = or i32 %9, 192
%11 = tail call i32 @addbyte(i32 %10)
%12 = tail call i32 @addbyte(i32 192)
%13 = tail call i32 @addbyte(i32 252)
%14 = tail call i32 @addbyte(i32 %1)
%15 = tail call i32 @addbyte(i32 65)
%16 = tail call i32 @addbyte(i32 137)
%17 = or i32 %8, 192
br label %28
18: ; preds = %2
%19 = and i32 %0, 8
%20 = icmp eq i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 @addbyte(i32 65)
br label %23
23: ; preds = %21, %18
%24 = tail call i32 @addbyte(i32 192)
%25 = and i32 %0, 7
%26 = or i32 %25, 248
%27 = tail call i32 @addbyte(i32 %26)
br label %28
28: ; preds = %23, %5
%29 = phi i32 [ %1, %23 ], [ %17, %5 ]
%30 = tail call i32 @addbyte(i32 %29)
ret void
}