#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*/ drv_generic_serial_write(char *, int);
int drv_MO_backlight(int backlight) {
  static unsigned char Backlight = 0;
  char cmd[3] = "\376Bn";
  if (backlight == -1)
    return Backlight;
  if (backlight < 0)
    backlight = 0;
  if (backlight > 255)
    backlight = 255;
  Backlight = backlight;
  if (backlight <= 0) {
    drv_generic_serial_write("\376F", 2);
  } else {
    cmd[2] = Backlight;
    drv_generic_serial_write(cmd, 3);
  }
  return Backlight;
}


x86 assembly (clang, -O0):
<drv_MO_backlight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    0xede(%rip),%ax
mov    %ax,-0xb(%rbp)
mov    0xed6(%rip),%al
mov    %al,-0x9(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1148 <drv_MO_backlight+0x38>
movzbl 0x2ee9(%rip),%eax
mov    %eax,-0x4(%rbp)
jmp    11b7 <drv_MO_backlight+0xa7>
cmpl   $0x0,-0x8(%rbp)
jge    1159 <drv_MO_backlight+0x49>
movl   $0x0,-0x8(%rbp)
cmpl   $0xff,-0x8(%rbp)
jle    116d <drv_MO_backlight+0x5d>
movl   $0xff,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %al,0x2eb3(%rip)
cmpl   $0x0,-0x8(%rbp)
jg     1196 <drv_MO_backlight+0x86>
lea    0xe7c(%rip),%rdi
mov    $0x2,%esi
call   1030 <drv_generic_serial_write@plt>
jmp    11ad <drv_MO_backlight+0x9d>
mov    0x2e8d(%rip),%al
mov    %al,-0x9(%rbp)
lea    -0xb(%rbp),%rdi
mov    $0x3,%esi
call   1030 <drv_generic_serial_write@plt>
movzbl 0x2e75(%rip),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drv_MO_backlight>:
push   %rax
movw   $0x42fe,0x4(%rsp)
cmp    $0xffffffff,%edi
je     115d <drv_MO_backlight+0x4d>
xor    %ecx,%ecx
test   %edi,%edi
cmovns %edi,%ecx
cmp    $0xff,%ecx
mov    $0xff,%eax
cmovb  %ecx,%eax
mov    %al,0x2ef1(%rip)
test   %eax,%eax
je     114c <drv_MO_backlight+0x3c>
mov    %al,0x6(%rsp)
lea    0x4(%rsp),%rdi
mov    $0x3,%esi
jmp    1158 <drv_MO_backlight+0x48>
lea    0xead(%rip),%rdi
mov    $0x2,%esi
call   1030 <drv_generic_serial_write@plt>
movzbl 0x2ec5(%rip),%eax
pop    %rcx
ret

LLVM IR (-O0):
@drv_MO_backlight.Backlight = internal global i8 0
@__const.drv_MO_backlight.cmd = [3 x i8] c"\FEBn"
@.str = [3 x i8] c"\FEF\00"
define i32 @drv_MO_backlight(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x i8]
store i32 %0, i32* %3
%5 = bitcast [3 x i8]* %4 to i8*
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i8, i8* @drv_MO_backlight.Backlight
%10 = zext i8 %9 to i32
store i32 %10, i32* %2
br label %34
11: ; preds = %1
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 0, i32* %3
br label %15
15: ; preds = %14, %11
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, 255
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 255, i32* %3
br label %19
19: ; preds = %18, %15
%20 = load i32, i32* %3
%21 = trunc i32 %20 to i8
store i8 %21, i8* @drv_MO_backlight.Backlight
%22 = load i32, i32* %3
%23 = icmp sle i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call i32 @drv_generic_serial_write(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
br label %31
26: ; preds = %19
%27 = load i8, i8* @drv_MO_backlight.Backlight
%28 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
store i8 %27, i8* %28
%29 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%30 = call i32 @drv_generic_serial_write(i8* %29, i32 3)
br label %31
31: ; preds = %26, %24
%32 = load i8, i8* @drv_MO_backlight.Backlight
%33 = zext i8 %32 to i32
store i32 %33, i32* %2
br label %34
34: ; preds = %31, %8
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@drv_MO_backlight.Backlight = internal unnamed_addr global i8 0
@.str = [3 x i8] c"\FEF\00"
define i32 @drv_MO_backlight(i32 %0) {
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%4 = bitcast [3 x i8]* %2 to i16*
store i16 17150, i16* %4
%5 = icmp eq i32 %0, -1
br i1 %5, label %18, label %6
6: ; preds = %1
%7 = icmp sgt i32 %0, 0
%8 = select i1 %7, i32 %0, i32 0
%9 = icmp ult i32 %8, 255
%10 = select i1 %9, i32 %8, i32 255
%11 = trunc i32 %10 to i8
store i8 %11, i8* @drv_MO_backlight.Backlight
%12 = icmp eq i32 %10, 0
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = tail call i32 @drv_generic_serial_write(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
br label %18
15: ; preds = %6
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
store i8 %11, i8* %16
%17 = call i32 @drv_generic_serial_write(i8* %3, i32 3)
br label %18
18: ; preds = %13, %15, %1
%19 = load i8, i8* @drv_MO_backlight.Backlight
%20 = zext i8 %19 to i32
ret i32 %20
}