#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*/ assert(int);
int /*<<< orphan*/ emit1(struct jit_state *, int);
void emit_rex(struct jit_state *state, int w, int r, int x, int b) {
  assert(!(w & ~1));
  assert(!(r & ~1));
  assert(!(x & ~1));
  assert(!(b & ~1));
  emit1(state, 0x40 | (w << 3) | (r << 2) | (x << 1) | b);
}


x86 assembly (clang, -O0):
<emit_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)
mov    %r8d,-0x18(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfffffffe,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%eax
and    $0xfffffffe,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x14(%rbp),%eax
and    $0xfffffffe,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%eax
and    $0xfffffffe,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
shl    $0x3,%esi
or     $0x40,%esi
mov    -0x10(%rbp),%eax
shl    $0x2,%eax
or     %eax,%esi
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
or     %eax,%esi
or     -0x18(%rbp),%esi
call   1030 <emit1@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_rex>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r15d
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %esi,%r12d
mov    %rdi,%r14
xor    %edi,%edi
cmp    $0x2,%esi
setb   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmp    $0x2,%ebp
setb   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmp    $0x2,%ebx
setb   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmp    $0x2,%r15d
setb   %dil
call   1040 <assert@plt>
shl    $0x3,%r12d
shl    $0x2,%ebp
or     %r12d,%ebp
add    %ebx,%ebx
or     %r15d,%ebx
or     %ebp,%ebx
or     $0x40,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <emit1@plt>

LLVM IR (-O0):
%struct.jit_state = type { i32 }
define void @emit_rex(%struct.jit_state* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca %struct.jit_state*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store %struct.jit_state* %0, %struct.jit_state** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %7
%12 = and i32 %11, -2
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i32, i32* %8
%18 = and i32 %17, -2
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32, i32* %9
%24 = and i32 %23, -2
%25 = icmp ne i32 %24, 0
%26 = xor i1 %25, true
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load i32, i32* %10
%30 = and i32 %29, -2
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load %struct.jit_state*, %struct.jit_state** %6
%36 = load i32, i32* %7
%37 = shl i32 %36, 3
%38 = or i32 64, %37
%39 = load i32, i32* %8
%40 = shl i32 %39, 2
%41 = or i32 %38, %40
%42 = load i32, i32* %9
%43 = shl i32 %42, 1
%44 = or i32 %41, %43
%45 = load i32, i32* %10
%46 = or i32 %44, %45
%47 = call i32 @emit1(%struct.jit_state* %35, i32 %46)
ret void
}

LLVM IR (-O2):
%struct.jit_state = type { i32 }
define void @emit_rex(%struct.jit_state* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp ult i32 %1, 2
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = icmp ult i32 %2, 2
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = icmp ult i32 %3, 2
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = icmp ult i32 %4, 2
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = shl i32 %1, 3
%19 = shl i32 %2, 2
%20 = shl i32 %3, 1
%21 = or i32 %18, %19
%22 = or i32 %21, %20
%23 = or i32 %22, %4
%24 = or i32 %23, 64
%25 = tail call i32 @emit1(%struct.jit_state* %0, i32 %24)
ret void
}