#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ addbyte(int);
int /*<<< orphan*/ addword(int);
void ADD_HOST_REG_IMM_B(int host_reg, uint8_t imm) {
  if (host_reg & 0x10) {
    addbyte(0x66);
    if (host_reg & 8)
      addbyte(0x41);
    addbyte(0x81);
    addbyte(0xC0 | (host_reg & 7));
    addword(imm << 8);
  } else {
    if (host_reg & 8)
      addbyte(0x41);
    addbyte(0x80);
    addbyte(0xC0 | (host_reg & 7));
    addbyte(imm);
  }
}


x86 assembly (clang, -O0):
<ADD_HOST_REG_IMM_B>:
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     118b <ADD_HOST_REG_IMM_B+0x6b>
mov    $0x66,%edi
call   1040 <addbyte@plt>
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1160 <ADD_HOST_REG_IMM_B+0x40>
mov    $0x41,%edi
call   1040 <addbyte@plt>
mov    $0x81,%edi
call   1040 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
or     $0xc0,%edi
call   1040 <addbyte@plt>
mov    -0x8(%rbp),%edi
shl    $0x8,%edi
call   1030 <addword@plt>
jmp    11c7 <ADD_HOST_REG_IMM_B+0xa7>
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11a4 <ADD_HOST_REG_IMM_B+0x84>
mov    $0x41,%edi
call   1040 <addbyte@plt>
mov    $0x80,%edi
call   1040 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
or     $0xc0,%edi
call   1040 <addbyte@plt>
mov    -0x8(%rbp),%edi
call   1040 <addbyte@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADD_HOST_REG_IMM_B>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
test   $0x10,%bpl
jne    1164 <ADD_HOST_REG_IMM_B+0x44>
test   $0x8,%bpl
je     113d <ADD_HOST_REG_IMM_B+0x1d>
mov    $0x41,%edi
call   1040 <addbyte@plt>
mov    $0x80,%edi
call   1040 <addbyte@plt>
and    $0x7,%ebp
or     $0xc0,%ebp
mov    %ebp,%edi
call   1040 <addbyte@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <addbyte@plt>
mov    $0x66,%edi
call   1040 <addbyte@plt>
test   $0x8,%bpl
je     117e <ADD_HOST_REG_IMM_B+0x5e>
mov    $0x41,%edi
call   1040 <addbyte@plt>
mov    $0x81,%edi
call   1040 <addbyte@plt>
and    $0x7,%ebp
or     $0xc0,%ebp
mov    %ebp,%edi
call   1040 <addbyte@plt>
shl    $0x8,%ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <addword@plt>

LLVM IR (-O0):
define void @ADD_HOST_REG_IMM_B(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 %24
8: ; preds = %2
%9 = call i32 @addbyte(i32 102)
%10 = load i32, i32* %3
%11 = and i32 %10, 8
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 @addbyte(i32 65)
br label %15
15: ; preds = %13, %8
%16 = call i32 @addbyte(i32 129)
%17 = load i32, i32* %3
%18 = and i32 %17, 7
%19 = or i32 192, %18
%20 = call i32 @addbyte(i32 %19)
%21 = load i32, i32* %4
%22 = shl i32 %21, 8
%23 = call i32 @addword(i32 %22)
br label %38
24: ; preds = %2
%25 = load i32, i32* %3
%26 = and i32 %25, 8
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 @addbyte(i32 65)
br label %30
30: ; preds = %28, %24
%31 = call i32 @addbyte(i32 128)
%32 = load i32, i32* %3
%33 = and i32 %32, 7
%34 = or i32 192, %33
%35 = call i32 @addbyte(i32 %34)
%36 = load i32, i32* %4
%37 = call i32 @addbyte(i32 %36)
br label %38
38: ; preds = %30, %15
ret void
}

LLVM IR (-O2):
define void @ADD_HOST_REG_IMM_B(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 102)
%7 = and i32 %0, 8
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call i32 @addbyte(i32 65)
br label %11
11: ; preds = %9, %5
%12 = tail call i32 @addbyte(i32 129)
%13 = and i32 %0, 7
%14 = or i32 %13, 192
%15 = tail call i32 @addbyte(i32 %14)
%16 = shl i32 %1, 8
%17 = tail call i32 @addword(i32 %16)
br label %29
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 128)
%25 = and i32 %0, 7
%26 = or i32 %25, 192
%27 = tail call i32 @addbyte(i32 %26)
%28 = tail call i32 @addbyte(i32 %1)
br label %29
29: ; preds = %23, %11
ret void
}