#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*/ exec_write_cmd(void *, int, int, int);
void PEX_8111Write(void *info, int addr, int data) {
  if (addr < 0x1000) {
    exec_write_cmd(info, addr, 4, data);
  } else if (addr >= 0x1000 && addr <= 0x1FFF) {
    exec_write_cmd(info, 0x84, 4, addr);
    exec_write_cmd(info, 0x88, 4, data);
  }
}


x86 assembly (clang, -O0):
<PEX_8111Write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x1000,-0xc(%rbp)
jge    1148 <PEX_8111Write+0x38>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%ecx
mov    $0x4,%edx
call   1030 <exec_write_cmd@plt>
jmp    1193 <PEX_8111Write+0x83>
cmpl   $0x1000,-0xc(%rbp)
jl     118e <PEX_8111Write+0x7e>
cmpl   $0x1fff,-0xc(%rbp)
jg     118e <PEX_8111Write+0x7e>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%ecx
mov    $0x84,%esi
mov    $0x4,%edx
call   1030 <exec_write_cmd@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%ecx
mov    $0x88,%esi
mov    $0x4,%edx
call   1030 <exec_write_cmd@plt>
jmp    1193 <PEX_8111Write+0x83>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PEX_8111Write>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%ecx
mov    %rdi,%rbx
cmp    $0x1000,%esi
jl     1141 <PEX_8111Write+0x31>
cmp    $0x1fff,%ecx
ja     1158 <PEX_8111Write+0x48>
mov    %rbx,%rdi
mov    $0x84,%esi
mov    $0x4,%edx
call   1030 <exec_write_cmd@plt>
mov    $0x88,%ecx
mov    %rbx,%rdi
mov    %ecx,%esi
mov    $0x4,%edx
mov    %ebp,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <exec_write_cmd@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @PEX_8111Write(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 4096
br i1 %8, label %9, label %14
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = call i32 @exec_write_cmd(i8* %10, i32 %11, i32 4, i32 %12)
br label %28
14: ; preds = %3
%15 = load i32, i32* %5
%16 = icmp sge i32 %15, 4096
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = load i32, i32* %5
%19 = icmp sle i32 %18, 8191
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load i8*, i8** %4
%22 = load i32, i32* %5
%23 = call i32 @exec_write_cmd(i8* %21, i32 132, i32 4, i32 %22)
%24 = load i8*, i8** %4
%25 = load i32, i32* %6
%26 = call i32 @exec_write_cmd(i8* %24, i32 136, i32 4, i32 %25)
br label %27
27: ; preds = %20, %17, %14
br label %28
28: ; preds = %27, %9
ret void
}

LLVM IR (-O2):
define void @PEX_8111Write(i8* %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, 4096
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = icmp ult i32 %1, 8192
br i1 %6, label %7, label %12
7: ; preds = %5
%8 = tail call i32 @exec_write_cmd(i8* %0, i32 132, i32 4, i32 %1)
br label %9
9: ; preds = %3, %7
%10 = phi i32 [ 136, %7 ], [ %1, %3 ]
%11 = tail call i32 @exec_write_cmd(i8* %0, i32 %10, i32 4, i32 %2)
br label %12
12: ; preds = %9, %5
ret void
}