#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*/ Disable_Backlight(int);
int /*<<< orphan*/ Enable_Backlight(int);
int /*<<< orphan*/ Write_LCD(int, char *, int);
void Backlight_Brightness(int fd, int brightness) {
  if (brightness == 1) {
    Disable_Backlight(fd);
  } else if (brightness == 7) {
    Enable_Backlight(fd);
  } else {
    char cmd[] = {254, 65, 0, 253};
    cmd[2] = (char)brightness;
    Write_LCD(fd, cmd, 4);
  }
}


x86 assembly (clang, -O0):
<Backlight_Brightness>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1155 <Backlight_Brightness+0x25>
mov    -0x4(%rbp),%edi
call   1030 <Disable_Backlight@plt>
jmp    1191 <Backlight_Brightness+0x61>
cmpl   $0x7,-0x8(%rbp)
jne    116c <Backlight_Brightness+0x3c>
mov    -0x4(%rbp),%edi
call   1040 <Enable_Backlight@plt>
jmp    118c <Backlight_Brightness+0x5c>
mov    0xe8e(%rip),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %al,-0xa(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xc(%rbp),%rsi
mov    $0x4,%edx
call   1050 <Write_LCD@plt>
jmp    1191 <Backlight_Brightness+0x61>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Backlight_Brightness>:
cmp    $0x7,%esi
je     113f <Backlight_Brightness+0xf>
cmp    $0x1,%esi
jne    1144 <Backlight_Brightness+0x14>
jmp    1030 <Disable_Backlight@plt>
jmp    1040 <Enable_Backlight@plt>
push   %rax
movl   $0xfd0041fe,0x4(%rsp)
fd
mov    %sil,0x6(%rsp)
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
call   1050 <Write_LCD@plt>
pop    %rax
ret

LLVM IR (-O0):
@__const.Backlight_Brightness.cmd = [4 x i8] c"\FEA\00\FD"
define void @Backlight_Brightness(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* %3
%10 = call i32 @Disable_Backlight(i32 %9)
br label %26
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 7
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %3
%16 = call i32 @Enable_Backlight(i32 %15)
br label %25
17: ; preds = %11
%18 = bitcast [4 x i8]* %5 to i8*
%19 = load i32, i32* %4
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 2
store i8 %20, i8* %21
%22 = load i32, i32* %3
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%24 = call i32 @Write_LCD(i32 %22, i8* %23, i32 4)
br label %25
25: ; preds = %17, %14
br label %26
26: ; preds = %25, %8
ret void
}

LLVM IR (-O2):
define void @Backlight_Brightness(i32 %0, i32 %1) {
%3 = alloca i32
switch i32 %1, label %8 [
i32 1, label %4
i32 7, label %6
]
4: ; preds = %2
%5 = tail call i32 @Disable_Backlight(i32 %0)
br label %14
6: ; preds = %2
%7 = tail call i32 @Enable_Backlight(i32 %0)
br label %14
8: ; preds = %2
%9 = bitcast i32* %3 to [4 x i8]*
%10 = bitcast i32* %3 to i8*
store i32 -50314754, i32* %3
%11 = trunc i32 %1 to i8
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 2
store i8 %11, i8* %12
%13 = call i32 @Write_LCD(i32 %0, i8* %10, i32 4)
br label %14
14: ; preds = %6, %8, %4
ret void
}