#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 AND_HOST_REG_W(int dst_reg, int src_reg) {
  if (dst_reg & src_reg & 8) {
    addbyte(0x66);
    addbyte(0x45);
    addbyte(0x21);
    addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3));
  } else if (dst_reg & 8) {
    addbyte(0x66);
    addbyte(0x41);
    addbyte(0x21);
    addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3));
  } else if (src_reg & 8) {
    addbyte(0x66);
    addbyte(0x44);
    addbyte(0x21);
    addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3));
  } else {
    addbyte(0x66);
    addbyte(0x21);
    addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3));
  }
}


x86 assembly (clang, -O0):
<AND_HOST_REG_W>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    -0x8(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     116f <AND_HOST_REG_W+0x5f>
mov    $0x66,%edi
call   1030 <addbyte@plt>
mov    $0x45,%edi
call   1030 <addbyte@plt>
mov    $0x21,%edi
call   1030 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
or     $0xc0,%edi
mov    -0x8(%rbp),%eax
and    $0x7,%eax
shl    $0x3,%eax
or     %eax,%edi
call   1030 <addbyte@plt>
jmp    1245 <AND_HOST_REG_W+0x135>
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11bd <AND_HOST_REG_W+0xad>
mov    $0x66,%edi
call   1030 <addbyte@plt>
mov    $0x41,%edi
call   1030 <addbyte@plt>
mov    $0x21,%edi
call   1030 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
or     $0xc0,%edi
mov    -0x8(%rbp),%eax
and    $0x7,%eax
shl    $0x3,%eax
or     %eax,%edi
call   1030 <addbyte@plt>
jmp    1240 <AND_HOST_REG_W+0x130>
mov    -0x8(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     120b <AND_HOST_REG_W+0xfb>
mov    $0x66,%edi
call   1030 <addbyte@plt>
mov    $0x44,%edi
call   1030 <addbyte@plt>
mov    $0x21,%edi
call   1030 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
or     $0xc0,%edi
mov    -0x8(%rbp),%eax
and    $0x7,%eax
shl    $0x3,%eax
or     %eax,%edi
call   1030 <addbyte@plt>
jmp    123b <AND_HOST_REG_W+0x12b>
mov    $0x66,%edi
call   1030 <addbyte@plt>
mov    $0x21,%edi
call   1030 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
or     $0xc0,%edi
mov    -0x8(%rbp),%eax
and    $0x7,%eax
shl    $0x3,%eax
or     %eax,%edi
call   1030 <addbyte@plt>
jmp    1240 <AND_HOST_REG_W+0x130>
jmp    1245 <AND_HOST_REG_W+0x135>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AND_HOST_REG_W>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%r14d
mov    %edi,%eax
and    $0x8,%eax
mov    $0x45,%ebp
test   %esi,%eax
jne    1146 <AND_HOST_REG_W+0x36>
mov    $0x41,%ebp
test   %eax,%eax
jne    1146 <AND_HOST_REG_W+0x36>
mov    $0x66,%edi
call   1030 <addbyte@plt>
mov    $0x44,%ebp
test   $0x8,%bl
jne    1150 <AND_HOST_REG_W+0x40>
jmp    1157 <AND_HOST_REG_W+0x47>
mov    $0x66,%edi
call   1030 <addbyte@plt>
mov    %ebp,%edi
call   1030 <addbyte@plt>
mov    $0x21,%edi
call   1030 <addbyte@plt>
and    $0x7,%r14d
and    $0x1f,%ebx
lea    (%r14,%rbx,8),%edi
or     $0xc0,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <addbyte@plt>

LLVM IR (-O0):
define void @AND_HOST_REG_W(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 = load i32, i32* %4
%7 = and i32 %5, %6
%8 = and i32 %7, 8
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %2
%11 = call i32 @addbyte(i32 102)
%12 = call i32 @addbyte(i32 69)
%13 = call i32 @addbyte(i32 33)
%14 = load i32, i32* %3
%15 = and i32 %14, 7
%16 = or i32 192, %15
%17 = load i32, i32* %4
%18 = and i32 %17, 7
%19 = shl i32 %18, 3
%20 = or i32 %16, %19
%21 = call i32 @addbyte(i32 %20)
br label %67
22: ; preds = %2
%23 = load i32, i32* %3
%24 = and i32 %23, 8
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %38
26: ; preds = %22
%27 = call i32 @addbyte(i32 102)
%28 = call i32 @addbyte(i32 65)
%29 = call i32 @addbyte(i32 33)
%30 = load i32, i32* %3
%31 = and i32 %30, 7
%32 = or i32 192, %31
%33 = load i32, i32* %4
%34 = and i32 %33, 7
%35 = shl i32 %34, 3
%36 = or i32 %32, %35
%37 = call i32 @addbyte(i32 %36)
br label %66
38: ; preds = %22
%39 = load i32, i32* %4
%40 = and i32 %39, 8
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %54
42: ; preds = %38
%43 = call i32 @addbyte(i32 102)
%44 = call i32 @addbyte(i32 68)
%45 = call i32 @addbyte(i32 33)
%46 = load i32, i32* %3
%47 = and i32 %46, 7
%48 = or i32 192, %47
%49 = load i32, i32* %4
%50 = and i32 %49, 7
%51 = shl i32 %50, 3
%52 = or i32 %48, %51
%53 = call i32 @addbyte(i32 %52)
br label %65
54: ; preds = %38
%55 = call i32 @addbyte(i32 102)
%56 = call i32 @addbyte(i32 33)
%57 = load i32, i32* %3
%58 = and i32 %57, 7
%59 = or i32 192, %58
%60 = load i32, i32* %4
%61 = and i32 %60, 7
%62 = shl i32 %61, 3
%63 = or i32 %59, %62
%64 = call i32 @addbyte(i32 %63)
br label %65
65: ; preds = %54, %42
br label %66
66: ; preds = %65, %26
br label %67
67: ; preds = %66, %10
ret void
}

LLVM IR (-O2):
define void @AND_HOST_REG_W(i32 %0, i32 %1) {
%3 = and i32 %0, 8
%4 = and i32 %3, %1
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = icmp eq i32 %3, 0
br i1 %7, label %8, label %12
8: ; preds = %6
%9 = and i32 %1, 8
%10 = icmp eq i32 %9, 0
%11 = tail call i32 @addbyte(i32 102)
br i1 %10, label %18, label %15
12: ; preds = %6, %2
%13 = phi i32 [ 69, %2 ], [ 65, %6 ]
%14 = tail call i32 @addbyte(i32 102)
br label %15
15: ; preds = %12, %8
%16 = phi i32 [ 68, %8 ], [ %13, %12 ]
%17 = tail call i32 @addbyte(i32 %16)
br label %18
18: ; preds = %15, %8
%19 = tail call i32 @addbyte(i32 33)
%20 = and i32 %0, 7
%21 = shl i32 %1, 3
%22 = and i32 %21, 56
%23 = or i32 %20, %22
%24 = or i32 %23, 192
%25 = tail call i32 @addbyte(i32 %24)
ret void
}