#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)\n", imm, addr);
  assert(addr >= -128 && addr < 128);
  output_byte(0xC7);
  output_modrm(!!addr, 4, 0);
  output_sib(0, 4, 4);
  if (addr)
    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>
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%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>
cmpl   $0x0,-0x8(%rbp)
je     11ef <emit_writeword_imm_esp+0x8f>
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>
xor    %edi,%edi
test   %ebp,%ebp
setne  %dil
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>
test   %ebp,%ebp
je     11c2 <emit_writeword_imm_esp+0x62>
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 = [19 x i8] c"mov $%x,%x(%%esp)\0A\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 ([19 x i8], [19 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 = load i32, i32* %4
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
%21 = xor i1 %20, true
%22 = zext i1 %21 to i32
%23 = call i32 @output_modrm(i32 %22, i32 4, i32 0)
%24 = call i32 @output_sib(i32 0, i32 4, i32 4)
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %13
%28 = load i32, i32* %4
%29 = call i32 @output_byte(i32 %28)
br label %30
30: ; preds = %27, %13
%31 = load i32, i32* %3
%32 = call i32 @output_w32(i32 %31)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"mov $%x,%x(%%esp)\0A\00"
define void @emit_writeword_imm_esp(i32 %0, i32 %1) {
%3 = tail call i32 @assem_debug(i8* getelementptr inbounds ([19 x i8], [19 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 = icmp ne i32 %1, 0
%10 = zext i1 %9 to i32
%11 = tail call i32 @output_modrm(i32 %10, i32 4, i32 0)
%12 = tail call i32 @output_sib(i32 0, i32 4, i32 4)
br i1 %9, label %13, label %15
13: ; preds = %2
%14 = tail call i32 @output_byte(i32 %1)
br label %15
15: ; preds = %13, %2
%16 = tail call i32 @output_w32(i32 %0)
ret void
}