#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*/ free(char *);
char *get_driver();
int read_backlight(char *);
int read_max_backlight(char *);
int /*<<< orphan*/ set_backlight(char *, int);
void decreases_blacklight() {
  char *driver = get_driver();
  if (driver == NULL) {
    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    1173 <decreases_blacklight+0x23>
jmp    11ef <decreases_blacklight+0x9f>
mov    -0x8(%rbp),%rdi
call   1060 <read_max_backlight@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <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    11aa <decreases_blacklight+0x5a>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     11c4 <decreases_blacklight+0x74>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e6 <decreases_blacklight+0x96>
cmpl   $0x0,-0x18(%rbp)
jle    11e6 <decreases_blacklight+0x96>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1070 <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     11c3 <decreases_blacklight+0x73>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <read_max_backlight@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1050 <read_backlight@plt>
lea    0x9(%r14),%edx
mov    $0xffffffff,%ecx
cmp    $0x13,%edx
jb     119b <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    11b4 <decreases_blacklight+0x64>
mov    %rbx,%rdi
call   1070 <set_backlight@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
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 %10
9: ; preds = %0
br label %41
10: ; preds = %0
%11 = load i8*, i8** %1
%12 = call i32 @read_max_backlight(i8* %11)
store i32 %12, i32* %2
%13 = load i8*, i8** %1
%14 = call i32 @read_backlight(i8* %13)
store i32 %14, i32* %3
%15 = load i32, i32* %2
%16 = sdiv i32 %15, 10
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %10
store i32 1, i32* %4
br label %20
20: ; preds = %19, %10
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = sub nsw i32 %21, %22
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp sle i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
store i32 1, i32* %5
br label %27
27: ; preds = %26, %20
%28 = load i32, i32* %5
%29 = load i32, i32* %2
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %38
31: ; preds = %27
%32 = load i32, i32* %5
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i8*, i8** %1
%36 = load i32, i32* %5
%37 = call i32 @set_backlight(i8* %35, i32 %36)
br label %38
38: ; preds = %34, %31, %27
%39 = load i8*, i8** %1
%40 = call i32 @free(i8* %39)
br label %41
41: ; preds = %38, %9
ret void
}

LLVM IR (-O2):
define void @decreases_blacklight() {
%1 = tail call i8* (...) @get_driver()
%2 = icmp eq i8* %1, null
br i1 %2, label %18, label %3
3: ; preds = %0
%4 = tail call i32 @read_max_backlight(i8* %1)
%5 = tail call i32 @read_backlight(i8* %1)
%6 = sdiv i32 %4, -10
%7 = add i32 %4, 9
%8 = icmp ult i32 %7, 19
%9 = select i1 %8, i32 -1, i32 %6
%10 = add i32 %9, %5
%11 = icmp sgt i32 %10, 1
%12 = select i1 %11, i32 %10, i32 1
%13 = icmp slt i32 %12, %4
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = tail call i32 @set_backlight(i8* %1, i32 %12)
br label %16
16: ; preds = %14, %3
%17 = tail call i32 @free(i8* %1)
br label %18
18: ; preds = %0, %16
ret void
}