#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*/ error(char *);
int /*<<< orphan*/ insert16(int);
int /*<<< orphan*/ insert8(int);
int /*<<< orphan*/ warning(char *);
void codemode(int code, int add, int value) {
  insert8(code + add);
  if (!add && (code == 0x8c || code == 0x8e || code == 0xc3 || code == 0xcc ||
               code == 0xce || code == 0x83)) {
    insert16(value);
  } else if (add == 0x30) {
    insert16(value);
  } else {
    insert8(value);
    if (value & 0xff00) {
      if (add == 0x20) {
        error("too long displacement");
      } else {
        warning("operand overflow");
      }
    }
  }
}


x86 assembly (clang, -O0):
<codemode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
add    -0x8(%rbp),%edi
call   1040 <insert8@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11c1 <codemode+0x81>
cmpl   $0x8c,-0x4(%rbp)
je     11b4 <codemode+0x74>
cmpl   $0x8e,-0x4(%rbp)
je     11b4 <codemode+0x74>
cmpl   $0xc3,-0x4(%rbp)
je     11b4 <codemode+0x74>
cmpl   $0xcc,-0x4(%rbp)
je     11b4 <codemode+0x74>
cmpl   $0xce,-0x4(%rbp)
je     11b4 <codemode+0x74>
cmpl   $0x83,-0x4(%rbp)
jne    11c1 <codemode+0x81>
mov    -0xc(%rbp),%edi
call   1050 <insert16@plt>
jmp    1227 <codemode+0xe7>
cmpl   $0x30,-0x8(%rbp)
jne    11d8 <codemode+0x98>
mov    -0xc(%rbp),%edi
call   1050 <insert16@plt>
jmp    1222 <codemode+0xe2>
mov    -0xc(%rbp),%edi
call   1040 <insert8@plt>
mov    -0xc(%rbp),%eax
and    $0xff00,%eax
cmp    $0x0,%eax
je     121d <codemode+0xdd>
cmpl   $0x20,-0x8(%rbp)
jne    120c <codemode+0xcc>
lea    0xdfe(%rip),%rdi
call   1060 <error@plt>
jmp    1218 <codemode+0xd8>
lea    0xe03(%rip),%rdi
call   1030 <warning@plt>
jmp    121d <codemode+0xdd>
jmp    1222 <codemode+0xe2>
jmp    1227 <codemode+0xe7>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<codemode>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%ebp
lea    (%rbx,%rbp,1),%edi
call   1040 <insert8@plt>
cmp    $0x30,%ebx
je     11ac <codemode+0x6c>
test   %ebx,%ebx
jne    117c <codemode+0x3c>
lea    -0x83(%rbp),%eax
cmp    $0xb,%eax
jbe    11a2 <codemode+0x62>
add    $0xffffff3d,%ebp
cmp    $0xb,%ebp
ja     117c <codemode+0x3c>
mov    $0xa01,%eax
bt     %ebp,%eax
jb     11ac <codemode+0x6c>
mov    %r14d,%edi
call   1040 <insert8@plt>
test   $0xff00,%r14d
je     11b8 <codemode+0x78>
cmp    $0x20,%ebx
jne    11bd <codemode+0x7d>
lea    0xe67(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <error@plt>
mov    $0xa01,%ecx
bt     %eax,%ecx
jae    1167 <codemode+0x27>
mov    %r14d,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <insert16@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe52(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <warning@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"too long displacement\00"
@.str.1 = [17 x i8] c"operand overflow\00"
define void @codemode(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = add nsw i32 %7, %8
%10 = call i32 @insert8(i32 %9)
%11 = load i32, i32* %5
%12 = icmp ne i32 %11, 0
br i1 %12, label %34, label %13
13: ; preds = %3
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 140
br i1 %15, label %31, label %16
16: ; preds = %13
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 142
br i1 %18, label %31, label %19
19: ; preds = %16
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 195
br i1 %21, label %31, label %22
22: ; preds = %19
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 204
br i1 %24, label %31, label %25
25: ; preds = %22
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 206
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 131
br i1 %30, label %31, label %34
31: ; preds = %28, %25, %22, %19, %16, %13
%32 = load i32, i32* %6
%33 = call i32 @insert16(i32 %32)
br label %56
34: ; preds = %28, %3
%35 = load i32, i32* %5
%36 = icmp eq i32 %35, 48
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %6
%39 = call i32 @insert16(i32 %38)
br label %55
40: ; preds = %34
%41 = load i32, i32* %6
%42 = call i32 @insert8(i32 %41)
%43 = load i32, i32* %6
%44 = and i32 %43, 65280
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %54
46: ; preds = %40
%47 = load i32, i32* %5
%48 = icmp eq i32 %47, 32
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %53
51: ; preds = %46
%52 = call i32 @warning(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %53
53: ; preds = %51, %49
br label %54
54: ; preds = %53, %40
br label %55
55: ; preds = %54, %37
br label %56
56: ; preds = %55, %31
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"too long displacement\00"
@.str.1 = [17 x i8] c"operand overflow\00"
define void @codemode(i32 %0, i32 %1, i32 %2) {
%4 = add nsw i32 %1, %0
%5 = tail call i32 @insert8(i32 %4)
switch i32 %1, label %11 [
i32 0, label %6
i32 48, label %9
]
6: ; preds = %3
switch i32 %0, label %11 [
i32 206, label %7
i32 204, label %7
i32 195, label %7
i32 142, label %7
i32 140, label %7
i32 131, label %7
]
7: ; preds = %6, %6, %6, %6, %6, %6
%8 = tail call i32 @insert16(i32 %2)
br label %21
9: ; preds = %3
%10 = tail call i32 @insert16(i32 %2)
br label %21
11: ; preds = %6, %3
%12 = tail call i32 @insert8(i32 %2)
%13 = and i32 %2, 65280
%14 = icmp eq i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %11
%16 = icmp eq i32 %1, 32
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = tail call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %21
19: ; preds = %15
%20 = tail call i32 @warning(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %9, %17, %19, %11, %7
ret void
}