#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ addbyte(int);
int /*<<< orphan*/ addlong(int);
int /*<<< orphan*/ addword(int);
void AND_HOST_REG_IMM(int host_reg, uint32_t imm) {
  if (host_reg & 0x10) {
    addbyte(0x66);
    if (host_reg & 8)
      addbyte(0x41);
    addbyte(0x81);
    addbyte(0xe0 | (host_reg & 7));
    addword((imm << 8) | 0xff);
  } else {
    if (host_reg & 8)
      addbyte(0x41);
    addbyte(0x81);
    addbyte(0xe0 | (host_reg & 7));
    addlong(imm);
  }
}


x86 assembly (clang, -O0):
<AND_HOST_REG_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     11a1 <AND_HOST_REG_IMM+0x71>
mov    $0x66,%edi
call   1050 <addbyte@plt>
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1170 <AND_HOST_REG_IMM+0x40>
mov    $0x41,%edi
call   1050 <addbyte@plt>
mov    $0x81,%edi
call   1050 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
or     $0xe0,%edi
call   1050 <addbyte@plt>
mov    -0x8(%rbp),%edi
shl    $0x8,%edi
or     $0xff,%edi
call   1030 <addword@plt>
jmp    11dd <AND_HOST_REG_IMM+0xad>
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11ba <AND_HOST_REG_IMM+0x8a>
mov    $0x41,%edi
call   1050 <addbyte@plt>
mov    $0x81,%edi
call   1050 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
or     $0xe0,%edi
call   1050 <addbyte@plt>
mov    -0x8(%rbp),%edi
call   1040 <addlong@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AND_HOST_REG_IMM>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
test   $0x10,%bpl
jne    1174 <AND_HOST_REG_IMM+0x44>
test   $0x8,%bpl
je     114d <AND_HOST_REG_IMM+0x1d>
mov    $0x41,%edi
call   1050 <addbyte@plt>
mov    $0x81,%edi
call   1050 <addbyte@plt>
and    $0x7,%ebp
or     $0xe0,%ebp
mov    %ebp,%edi
call   1050 <addbyte@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <addlong@plt>
mov    $0x66,%edi
call   1050 <addbyte@plt>
test   $0x8,%bpl
je     118e <AND_HOST_REG_IMM+0x5e>
mov    $0x41,%edi
call   1050 <addbyte@plt>
mov    $0x81,%edi
call   1050 <addbyte@plt>
and    $0x7,%ebp
or     $0xe0,%ebp
mov    %ebp,%edi
call   1050 <addbyte@plt>
shl    $0x8,%ebx
or     $0xff,%ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <addword@plt>

LLVM IR (-O0):
define void @AND_HOST_REG_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 %25
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 224, %18
%20 = call i32 @addbyte(i32 %19)
%21 = load i32, i32* %4
%22 = shl i32 %21, 8
%23 = or i32 %22, 255
%24 = call i32 @addword(i32 %23)
br label %39
25: ; preds = %2
%26 = load i32, i32* %3
%27 = and i32 %26, 8
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @addbyte(i32 65)
br label %31
31: ; preds = %29, %25
%32 = call i32 @addbyte(i32 129)
%33 = load i32, i32* %3
%34 = and i32 %33, 7
%35 = or i32 224, %34
%36 = call i32 @addbyte(i32 %35)
%37 = load i32, i32* %4
%38 = call i32 @addlong(i32 %37)
br label %39
39: ; preds = %31, %15
ret void
}

LLVM IR (-O2):
define void @AND_HOST_REG_IMM(i32 %0, i32 %1) {
%3 = and i32 %0, 16
%4 = icmp eq i32 %3, 0
br i1 %4, label %19, 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, 224
%15 = tail call i32 @addbyte(i32 %14)
%16 = shl i32 %1, 8
%17 = or i32 %16, 255
%18 = tail call i32 @addword(i32 %17)
br label %30
19: ; preds = %2
%20 = and i32 %0, 8
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 @addbyte(i32 65)
br label %24
24: ; preds = %22, %19
%25 = tail call i32 @addbyte(i32 129)
%26 = and i32 %0, 7
%27 = or i32 %26, 224
%28 = tail call i32 @addbyte(i32 %27)
%29 = tail call i32 @addlong(i32 %1)
br label %30
30: ; preds = %24, %11
ret void
}