#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(unsigned short);
void lcm_update(unsigned int x, unsigned int y, unsigned int width,
                unsigned int height) {
  unsigned short x0, y0, x1, y1;
  unsigned 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 = (unsigned short)x;
  y0 = (unsigned short)y;
  x1 = (unsigned short)x + width - 1;
  y1 = (unsigned short)y + height - 1;
  h_X_start = ((x0 & 0xFF00) >> 8);
  l_X_start = (x0 & 0x00FF);
  h_X_end = ((x1 & 0xFF00) >> 8);
  l_X_end = (x1 & 0x00FF);
  h_Y_start = ((y0 & 0xFF00) >> 8);
  l_Y_start = (y0 & 0x00FF);
  h_Y_end = ((y1 & 0xFF00) >> 8);
  l_Y_end = (y1 & 0x00FF);
  send_ctrl_cmd(0x2A);
  send_data_cmd(h_X_start);
  send_data_cmd(l_X_start);
  send_data_cmd(h_X_end);
  send_data_cmd(l_X_end);
  send_ctrl_cmd(0x2B);
  send_data_cmd(h_Y_start);
  send_data_cmd(l_Y_start);
  send_data_cmd(h_Y_end);
  send_data_cmd(l_Y_end);
  send_ctrl_cmd(0x29);
  send_ctrl_cmd(0x2C);
}


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
movzwl %ax,%eax
add    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %ax,-0x16(%rbp)
mov    -0x8(%rbp),%eax
movzwl %ax,%eax
add    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %ax,-0x18(%rbp)
movzwl -0x12(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %ax,-0x1a(%rbp)
movzwl -0x12(%rbp),%eax
and    $0xff,%eax
mov    %ax,-0x1c(%rbp)
movzwl -0x16(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %ax,-0x1e(%rbp)
movzwl -0x16(%rbp),%eax
and    $0xff,%eax
mov    %ax,-0x20(%rbp)
movzwl -0x14(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %ax,-0x22(%rbp)
movzwl -0x14(%rbp),%eax
and    $0xff,%eax
mov    %ax,-0x24(%rbp)
movzwl -0x18(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %ax,-0x26(%rbp)
movzwl -0x18(%rbp),%eax
and    $0xff,%eax
mov    %ax,-0x28(%rbp)
mov    $0x2a,%edi
call   1040 <send_ctrl_cmd@plt>
movzwl -0x1a(%rbp),%edi
call   1030 <send_data_cmd@plt>
movzwl -0x1c(%rbp),%edi
call   1030 <send_data_cmd@plt>
movzwl -0x1e(%rbp),%edi
call   1030 <send_data_cmd@plt>
movzwl -0x20(%rbp),%edi
call   1030 <send_data_cmd@plt>
mov    $0x2b,%edi
call   1040 <send_ctrl_cmd@plt>
movzwl -0x22(%rbp),%edi
call   1030 <send_data_cmd@plt>
movzwl -0x24(%rbp),%edi
call   1030 <send_data_cmd@plt>
movzwl -0x26(%rbp),%edi
call   1030 <send_data_cmd@plt>
movzwl -0x28(%rbp),%edi
call   1030 <send_data_cmd@plt>
mov    $0x29,%edi
call   1040 <send_ctrl_cmd@plt>
mov    $0x2c,%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    %ecx,%ebp
mov    %esi,%ecx
mov    %edi,%ebx
movzbl %bh,%eax
mov    %eax,%r12d
lea    -0x1(%rdx,%rbx,1),%eax
movzbl %ah,%edx
mov    %edx,%r14d
movzbl %al,%r15d
movzbl %ch,%eax
mov    %eax,%r13d
lea    -0x1(%rbp,%rcx,1),%eax
mov    %rcx,%rbp
movzbl %ah,%ecx
mov    %ecx,(%rsp)
movzbl %al,%eax
mov    %eax,0x4(%rsp)
mov    $0x2a,%edi
call   1040 <send_ctrl_cmd@plt>
mov    %r12d,%edi
call   1030 <send_data_cmd@plt>
movzbl %bl,%edi
call   1030 <send_data_cmd@plt>
mov    %r14d,%edi
call   1030 <send_data_cmd@plt>
mov    %r15d,%edi
call   1030 <send_data_cmd@plt>
mov    $0x2b,%edi
call   1040 <send_ctrl_cmd@plt>
mov    %r13d,%edi
call   1030 <send_data_cmd@plt>
movzbl %bpl,%edi
call   1030 <send_data_cmd@plt>
mov    (%rsp),%edi
call   1030 <send_data_cmd@plt>
mov    0x4(%rsp),%edi
call   1030 <send_data_cmd@plt>
mov    $0x29,%edi
call   1040 <send_ctrl_cmd@plt>
mov    $0x2c,%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 = zext 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 = zext 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 = zext i16 %39 to i32
%41 = and i32 %40, 65280
%42 = ashr i32 %41, 8
%43 = trunc i32 %42 to i16
store i16 %43, i16* %13
%44 = load i16, i16* %9
%45 = zext 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 = zext i16 %48 to i32
%50 = and i32 %49, 65280
%51 = ashr i32 %50, 8
%52 = trunc i32 %51 to i16
store i16 %52, i16* %15
%53 = load i16, i16* %11
%54 = zext 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 = zext i16 %57 to i32
%59 = and i32 %58, 65280
%60 = ashr i32 %59, 8
%61 = trunc i32 %60 to i16
store i16 %61, i16* %17
%62 = load i16, i16* %10
%63 = zext 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 = zext i16 %66 to i32
%68 = and i32 %67, 65280
%69 = ashr i32 %68, 8
%70 = trunc i32 %69 to i16
store i16 %70, i16* %19
%71 = load i16, i16* %12
%72 = zext 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 42)
%76 = load i16, i16* %13
%77 = call i32 @send_data_cmd(i16 zeroext %76)
%78 = load i16, i16* %14
%79 = call i32 @send_data_cmd(i16 zeroext %78)
%80 = load i16, i16* %15
%81 = call i32 @send_data_cmd(i16 zeroext %80)
%82 = load i16, i16* %16
%83 = call i32 @send_data_cmd(i16 zeroext %82)
%84 = call i32 @send_ctrl_cmd(i32 43)
%85 = load i16, i16* %17
%86 = call i32 @send_data_cmd(i16 zeroext %85)
%87 = load i16, i16* %18
%88 = call i32 @send_data_cmd(i16 zeroext %87)
%89 = load i16, i16* %19
%90 = call i32 @send_data_cmd(i16 zeroext %89)
%91 = load i16, i16* %20
%92 = call i32 @send_data_cmd(i16 zeroext %91)
%93 = call i32 @send_ctrl_cmd(i32 41)
%94 = call i32 @send_ctrl_cmd(i32 44)
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 %7, 255
%10 = trunc i32 %5 to i16
%11 = add i16 %10, -1
%12 = lshr i16 %11, 8
%13 = and i16 %11, 255
%14 = trunc i32 %1 to i16
%15 = lshr i16 %14, 8
%16 = and i16 %14, 255
%17 = trunc i32 %6 to i16
%18 = add i16 %17, -1
%19 = lshr i16 %18, 8
%20 = and i16 %18, 255
%21 = tail call i32 @send_ctrl_cmd(i32 42)
%22 = tail call i32 @send_data_cmd(i16 zeroext %8)
%23 = tail call i32 @send_data_cmd(i16 zeroext %9)
%24 = tail call i32 @send_data_cmd(i16 zeroext %12)
%25 = tail call i32 @send_data_cmd(i16 zeroext %13)
%26 = tail call i32 @send_ctrl_cmd(i32 43)
%27 = tail call i32 @send_data_cmd(i16 zeroext %15)
%28 = tail call i32 @send_data_cmd(i16 zeroext %16)
%29 = tail call i32 @send_data_cmd(i16 zeroext %19)
%30 = tail call i32 @send_data_cmd(i16 zeroext %20)
%31 = tail call i32 @send_ctrl_cmd(i32 41)
%32 = tail call i32 @send_ctrl_cmd(i32 44)
ret void
}