#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_contrast(int contrast) {
  static unsigned char Contrast = 0;
  char cmd[3] = "\376Pn";
  if (contrast == -1)
    return Contrast;
  if (contrast < 0)
    contrast = 0;
  if (contrast > 255)
    contrast = 255;
  Contrast = contrast;
  cmd[2] = Contrast;
  drv_generic_serial_write(cmd, 3);
  return Contrast;
}


x86 assembly (clang, -O0):
<drv_MO_contrast>:
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_contrast+0x38>
movzbl 0x2ee9(%rip),%eax
mov    %eax,-0x4(%rbp)
jmp    1197 <drv_MO_contrast+0x87>
cmpl   $0x0,-0x8(%rbp)
jge    1159 <drv_MO_contrast+0x49>
movl   $0x0,-0x8(%rbp)
cmpl   $0xff,-0x8(%rbp)
jle    116d <drv_MO_contrast+0x5d>
movl   $0xff,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %al,0x2eb3(%rip)
mov    0x2ead(%rip),%al
mov    %al,-0x9(%rbp)
lea    -0xb(%rbp),%rdi
mov    $0x3,%esi
call   1030 <drv_generic_serial_write@plt>
movzbl 0x2e95(%rip),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drv_MO_contrast>:
push   %rax
movw   $0x50fe,0x4(%rsp)
cmp    $0xffffffff,%edi
je     114a <drv_MO_contrast+0x3a>
xor    %eax,%eax
test   %edi,%edi
cmovns %edi,%eax
cmp    $0xff,%eax
mov    $0xff,%ecx
cmovb  %eax,%ecx
mov    %cl,0x2ef2(%rip)
mov    %cl,0x6(%rsp)
lea    0x4(%rsp),%rdi
mov    $0x3,%esi
call   1030 <drv_generic_serial_write@plt>
movzbl 0x2ed8(%rip),%eax
pop    %rcx
ret

LLVM IR (-O0):
@drv_MO_contrast.Contrast = internal global i8 0
@__const.drv_MO_contrast.cmd = [3 x i8] c"\FEPn"
define i32 @drv_MO_contrast(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_contrast.Contrast
%10 = zext i8 %9 to i32
store i32 %10, i32* %2
br label %28
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_contrast.Contrast
%22 = load i8, i8* @drv_MO_contrast.Contrast
%23 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
store i8 %22, i8* %23
%24 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%25 = call i32 @drv_generic_serial_write(i8* %24, i32 3)
%26 = load i8, i8* @drv_MO_contrast.Contrast
%27 = zext i8 %26 to i32
store i32 %27, i32* %2
br label %28
28: ; preds = %19, %8
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@drv_MO_contrast.Contrast = internal unnamed_addr global i8 0
define i32 @drv_MO_contrast(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 20734, i16* %4
%5 = icmp eq i32 %0, -1
br i1 %5, label %14, 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_contrast.Contrast
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
store i8 %11, i8* %12
%13 = call i32 @drv_generic_serial_write(i8* %3, i32 3)
br label %14
14: ; preds = %1, %6
%15 = load i8, i8* @drv_MO_contrast.Contrast
%16 = zext i8 %15 to i32
ret i32 %16
}