#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_CW_send(char *, int);
int drv_CW_brightness(int brightness) {
  static unsigned char Brightness = 0;
  char cmd[5] = "\376A_\375";
  if (brightness == -1)
    return Brightness;
  if (brightness < 0)
    brightness = 0;
  if (brightness > 8)
    brightness = 8;
  Brightness = brightness;
  switch (Brightness) {
  case 0:
    drv_CW_send("\376F\375", 3);
    break;
  case 8:
    drv_CW_send("\376B\375", 3);
    break;
  default:
    cmd[2] = (char)Brightness;
    drv_CW_send(cmd, 4);
    break;
  }
  return Brightness;
}


x86 assembly (clang, -O0):
<drv_CW_brightness>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    0xedf(%rip),%eax
mov    %eax,-0xd(%rbp)
mov    0xeda(%rip),%al
mov    %al,-0x9(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1146 <drv_CW_brightness+0x36>
movzbl 0x2eeb(%rip),%eax
mov    %eax,-0x4(%rbp)
jmp    11e6 <drv_CW_brightness+0xd6>
cmpl   $0x0,-0x8(%rbp)
jge    1157 <drv_CW_brightness+0x47>
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jle    1168 <drv_CW_brightness+0x58>
movl   $0x8,-0x8(%rbp)
mov    -0x8(%rbp),%al
mov    %al,0x2eb8(%rip)
movzbl 0x2eb1(%rip),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     1199 <drv_CW_brightness+0x89>
jmp    1188 <drv_CW_brightness+0x78>
mov    -0x14(%rbp),%eax
sub    $0x8,%eax
je     11af <drv_CW_brightness+0x9f>
jmp    11c5 <drv_CW_brightness+0xb5>
lea    0xe65(%rip),%rdi
mov    $0x3,%esi
call   1030 <drv_CW_send@plt>
jmp    11dc <drv_CW_brightness+0xcc>
lea    0xe53(%rip),%rdi
mov    $0x3,%esi
call   1030 <drv_CW_send@plt>
jmp    11dc <drv_CW_brightness+0xcc>
mov    0x2e5e(%rip),%al
mov    %al,-0xb(%rbp)
lea    -0xd(%rbp),%rdi
mov    $0x4,%esi
call   1030 <drv_CW_send@plt>
movzbl 0x2e46(%rip),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drv_CW_brightness>:
push   %rax
movb   $0x0,0x4(%rsp)
movl   $0xfd5f41fe,(%rsp)
cmp    $0xffffffff,%edi
je     1170 <drv_CW_brightness+0x60>
xor    %ecx,%ecx
test   %edi,%edi
cmovns %edi,%ecx
cmp    $0x8,%ecx
mov    $0x8,%eax
cmovb  %ecx,%eax
mov    %al,0x2eef(%rip)
cmp    $0x8,%eax
je     1151 <drv_CW_brightness+0x41>
test   %eax,%eax
jne    115f <drv_CW_brightness+0x4f>
lea    0xebb(%rip),%rdi
mov    $0x3,%esi
jmp    116b <drv_CW_brightness+0x5b>
lea    0xeb1(%rip),%rdi
mov    $0x3,%esi
jmp    116b <drv_CW_brightness+0x5b>
mov    %al,0x2(%rsp)
mov    %rsp,%rdi
mov    $0x4,%esi
call   1030 <drv_CW_send@plt>
movzbl 0x2eb2(%rip),%eax
pop    %rcx
ret

LLVM IR (-O0):
@drv_CW_brightness.Brightness = internal global i8 0
@__const.drv_CW_brightness.cmd = [5 x i8] c"\FEA_\FD\00"
@.str = [4 x i8] c"\FEF\FD\00"
@.str.1 = [4 x i8] c"\FEB\FD\00"
define i32 @drv_CW_brightness(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [5 x i8]
store i32 %0, i32* %3
%5 = bitcast [5 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_CW_brightness.Brightness
%10 = zext i8 %9 to i32
store i32 %10, i32* %2
br label %36
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, 8
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 8, 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_CW_brightness.Brightness
%22 = load i8, i8* @drv_CW_brightness.Brightness
%23 = zext i8 %22 to i32
switch i32 %23, label %28 [
i32 0, label %24
i32 8, label %26
]
24: ; preds = %19
%25 = call i32 @drv_CW_send(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
br label %33
26: ; preds = %19
%27 = call i32 @drv_CW_send(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
br label %33
28: ; preds = %19
%29 = load i8, i8* @drv_CW_brightness.Brightness
%30 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 2
store i8 %29, i8* %30
%31 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%32 = call i32 @drv_CW_send(i8* %31, i32 4)
br label %33
33: ; preds = %28, %26, %24
%34 = load i8, i8* @drv_CW_brightness.Brightness
%35 = zext i8 %34 to i32
store i32 %35, i32* %2
br label %36
36: ; preds = %33, %8
%37 = load i32, i32* %2
ret i32 %37
}

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