#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 */
struct jit_state {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ emit_rex(struct jit_state *, int, int, int /*<<< orphan*/,
                            int);
void emit_basic_rex(struct jit_state *state, int w, int src, int dst) {
  if (w || (src & 8) || (dst & 8)) {
    emit_rex(state, w, !!(src & 8), 0, !!(dst & 8));
  }
}


x86 assembly (clang, -O0):
<emit_basic_rex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    114d <emit_basic_rex+0x3d>
mov    -0x10(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
jne    114d <emit_basic_rex+0x3d>
mov    -0x14(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1186 <emit_basic_rex+0x76>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edx
mov    -0x14(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%r8d
xor    %ecx,%ecx
call   1030 <emit_rex@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_basic_rex>:
mov    %ecx,%r8d
mov    %edx,%eax
and    $0x8,%eax
or     %esi,%eax
and    $0x8,%ecx
or     %eax,%ecx
je     1136 <emit_basic_rex+0x26>
shr    $0x3,%edx
and    $0x1,%edx
shr    $0x3,%r8d
and    $0x1,%r8d
xor    %ecx,%ecx
jmp    1030 <emit_rex@plt>
ret

LLVM IR (-O0):
%struct.jit_state = type { i32 }
define void @emit_basic_rex(%struct.jit_state* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.jit_state*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.jit_state* %0, %struct.jit_state** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %4
%12 = load i32, i32* %7
%13 = and i32 %12, 8
%14 = icmp ne i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load i32, i32* %8
%17 = and i32 %16, 8
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %35
19: ; preds = %15, %11, %4
%20 = load %struct.jit_state*, %struct.jit_state** %5
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = and i32 %22, 8
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
%26 = xor i1 %25, true
%27 = zext i1 %26 to i32
%28 = load i32, i32* %8
%29 = and i32 %28, 8
%30 = icmp ne i32 %29, 0
%31 = xor i1 %30, true
%32 = xor i1 %31, true
%33 = zext i1 %32 to i32
%34 = call i32 @emit_rex(%struct.jit_state* %20, i32 %21, i32 %27, i32 0, i32 %33)
br label %35
35: ; preds = %19, %15
ret void
}

LLVM IR (-O2):
%struct.jit_state = type { i32 }
define void @emit_basic_rex(%struct.jit_state* %0, i32 %1, i32 %2, i32 %3) {
%5 = and i32 %2, 8
%6 = or i32 %5, %1
%7 = and i32 %3, 8
%8 = or i32 %6, %7
%9 = icmp eq i32 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %4
%11 = lshr i32 %2, 3
%12 = and i32 %11, 1
%13 = lshr i32 %3, 3
%14 = and i32 %13, 1
%15 = tail call i32 @emit_rex(%struct.jit_state* %0, i32 %1, i32 %12, i32 0, i32 %14)
br label %16
16: ; preds = %4, %10
ret void
}