#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*/ emit_addimm(unsigned int, int, unsigned int);
int /*<<< orphan*/ emit_movimm(int, unsigned int);
void emit_mov2imm_compact(int imm1, unsigned int rt1, int imm2,
                          unsigned int rt2) {
  emit_movimm(imm1, rt1);
  if (imm2 - imm1 < 128 && imm2 - imm1 >= -128)
    emit_addimm(rt1, imm2 - imm1, rt2);
  else
    emit_movimm(imm2, rt2);
}


x86 assembly (clang, -O0):
<emit_mov2imm_compact>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <emit_movimm@plt>
mov    -0xc(%rbp),%eax
sub    -0x4(%rbp),%eax
cmp    $0x80,%eax
jge    1175 <emit_mov2imm_compact+0x55>
mov    -0xc(%rbp),%eax
sub    -0x4(%rbp),%eax
cmp    $0xffffff80,%eax
jl     1175 <emit_mov2imm_compact+0x55>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
sub    -0x4(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <emit_addimm@plt>
jmp    1180 <emit_mov2imm_compact+0x60>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <emit_movimm@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_mov2imm_compact>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%ebp
call   1040 <emit_movimm@plt>
mov    %r15d,%esi
sub    %ebp,%esi
movsbl %sil,%eax
cmp    %esi,%eax
jne    1157 <emit_mov2imm_compact+0x37>
mov    %ebx,%edi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <emit_addimm@plt>
mov    %r15d,%edi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <emit_movimm@plt>

LLVM IR (-O0):
define void @emit_mov2imm_compact(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = call i32 @emit_movimm(i32 %9, i32 %10)
%12 = load i32, i32* %7
%13 = load i32, i32* %5
%14 = sub nsw i32 %12, %13
%15 = icmp slt i32 %14, 128
br i1 %15, label %16, label %28
16: ; preds = %4
%17 = load i32, i32* %7
%18 = load i32, i32* %5
%19 = sub nsw i32 %17, %18
%20 = icmp sge i32 %19, -128
br i1 %20, label %21, label %28
21: ; preds = %16
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = load i32, i32* %5
%25 = sub nsw i32 %23, %24
%26 = load i32, i32* %8
%27 = call i32 @emit_addimm(i32 %22, i32 %25, i32 %26)
br label %32
28: ; preds = %16, %4
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = call i32 @emit_movimm(i32 %29, i32 %30)
br label %32
32: ; preds = %28, %21
ret void
}

LLVM IR (-O2):
define void @emit_mov2imm_compact(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @emit_movimm(i32 %0, i32 %1)
%6 = sub nsw i32 %2, %0
%7 = add i32 %6, 128
%8 = icmp ult i32 %7, 256
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @emit_addimm(i32 %1, i32 %6, i32 %3)
br label %13
11: ; preds = %4
%12 = tail call i32 @emit_movimm(i32 %2, i32 %3)
br label %13
13: ; preds = %11, %9
ret void
}