#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*/ send_data_cmd(short);
void lcm_update(unsigned int x, unsigned int y, unsigned int width,
                unsigned int height) {
  short x0, y0, x1, y1;
  short h_X_start, l_X_start, h_X_end, l_X_end, h_Y_start, l_Y_start, h_Y_end,
      l_Y_end;
  x0 = (short)x;
  y0 = (short)y;
  x1 = (short)x + width - 1;
  y1 = (short)y + height - 1;
  h_X_start = ((x0 & 0x0300) >> 8);
  l_X_start = (x0 & 0x00FF);
  h_X_end = ((x1 & 0x0300) >> 8);
  l_X_end = (x1 & 0x00FF);
  h_Y_start = ((y0 & 0x0300) >> 8);
  l_Y_start = (y0 & 0x00FF);
  h_Y_end = ((y1 & 0x0300) >> 8);
  l_Y_end = (y1 & 0x00FF);
  send_ctrl_cmd(0x2A00);
  send_data_cmd(h_X_start);
  send_ctrl_cmd(0x2A01);
  send_data_cmd(l_X_start);
  send_ctrl_cmd(0x2A02);
  send_data_cmd(h_X_end);
  send_ctrl_cmd(0x2A03);
  send_data_cmd(l_X_end);
  send_ctrl_cmd(0x2B00);
  send_data_cmd(h_Y_start);
  send_ctrl_cmd(0x2B01);
  send_data_cmd(l_Y_start);
  send_ctrl_cmd(0x2B02);
  send_data_cmd(h_Y_end);
  send_ctrl_cmd(0x2B03);
  send_data_cmd(l_Y_end);
  send_ctrl_cmd(0x2C00);
}


x86 assembly (clang, -O0):
<lcm_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %ax,-0x12(%rbp)
mov    -0x8(%rbp),%eax
mov    %ax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
cwtl
add    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %ax,-0x16(%rbp)
mov    -0x8(%rbp),%eax
cwtl
add    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %ax,-0x18(%rbp)
movswl -0x12(%rbp),%eax
and    $0x300,%eax
sar    $0x8,%eax
mov    %ax,-0x1a(%rbp)
movswl -0x12(%rbp),%eax
and    $0xff,%eax
mov    %ax,-0x1c(%rbp)
movswl -0x16(%rbp),%eax
and    $0x300,%eax
sar    $0x8,%eax
mov    %ax,-0x1e(%rbp)
movswl -0x16(%rbp),%eax
and    $0xff,%eax
mov    %ax,-0x20(%rbp)
movswl -0x14(%rbp),%eax
and    $0x300,%eax
sar    $0x8,%eax
mov    %ax,-0x22(%rbp)
movswl -0x14(%rbp),%eax
and    $0xff,%eax
mov    %ax,-0x24(%rbp)
movswl -0x18(%rbp),%eax
and    $0x300,%eax
sar    $0x8,%eax
mov    %ax,-0x26(%rbp)
movswl -0x18(%rbp),%eax
and    $0xff,%eax
mov    %ax,-0x28(%rbp)
mov    $0x2a00,%edi
call   1040 <send_ctrl_cmd@plt>
movswl -0x1a(%rbp),%edi
call   1030 <send_data_cmd@plt>
mov    $0x2a01,%edi
call   1040 <send_ctrl_cmd@plt>
movswl -0x1c(%rbp),%edi
call   1030 <send_data_cmd@plt>
mov    $0x2a02,%edi
call   1040 <send_ctrl_cmd@plt>
movswl -0x1e(%rbp),%edi
call   1030 <send_data_cmd@plt>
mov    $0x2a03,%edi
call   1040 <send_ctrl_cmd@plt>
movswl -0x20(%rbp),%edi
call   1030 <send_data_cmd@plt>
mov    $0x2b00,%edi
call   1040 <send_ctrl_cmd@plt>
movswl -0x22(%rbp),%edi
call   1030 <send_data_cmd@plt>
mov    $0x2b01,%edi
call   1040 <send_ctrl_cmd@plt>
movswl -0x24(%rbp),%edi
call   1030 <send_data_cmd@plt>
mov    $0x2b02,%edi
call   1040 <send_ctrl_cmd@plt>
movswl -0x26(%rbp),%edi
call   1030 <send_data_cmd@plt>
mov    $0x2b03,%edi
call   1040 <send_ctrl_cmd@plt>
movswl -0x28(%rbp),%edi
call   1030 <send_data_cmd@plt>
mov    $0x2c00,%edi
call   1040 <send_ctrl_cmd@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcm_update>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%r13d
mov    %edi,%r12d
shr    $0x8,%r12d
and    $0x3,%r12d
lea    (%rdx,%r13,1),%r14d
add    $0xffffffff,%r14d
movzbl %r14b,%eax
mov    %eax,(%rsp)
shr    $0x8,%r14d
and    $0x3,%r14d
mov    %esi,%ebx
shr    $0x8,%ebx
and    $0x3,%ebx
lea    (%rcx,%r15,1),%ebp
add    $0xffffffff,%ebp
movzbl %bpl,%eax
mov    %eax,0x4(%rsp)
shr    $0x8,%ebp
and    $0x3,%ebp
mov    $0x2a00,%edi
call   1040 <send_ctrl_cmd@plt>
mov    %r12d,%edi
call   1030 <send_data_cmd@plt>
mov    $0x2a01,%edi
call   1040 <send_ctrl_cmd@plt>
movzbl %r13b,%edi
call   1030 <send_data_cmd@plt>
mov    $0x2a02,%edi
call   1040 <send_ctrl_cmd@plt>
mov    %r14d,%edi
call   1030 <send_data_cmd@plt>
mov    $0x2a03,%edi
call   1040 <send_ctrl_cmd@plt>
mov    (%rsp),%edi
call   1030 <send_data_cmd@plt>
mov    $0x2b00,%edi
call   1040 <send_ctrl_cmd@plt>
mov    %ebx,%edi
call   1030 <send_data_cmd@plt>
mov    $0x2b01,%edi
call   1040 <send_ctrl_cmd@plt>
movzbl %r15b,%edi
call   1030 <send_data_cmd@plt>
mov    $0x2b02,%edi
call   1040 <send_ctrl_cmd@plt>
mov    %ebp,%edi
call   1030 <send_data_cmd@plt>
mov    $0x2b03,%edi
call   1040 <send_ctrl_cmd@plt>
mov    0x4(%rsp),%edi
call   1030 <send_data_cmd@plt>
mov    $0x2c00,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 i16
%10 = alloca i16
%11 = alloca i16
%12 = alloca i16
%13 = alloca i16
%14 = alloca i16
%15 = alloca i16
%16 = alloca i16
%17 = alloca i16
%18 = alloca i16
%19 = alloca i16
%20 = alloca i16
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%21 = load i32, i32* %5
%22 = trunc i32 %21 to i16
store i16 %22, i16* %9
%23 = load i32, i32* %6
%24 = trunc i32 %23 to i16
store i16 %24, i16* %10
%25 = load i32, i32* %5
%26 = trunc i32 %25 to i16
%27 = sext i16 %26 to i32
%28 = load i32, i32* %7
%29 = add i32 %27, %28
%30 = sub i32 %29, 1
%31 = trunc i32 %30 to i16
store i16 %31, i16* %11
%32 = load i32, i32* %6
%33 = trunc i32 %32 to i16
%34 = sext i16 %33 to i32
%35 = load i32, i32* %8
%36 = add i32 %34, %35
%37 = sub i32 %36, 1
%38 = trunc i32 %37 to i16
store i16 %38, i16* %12
%39 = load i16, i16* %9
%40 = sext i16 %39 to i32
%41 = and i32 %40, 768
%42 = ashr i32 %41, 8
%43 = trunc i32 %42 to i16
store i16 %43, i16* %13
%44 = load i16, i16* %9
%45 = sext i16 %44 to i32
%46 = and i32 %45, 255
%47 = trunc i32 %46 to i16
store i16 %47, i16* %14
%48 = load i16, i16* %11
%49 = sext i16 %48 to i32
%50 = and i32 %49, 768
%51 = ashr i32 %50, 8
%52 = trunc i32 %51 to i16
store i16 %52, i16* %15
%53 = load i16, i16* %11
%54 = sext i16 %53 to i32
%55 = and i32 %54, 255
%56 = trunc i32 %55 to i16
store i16 %56, i16* %16
%57 = load i16, i16* %10
%58 = sext i16 %57 to i32
%59 = and i32 %58, 768
%60 = ashr i32 %59, 8
%61 = trunc i32 %60 to i16
store i16 %61, i16* %17
%62 = load i16, i16* %10
%63 = sext i16 %62 to i32
%64 = and i32 %63, 255
%65 = trunc i32 %64 to i16
store i16 %65, i16* %18
%66 = load i16, i16* %12
%67 = sext i16 %66 to i32
%68 = and i32 %67, 768
%69 = ashr i32 %68, 8
%70 = trunc i32 %69 to i16
store i16 %70, i16* %19
%71 = load i16, i16* %12
%72 = sext i16 %71 to i32
%73 = and i32 %72, 255
%74 = trunc i32 %73 to i16
store i16 %74, i16* %20
%75 = call i32 @send_ctrl_cmd(i32 10752)
%76 = load i16, i16* %13
%77 = call i32 @send_data_cmd(i16 signext %76)
%78 = call i32 @send_ctrl_cmd(i32 10753)
%79 = load i16, i16* %14
%80 = call i32 @send_data_cmd(i16 signext %79)
%81 = call i32 @send_ctrl_cmd(i32 10754)
%82 = load i16, i16* %15
%83 = call i32 @send_data_cmd(i16 signext %82)
%84 = call i32 @send_ctrl_cmd(i32 10755)
%85 = load i16, i16* %16
%86 = call i32 @send_data_cmd(i16 signext %85)
%87 = call i32 @send_ctrl_cmd(i32 11008)
%88 = load i16, i16* %17
%89 = call i32 @send_data_cmd(i16 signext %88)
%90 = call i32 @send_ctrl_cmd(i32 11009)
%91 = load i16, i16* %18
%92 = call i32 @send_data_cmd(i16 signext %91)
%93 = call i32 @send_ctrl_cmd(i32 11010)
%94 = load i16, i16* %19
%95 = call i32 @send_data_cmd(i16 signext %94)
%96 = call i32 @send_ctrl_cmd(i32 11011)
%97 = load i16, i16* %20
%98 = call i32 @send_data_cmd(i16 signext %97)
%99 = call i32 @send_ctrl_cmd(i32 11264)
ret void
}

LLVM IR (-O2):
define void @lcm_update(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = add i32 %2, %0
%6 = add i32 %3, %1
%7 = trunc i32 %0 to i16
%8 = lshr i16 %7, 8
%9 = and i16 %8, 3
%10 = and i16 %7, 255
%11 = trunc i32 %5 to i16
%12 = add i16 %11, -1
%13 = lshr i16 %12, 8
%14 = and i16 %13, 3
%15 = and i16 %12, 255
%16 = trunc i32 %1 to i16
%17 = lshr i16 %16, 8
%18 = and i16 %17, 3
%19 = and i16 %16, 255
%20 = trunc i32 %6 to i16
%21 = add i16 %20, -1
%22 = lshr i16 %21, 8
%23 = and i16 %22, 3
%24 = and i16 %21, 255
%25 = tail call i32 @send_ctrl_cmd(i32 10752)
%26 = tail call i32 @send_data_cmd(i16 signext %9)
%27 = tail call i32 @send_ctrl_cmd(i32 10753)
%28 = tail call i32 @send_data_cmd(i16 signext %10)
%29 = tail call i32 @send_ctrl_cmd(i32 10754)
%30 = tail call i32 @send_data_cmd(i16 signext %14)
%31 = tail call i32 @send_ctrl_cmd(i32 10755)
%32 = tail call i32 @send_data_cmd(i16 signext %15)
%33 = tail call i32 @send_ctrl_cmd(i32 11008)
%34 = tail call i32 @send_data_cmd(i16 signext %18)
%35 = tail call i32 @send_ctrl_cmd(i32 11009)
%36 = tail call i32 @send_data_cmd(i16 signext %19)
%37 = tail call i32 @send_ctrl_cmd(i32 11010)
%38 = tail call i32 @send_data_cmd(i16 signext %23)
%39 = tail call i32 @send_ctrl_cmd(i32 11011)
%40 = tail call i32 @send_data_cmd(i16 signext %24)
%41 = tail call i32 @send_ctrl_cmd(i32 11264)
ret void
}