#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 uint8_t;
typedef int source;
typedef int dest;

/* Variables and functions */
int /*<<< orphan*/ write_byte(int);
void emit_generic_instruction(uint8_t dest, uint8_t source, uint8_t opcode) {
  uint8_t rex = 0x40 | 0x08;
  if (((dest >> 3) & 1))
    rex |= 0x02;
  if (((source >> 3) & 1))
    rex |= 0x01;
  write_byte(rex);
  write_byte(opcode);
  write_byte(((((3) & 0x3) << 6) | (((dest)&0x7) << 3) | ((source)&0x7)));
}


x86 assembly (clang, -O0):
<emit_generic_instruction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x48,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x3,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1143 <emit_generic_instruction+0x33>
mov    -0x10(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x3,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     115e <emit_generic_instruction+0x4e>
mov    -0x10(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <write_byte@plt>
mov    -0xc(%rbp),%edi
call   1030 <write_byte@plt>
mov    -0x4(%rbp),%edi
and    $0x7,%edi
shl    $0x3,%edi
or     $0xc0,%edi
mov    -0x8(%rbp),%eax
and    $0x7,%eax
or     %eax,%edi
call   1030 <write_byte@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_generic_instruction>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%ebp
mov    %edi,%eax
and    $0x8,%eax
shr    $0x2,%eax
mov    %esi,%ecx
shr    $0x3,%ecx
and    $0x1,%ecx
lea    (%rax,%rcx,1),%edi
add    $0x48,%edi
call   1030 <write_byte@plt>
mov    %r14d,%edi
call   1030 <write_byte@plt>
and    $0x1f,%ebp
and    $0x7,%ebx
lea    (%rbx,%rbp,8),%edi
or     $0xc0,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <write_byte@plt>

LLVM IR (-O0):
define void @emit_generic_instruction(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 72, i32* %7
%8 = load i32, i32* %4
%9 = ashr i32 %8, 3
%10 = and i32 %9, 1
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i32, i32* %7
%14 = or i32 %13, 2
store i32 %14, i32* %7
br label %15
15: ; preds = %12, %3
%16 = load i32, i32* %5
%17 = ashr i32 %16, 3
%18 = and i32 %17, 1
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i32, i32* %7
%22 = or i32 %21, 1
store i32 %22, i32* %7
br label %23
23: ; preds = %20, %15
%24 = load i32, i32* %7
%25 = call i32 @write_byte(i32 %24)
%26 = load i32, i32* %6
%27 = call i32 @write_byte(i32 %26)
%28 = load i32, i32* %4
%29 = and i32 %28, 7
%30 = shl i32 %29, 3
%31 = or i32 192, %30
%32 = load i32, i32* %5
%33 = and i32 %32, 7
%34 = or i32 %31, %33
%35 = call i32 @write_byte(i32 %34)
ret void
}

LLVM IR (-O2):
define void @emit_generic_instruction(i32 %0, i32 %1, i32 %2) {
%4 = and i32 %0, 8
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i32 72, i32 74
%7 = lshr i32 %1, 3
%8 = and i32 %7, 1
%9 = or i32 %8, %6
%10 = tail call i32 @write_byte(i32 %9)
%11 = tail call i32 @write_byte(i32 %2)
%12 = shl i32 %0, 3
%13 = and i32 %12, 56
%14 = and i32 %1, 7
%15 = or i32 %14, %13
%16 = or i32 %15, 192
%17 = tail call i32 @write_byte(i32 %16)
ret void
}