#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*/ HIGH_BYTE(unsigned int);
int /*<<< orphan*/ LOW_BYTE(unsigned int);
int /*<<< orphan*/ send_ctrl_cmd(int);
int /*<<< orphan*/ set_lcm_register(int, int /*<<< orphan*/);
void lcm_update(unsigned int x, unsigned int y, unsigned int width,
                unsigned int height) {
  unsigned int x0 = x;
  unsigned int y0 = y;
  unsigned int x1 = x0 + width - 1;
  unsigned int y1 = y0 + height - 1;
  set_lcm_register(0x02, HIGH_BYTE(x0));
  set_lcm_register(0x03, LOW_BYTE(x0));
  set_lcm_register(0x04, HIGH_BYTE(x1));
  set_lcm_register(0x05, LOW_BYTE(x1));
  set_lcm_register(0x06, HIGH_BYTE(y0));
  set_lcm_register(0x07, LOW_BYTE(y0));
  set_lcm_register(0x08, HIGH_BYTE(y1));
  set_lcm_register(0x09, LOW_BYTE(y1));
  send_ctrl_cmd(0x22);
}


x86 assembly (clang, -O0):
<lcm_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <HIGH_BYTE@plt>
mov    %eax,%esi
mov    $0x2,%edi
call   1030 <set_lcm_register@plt>
mov    -0x14(%rbp),%edi
call   1040 <LOW_BYTE@plt>
mov    %eax,%esi
mov    $0x3,%edi
call   1030 <set_lcm_register@plt>
mov    -0x1c(%rbp),%edi
call   1050 <HIGH_BYTE@plt>
mov    %eax,%esi
mov    $0x4,%edi
call   1030 <set_lcm_register@plt>
mov    -0x1c(%rbp),%edi
call   1040 <LOW_BYTE@plt>
mov    %eax,%esi
mov    $0x5,%edi
call   1030 <set_lcm_register@plt>
mov    -0x18(%rbp),%edi
call   1050 <HIGH_BYTE@plt>
mov    %eax,%esi
mov    $0x6,%edi
call   1030 <set_lcm_register@plt>
mov    -0x18(%rbp),%edi
call   1040 <LOW_BYTE@plt>
mov    %eax,%esi
mov    $0x7,%edi
call   1030 <set_lcm_register@plt>
mov    -0x20(%rbp),%edi
call   1050 <HIGH_BYTE@plt>
mov    %eax,%esi
mov    $0x8,%edi
call   1030 <set_lcm_register@plt>
mov    -0x20(%rbp),%edi
call   1040 <LOW_BYTE@plt>
mov    %eax,%esi
mov    $0x9,%edi
call   1030 <set_lcm_register@plt>
mov    $0x22,%edi
call   1060 <send_ctrl_cmd@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcm_update>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%ebx
lea    (%rbx,%rdx,1),%ebp
add    $0xffffffff,%ebp
lea    (%r15,%rcx,1),%r14d
add    $0xffffffff,%r14d
call   1050 <HIGH_BYTE@plt>
mov    $0x2,%edi
mov    %eax,%esi
call   1030 <set_lcm_register@plt>
mov    %ebx,%edi
call   1040 <LOW_BYTE@plt>
mov    $0x3,%edi
mov    %eax,%esi
call   1030 <set_lcm_register@plt>
mov    %ebp,%edi
call   1050 <HIGH_BYTE@plt>
mov    $0x4,%edi
mov    %eax,%esi
call   1030 <set_lcm_register@plt>
mov    %ebp,%edi
call   1040 <LOW_BYTE@plt>
mov    $0x5,%edi
mov    %eax,%esi
call   1030 <set_lcm_register@plt>
mov    %r15d,%edi
call   1050 <HIGH_BYTE@plt>
mov    $0x6,%edi
mov    %eax,%esi
call   1030 <set_lcm_register@plt>
mov    %r15d,%edi
call   1040 <LOW_BYTE@plt>
mov    $0x7,%edi
mov    %eax,%esi
call   1030 <set_lcm_register@plt>
mov    %r14d,%edi
call   1050 <HIGH_BYTE@plt>
mov    $0x8,%edi
mov    %eax,%esi
call   1030 <set_lcm_register@plt>
mov    %r14d,%edi
call   1040 <LOW_BYTE@plt>
mov    $0x9,%edi
mov    %eax,%esi
call   1030 <set_lcm_register@plt>
mov    $0x22,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <send_ctrl_cmd@plt>

LLVM IR (-O0):
define void @lcm_update(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = load i32, i32* %5
store i32 %13, i32* %9
%14 = load i32, i32* %6
store i32 %14, i32* %10
%15 = load i32, i32* %9
%16 = load i32, i32* %7
%17 = add i32 %15, %16
%18 = sub i32 %17, 1
store i32 %18, i32* %11
%19 = load i32, i32* %10
%20 = load i32, i32* %8
%21 = add i32 %19, %20
%22 = sub i32 %21, 1
store i32 %22, i32* %12
%23 = load i32, i32* %9
%24 = call i32 @HIGH_BYTE(i32 %23)
%25 = call i32 @set_lcm_register(i32 2, i32 %24)
%26 = load i32, i32* %9
%27 = call i32 @LOW_BYTE(i32 %26)
%28 = call i32 @set_lcm_register(i32 3, i32 %27)
%29 = load i32, i32* %11
%30 = call i32 @HIGH_BYTE(i32 %29)
%31 = call i32 @set_lcm_register(i32 4, i32 %30)
%32 = load i32, i32* %11
%33 = call i32 @LOW_BYTE(i32 %32)
%34 = call i32 @set_lcm_register(i32 5, i32 %33)
%35 = load i32, i32* %10
%36 = call i32 @HIGH_BYTE(i32 %35)
%37 = call i32 @set_lcm_register(i32 6, i32 %36)
%38 = load i32, i32* %10
%39 = call i32 @LOW_BYTE(i32 %38)
%40 = call i32 @set_lcm_register(i32 7, i32 %39)
%41 = load i32, i32* %12
%42 = call i32 @HIGH_BYTE(i32 %41)
%43 = call i32 @set_lcm_register(i32 8, i32 %42)
%44 = load i32, i32* %12
%45 = call i32 @LOW_BYTE(i32 %44)
%46 = call i32 @set_lcm_register(i32 9, i32 %45)
%47 = call i32 @send_ctrl_cmd(i32 34)
ret void
}

LLVM IR (-O2):
define void @lcm_update(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = add i32 %0, -1
%6 = add i32 %5, %2
%7 = add i32 %1, -1
%8 = add i32 %7, %3
%9 = tail call i32 @HIGH_BYTE(i32 %0)
%10 = tail call i32 @set_lcm_register(i32 2, i32 %9)
%11 = tail call i32 @LOW_BYTE(i32 %0)
%12 = tail call i32 @set_lcm_register(i32 3, i32 %11)
%13 = tail call i32 @HIGH_BYTE(i32 %6)
%14 = tail call i32 @set_lcm_register(i32 4, i32 %13)
%15 = tail call i32 @LOW_BYTE(i32 %6)
%16 = tail call i32 @set_lcm_register(i32 5, i32 %15)
%17 = tail call i32 @HIGH_BYTE(i32 %1)
%18 = tail call i32 @set_lcm_register(i32 6, i32 %17)
%19 = tail call i32 @LOW_BYTE(i32 %1)
%20 = tail call i32 @set_lcm_register(i32 7, i32 %19)
%21 = tail call i32 @HIGH_BYTE(i32 %8)
%22 = tail call i32 @set_lcm_register(i32 8, i32 %21)
%23 = tail call i32 @LOW_BYTE(i32 %8)
%24 = tail call i32 @set_lcm_register(i32 9, i32 %23)
%25 = tail call i32 @send_ctrl_cmd(i32 34)
ret void
}