#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
char *get_driver();
int read_backlight(char *);
int read_max_backlight(char *);
int /*<<< orphan*/ set_backlight(char *, int);
int /*<<< orphan*/ stderr;
void decreases_blacklight() {
  char *driver = get_driver();
  if (driver == NULL) {
    fprintf(stderr, "Error: /sys/class/backlight is empty.");
    return;
  }
  int max_value = read_max_backlight(driver);
  int actual = read_backlight(driver);
  int decr = max_value / 10;
  if (decr == 0)
    decr = 1;
  int value = actual - decr;
  if (value <= 0)
    value = 1;
  if (value < max_value && value > 0) {
    set_backlight(driver, value);
  }
  free(driver);
}


x86 assembly (clang, -O0):
<decreases_blacklight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1040 <get_driver@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1198 <decreases_blacklight+0x38>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1214 <decreases_blacklight+0xb4>
mov    -0x8(%rbp),%rdi
call   1070 <read_max_backlight@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <read_backlight@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11cf <decreases_blacklight+0x6f>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     11e9 <decreases_blacklight+0x89>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120b <decreases_blacklight+0xab>
cmpl   $0x0,-0x18(%rbp)
jle    120b <decreases_blacklight+0xab>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1080 <set_backlight@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decreases_blacklight>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <get_driver@plt>
test   %rax,%rax
je     11d3 <decreases_blacklight+0x73>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <read_max_backlight@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1060 <read_backlight@plt>
lea    0x9(%r14),%edx
mov    $0xffffffff,%ecx
cmp    $0x13,%edx
jb     11ab <decreases_blacklight+0x4b>
movslq %r14d,%rcx
imul   $0xffffffff99999999,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %eax,%ecx
test   %ecx,%ecx
mov    $0x1,%esi
cmovg  %ecx,%esi
cmp    %r14d,%esi
jge    11c4 <decreases_blacklight+0x64>
mov    %rbx,%rdi
call   1080 <set_backlight@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"Error: /sys/class/backlight is empty.\00"
define void @decreases_blacklight() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i8* (...) @get_driver()
store i8* %6, i8** %1
%7 = load i8*, i8** %1
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %43
12: ; preds = %0
%13 = load i8*, i8** %1
%14 = call i32 @read_max_backlight(i8* %13)
store i32 %14, i32* %2
%15 = load i8*, i8** %1
%16 = call i32 @read_backlight(i8* %15)
store i32 %16, i32* %3
%17 = load i32, i32* %2
%18 = sdiv i32 %17, 10
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %12
store i32 1, i32* %4
br label %22
22: ; preds = %21, %12
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = sub nsw i32 %23, %24
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = icmp sle i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %22
store i32 1, i32* %5
br label %29
29: ; preds = %28, %22
%30 = load i32, i32* %5
%31 = load i32, i32* %2
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %40
33: ; preds = %29
%34 = load i32, i32* %5
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load i8*, i8** %1
%38 = load i32, i32* %5
%39 = call i32 @set_backlight(i8* %37, i32 %38)
br label %40
40: ; preds = %36, %33, %29
%41 = load i8*, i8** %1
%42 = call i32 @free(i8* %41)
br label %43
43: ; preds = %40, %9
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"Error: /sys/class/backlight is empty.\00"
define void @decreases_blacklight() {
%1 = tail call i8* (...) @get_driver()
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %21
6: ; preds = %0
%7 = tail call i32 @read_max_backlight(i8* %1)
%8 = tail call i32 @read_backlight(i8* %1)
%9 = sdiv i32 %7, -10
%10 = add i32 %7, 9
%11 = icmp ult i32 %10, 19
%12 = select i1 %11, i32 -1, i32 %9
%13 = add i32 %12, %8
%14 = icmp sgt i32 %13, 1
%15 = select i1 %14, i32 %13, i32 1
%16 = icmp slt i32 %15, %7
br i1 %16, label %17, label %19
17: ; preds = %6
%18 = tail call i32 @set_backlight(i8* %1, i32 %15)
br label %19
19: ; preds = %17, %6
%20 = tail call i32 @free(i8* %1)
br label %21
21: ; preds = %19, %3
ret void
}