#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, int, int /*<<< orphan*/);
int /*<<< orphan*/ output_sib(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ output_w32(int);
void emit_writeword_imm_esp(int imm, int addr) {
  assem_debug("mov $%x,%x(%%esp)", imm, addr);
  assert(addr >= -128 && addr < 128);
  output_byte(0xC7);
  output_modrm(1, 4, 0);
  output_sib(0, 4, 4);
  output_byte(addr);
  output_w32(imm);
}


x86 assembly (clang, -O0):
<emit_writeword_imm_esp>:
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    0xe85(%rip),%rdi
call   1030 <assem_debug@plt>
xor    %eax,%eax
cmpl   $0xffffff80,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jl     119c <emit_writeword_imm_esp+0x3c>
cmpl   $0x80,-0x8(%rbp)
setl   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    $0xc7,%edi
call   1050 <output_byte@plt>
mov    $0x1,%edi
mov    $0x4,%esi
xor    %edx,%edx
call   1060 <output_modrm@plt>
xor    %edi,%edi
mov    $0x4,%edx
mov    %edx,%esi
call   1080 <output_sib@plt>
mov    -0x8(%rbp),%edi
call   1050 <output_byte@plt>
mov    -0x4(%rbp),%edi
call   1040 <output_w32@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_writeword_imm_esp>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xe92(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <assem_debug@plt>
movsbl %bpl,%eax
xor    %edi,%edi
cmp    %ebp,%eax
sete   %dil
call   1070 <assert@plt>
mov    $0xc7,%edi
call   1050 <output_byte@plt>
mov    $0x1,%edi
mov    $0x4,%esi
xor    %edx,%edx
call   1060 <output_modrm@plt>
xor    %edi,%edi
mov    $0x4,%esi
mov    $0x4,%edx
call   1080 <output_sib@plt>
mov    %ebp,%edi
call   1050 <output_byte@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <output_w32@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"mov $%x,%x(%%esp)\00"
define void @emit_writeword_imm_esp(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 ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, -128
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* %4
%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 199)
%18 = call i32 @output_modrm(i32 1, i32 4, i32 0)
%19 = call i32 @output_sib(i32 0, i32 4, i32 4)
%20 = load i32, i32* %4
%21 = call i32 @output_byte(i32 %20)
%22 = load i32, i32* %3
%23 = call i32 @output_w32(i32 %22)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"mov $%x,%x(%%esp)\00"
define void @emit_writeword_imm_esp(i32 %0, i32 %1) {
%3 = tail call i32 @assem_debug(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%4 = add i32 %1, 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 199)
%9 = tail call i32 @output_modrm(i32 1, i32 4, i32 0)
%10 = tail call i32 @output_sib(i32 0, i32 4, i32 4)
%11 = tail call i32 @output_byte(i32 %1)
%12 = tail call i32 @output_w32(i32 %0)
ret void
}