#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*/ assem_debug(char *, int, int);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ output_byte(int);
int /*<<< orphan*/ output_modrm(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ output_w32(int);
void emit_writebyte_imm(int imm, int addr) {
  assem_debug("movb $%x,%x\n", imm, addr);
  assert(imm >= -128 && imm < 128);
  output_byte(0xC6);
  output_modrm(0, 5, 0);
  output_w32(addr);
  output_byte(imm);
}


x86 assembly (clang, -O0):
<emit_writebyte_imm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe95(%rip),%rdi
call   1030 <assem_debug@plt>
xor    %eax,%eax
cmpl   $0xffffff80,-0x4(%rbp)
mov    %al,-0x9(%rbp)
jl     118c <emit_writebyte_imm+0x3c>
cmpl   $0x80,-0x4(%rbp)
setl   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    $0xc6,%edi
call   1050 <output_byte@plt>
xor    %edx,%edx
mov    $0x5,%esi
mov    %edx,%edi
call   1060 <output_modrm@plt>
mov    -0x8(%rbp),%edi
call   1040 <output_w32@plt>
mov    -0x4(%rbp),%edi
call   1050 <output_byte@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_writebyte_imm>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xea2(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <assem_debug@plt>
movsbl %bl,%eax
xor    %edi,%edi
cmp    %ebx,%eax
sete   %dil
call   1070 <assert@plt>
mov    $0xc6,%edi
call   1050 <output_byte@plt>
xor    %edi,%edi
mov    $0x5,%esi
xor    %edx,%edx
call   1060 <output_modrm@plt>
mov    %ebp,%edi
call   1040 <output_w32@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <output_byte@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"movb $%x,%x\0A\00"
define void @emit_writebyte_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 = load i32, i32* %4
%7 = call i32 @assem_debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = load i32, i32* %3
%9 = icmp sge i32 %8, -128
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 128
br label %13
13: ; preds = %10, %2
%14 = phi i1 [ false, %2 ], [ %12, %10 ]
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = call i32 @output_byte(i32 198)
%18 = call i32 @output_modrm(i32 0, i32 5, i32 0)
%19 = load i32, i32* %4
%20 = call i32 @output_w32(i32 %19)
%21 = load i32, i32* %3
%22 = call i32 @output_byte(i32 %21)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"movb $%x,%x\0A\00"
define void @emit_writebyte_imm(i32 %0, i32 %1) {
%3 = tail call i32 @assem_debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%4 = add i32 %0, 128
%5 = icmp ult i32 %4, 256
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 @output_byte(i32 198)
%9 = tail call i32 @output_modrm(i32 0, i32 5, i32 0)
%10 = tail call i32 @output_w32(i32 %1)
%11 = tail call i32 @output_byte(i32 %0)
ret void
}