#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 OR_HOST_REG_IMM(int host_reg, uint32_t imm) {
  if (host_reg & 0x10) {
    addbyte(0x66);
    addbyte(0x41);
    addbyte(0x81);
    addbyte(0xc8 | (host_reg & 7));
    addword(imm << 8);
  } else if (host_reg & 8) {
    addbyte(0x41);
    addbyte(0x81);
    addbyte(0xc8 | (host_reg & 7));
    addlong(imm);
  } else {
    addbyte(0x81);
    addbyte(0xc8 | (host_reg & 7));
    addlong(imm);
  }
}


x86 assembly (clang, -O0):
<OR_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     118c <OR_HOST_REG_IMM+0x5c>
mov    $0x66,%edi
call   1050 <addbyte@plt>
mov    $0x41,%edi
call   1050 <addbyte@plt>
mov    $0x81,%edi
call   1050 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
or     $0xc8,%edi
call   1050 <addbyte@plt>
mov    -0x8(%rbp),%edi
shl    $0x8,%edi
call   1030 <addword@plt>
jmp    11f5 <OR_HOST_REG_IMM+0xc5>
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11cd <OR_HOST_REG_IMM+0x9d>
mov    $0x41,%edi
call   1050 <addbyte@plt>
mov    $0x81,%edi
call   1050 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
or     $0xc8,%edi
call   1050 <addbyte@plt>
mov    -0x8(%rbp),%edi
call   1040 <addlong@plt>
jmp    11f0 <OR_HOST_REG_IMM+0xc0>
mov    $0x81,%edi
call   1050 <addbyte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
or     $0xc8,%edi
call   1050 <addbyte@plt>
mov    -0x8(%rbp),%edi
call   1040 <addlong@plt>
jmp    11f5 <OR_HOST_REG_IMM+0xc5>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OR_HOST_REG_IMM>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
test   $0x10,%bpl
jne    1174 <OR_HOST_REG_IMM+0x44>
test   $0x8,%bpl
je     114d <OR_HOST_REG_IMM+0x1d>
mov    $0x41,%edi
call   1050 <addbyte@plt>
mov    $0x81,%edi
call   1050 <addbyte@plt>
and    $0x7,%ebp
or     $0xc8,%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>
mov    $0x41,%edi
call   1050 <addbyte@plt>
mov    $0x81,%edi
call   1050 <addbyte@plt>
and    $0x7,%ebp
or     $0xc8,%ebp
mov    %ebp,%edi
call   1050 <addbyte@plt>
shl    $0x8,%ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <addword@plt>

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

LLVM IR (-O2):
define void @OR_HOST_REG_IMM(i32 %0, i32 %1) {
%3 = and i32 %0, 16
%4 = icmp eq i32 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %2
%6 = tail call i32 @addbyte(i32 102)
%7 = tail call i32 @addbyte(i32 65)
%8 = tail call i32 @addbyte(i32 129)
%9 = and i32 %0, 7
%10 = or i32 %9, 200
%11 = tail call i32 @addbyte(i32 %10)
%12 = shl i32 %1, 8
%13 = tail call i32 @addword(i32 %12)
br label %30
14: ; preds = %2
%15 = and i32 %0, 8
%16 = icmp eq i32 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %14
%18 = tail call i32 @addbyte(i32 65)
%19 = tail call i32 @addbyte(i32 129)
%20 = and i32 %0, 7
%21 = or i32 %20, 200
%22 = tail call i32 @addbyte(i32 %21)
%23 = tail call i32 @addlong(i32 %1)
br label %30
24: ; preds = %14
%25 = tail call i32 @addbyte(i32 129)
%26 = and i32 %0, 7
%27 = or i32 %26, 200
%28 = tail call i32 @addbyte(i32 %27)
%29 = tail call i32 @addlong(i32 %1)
br label %30
30: ; preds = %17, %24, %5
ret void
}