#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);
int /*<<< orphan*/ fatal(char *);
void ADD_HOST_REG_W(int dst_reg, int src_reg) {
  if (dst_reg & src_reg & 8) {
    addbyte(0x66);
    addbyte(0x45);
    addbyte(0x01);
    addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3));
  } else if (dst_reg & 8) {
    addbyte(0x66);
    addbyte(0x41);
    addbyte(0x01);
    addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3));
  } else if (src_reg & 8) {
    addbyte(0x66);
    addbyte(0x44);
    addbyte(0x01);
    addbyte(0xc0 | (dst_reg & 7) | ((src_reg & 7) << 3));
  } else
    fatal("!(dst_reg & src_reg & 8)\n");
}


x86 assembly (clang, -O0):
<ADD_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     117f <ADD_HOST_REG_W+0x5f>
mov    $0x66,%edi
call   1030 <addbyte@plt>
mov    $0x45,%edi
call   1030 <addbyte@plt>
mov    $0x1,%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    1231 <ADD_HOST_REG_W+0x111>
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11cd <ADD_HOST_REG_W+0xad>
mov    $0x66,%edi
call   1030 <addbyte@plt>
mov    $0x41,%edi
call   1030 <addbyte@plt>
mov    $0x1,%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    122c <ADD_HOST_REG_W+0x10c>
mov    -0x8(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     121b <ADD_HOST_REG_W+0xfb>
mov    $0x66,%edi
call   1030 <addbyte@plt>
mov    $0x44,%edi
call   1030 <addbyte@plt>
mov    $0x1,%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    1227 <ADD_HOST_REG_W+0x107>
lea    0xdde(%rip),%rdi
call   1040 <fatal@plt>
jmp    122c <ADD_HOST_REG_W+0x10c>
jmp    1231 <ADD_HOST_REG_W+0x111>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ADD_HOST_REG_W>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%r14d
mov    %edi,%eax
and    $0x8,%eax
test   %esi,%eax
je     1143 <ADD_HOST_REG_W+0x23>
mov    $0x66,%edi
call   1030 <addbyte@plt>
mov    $0x45,%edi
jmp    117f <ADD_HOST_REG_W+0x5f>
test   %eax,%eax
jne    115f <ADD_HOST_REG_W+0x3f>
test   $0x8,%bl
jne    1170 <ADD_HOST_REG_W+0x50>
lea    0xead(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fatal@plt>
mov    $0x66,%edi
call   1030 <addbyte@plt>
mov    $0x41,%edi
jmp    117f <ADD_HOST_REG_W+0x5f>
mov    $0x66,%edi
call   1030 <addbyte@plt>
mov    $0x44,%edi
call   1030 <addbyte@plt>
mov    $0x1,%edi
call   1030 <addbyte@plt>
and    $0x7,%r14d
and    $0x1f,%ebx
lea    (%r14,%rbx,8),%edi
or     $0xc0,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <addbyte@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"!(dst_reg & src_reg & 8)\0A\00"
define void @ADD_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 1)
%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 %58
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 1)
%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 %57
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 1)
%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 %56
54: ; preds = %38
%55 = call i32 @fatal(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %56
56: ; preds = %54, %42
br label %57
57: ; preds = %56, %26
br label %58
58: ; preds = %57, %10
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"!(dst_reg & src_reg & 8)\0A\00"
define void @ADD_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 %16, label %6
6: ; preds = %2
%7 = tail call i32 @addbyte(i32 102)
%8 = tail call i32 @addbyte(i32 69)
%9 = tail call i32 @addbyte(i32 1)
%10 = and i32 %0, 7
%11 = shl i32 %1, 3
%12 = and i32 %11, 56
%13 = or i32 %10, %12
%14 = or i32 %13, 192
%15 = tail call i32 @addbyte(i32 %14)
br label %43
16: ; preds = %2
%17 = icmp eq i32 %3, 0
br i1 %17, label %28, label %18
18: ; preds = %16
%19 = tail call i32 @addbyte(i32 102)
%20 = tail call i32 @addbyte(i32 65)
%21 = tail call i32 @addbyte(i32 1)
%22 = and i32 %0, 7
%23 = shl i32 %1, 3
%24 = and i32 %23, 56
%25 = or i32 %22, %24
%26 = or i32 %25, 192
%27 = tail call i32 @addbyte(i32 %26)
br label %43
28: ; preds = %16
%29 = and i32 %1, 8
%30 = icmp eq i32 %29, 0
br i1 %30, label %41, label %31
31: ; preds = %28
%32 = tail call i32 @addbyte(i32 102)
%33 = tail call i32 @addbyte(i32 68)
%34 = tail call i32 @addbyte(i32 1)
%35 = and i32 %0, 7
%36 = shl i32 %1, 3
%37 = and i32 %36, 56
%38 = or i32 %35, %37
%39 = or i32 %38, 192
%40 = tail call i32 @addbyte(i32 %39)
br label %43
41: ; preds = %28
%42 = tail call i32 @fatal(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %18, %41, %31, %6
ret void
}