#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*/ send_ctrl_cmd(int);
int /*<<< orphan*/ set_lcm_register(int, unsigned int);
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(0x50, x0);
  set_lcm_register(0x51, x1);
  set_lcm_register(0x52, y0);
  set_lcm_register(0x53, y1);
  set_lcm_register(0x20, x0);
  set_lcm_register(0x21, y0);
  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),%esi
mov    $0x50,%edi
call   1030 <set_lcm_register@plt>
mov    -0x1c(%rbp),%esi
mov    $0x51,%edi
call   1030 <set_lcm_register@plt>
mov    -0x18(%rbp),%esi
mov    $0x52,%edi
call   1030 <set_lcm_register@plt>
mov    -0x20(%rbp),%esi
mov    $0x53,%edi
call   1030 <set_lcm_register@plt>
mov    -0x14(%rbp),%esi
mov    $0x20,%edi
call   1030 <set_lcm_register@plt>
mov    -0x18(%rbp),%esi
mov    $0x21,%edi
call   1030 <set_lcm_register@plt>
mov    $0x22,%edi
call   1040 <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,%r14d
mov    %edi,%ebx
lea    -0x1(%rbx,%rdx,1),%ebp
lea    (%r14,%rcx,1),%r15d
add    $0xffffffff,%r15d
mov    $0x50,%edi
mov    %ebx,%esi
call   1030 <set_lcm_register@plt>
mov    $0x51,%edi
mov    %ebp,%esi
call   1030 <set_lcm_register@plt>
mov    $0x52,%edi
mov    %r14d,%esi
call   1030 <set_lcm_register@plt>
mov    $0x53,%edi
mov    %r15d,%esi
call   1030 <set_lcm_register@plt>
mov    $0x20,%edi
mov    %ebx,%esi
call   1030 <set_lcm_register@plt>
mov    $0x21,%edi
mov    %r14d,%esi
call   1030 <set_lcm_register@plt>
mov    $0x22,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <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 @set_lcm_register(i32 80, i32 %23)
%25 = load i32, i32* %11
%26 = call i32 @set_lcm_register(i32 81, i32 %25)
%27 = load i32, i32* %10
%28 = call i32 @set_lcm_register(i32 82, i32 %27)
%29 = load i32, i32* %12
%30 = call i32 @set_lcm_register(i32 83, i32 %29)
%31 = load i32, i32* %9
%32 = call i32 @set_lcm_register(i32 32, i32 %31)
%33 = load i32, i32* %10
%34 = call i32 @set_lcm_register(i32 33, i32 %33)
%35 = 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 @set_lcm_register(i32 80, i32 %0)
%10 = tail call i32 @set_lcm_register(i32 81, i32 %6)
%11 = tail call i32 @set_lcm_register(i32 82, i32 %1)
%12 = tail call i32 @set_lcm_register(i32 83, i32 %8)
%13 = tail call i32 @set_lcm_register(i32 32, i32 %0)
%14 = tail call i32 @set_lcm_register(i32 33, i32 %1)
%15 = tail call i32 @send_ctrl_cmd(i32 34)
ret void
}