#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 increases_blacklight() {
  char *driver = get_driver();
  if (driver == NULL) {
    return;
  }
  int max_value = read_max_backlight(driver);
  int actual = read_backlight(driver);
  int incr = max_value / 10;
  if (incr == 0)
    incr = 1;
  int value = actual + incr;
  if (value > max_value)
    value = max_value;
  if (value < max_value && value > 0) {
    set_backlight(driver, value);
  }
  free(driver);
}


x86 assembly (clang, -O0):
<increases_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 <increases_blacklight+0x23>
jmp    11f0 <increases_blacklight+0xa0>
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 <increases_blacklight+0x5a>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11c5 <increases_blacklight+0x75>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e7 <increases_blacklight+0x97>
cmpl   $0x0,-0x18(%rbp)
jle    11e7 <increases_blacklight+0x97>
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):
<increases_blacklight>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <get_driver@plt>
test   %rax,%rax
je     11c1 <increases_blacklight+0x71>
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),%ecx
mov    $0x1,%esi
cmp    $0x13,%ecx
jb     119b <increases_blacklight+0x4b>
movslq %r14d,%rcx
imul   $0x66666667,%rcx,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rsi
add    %ecx,%esi
add    %eax,%esi
cmp    %r14d,%esi
cmovg  %r14d,%esi
jge    11b2 <increases_blacklight+0x62>
test   %esi,%esi
jle    11b2 <increases_blacklight+0x62>
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 @increases_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 %43
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 = add nsw i32 %21, %22
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = load i32, i32* %2
%26 = icmp sgt i32 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = load i32, i32* %2
store i32 %28, i32* %5
br label %29
29: ; preds = %27, %20
%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):
define void @increases_blacklight() {
%1 = tail call i8* (...) @get_driver()
%2 = icmp eq i8* %1, null
br i1 %2, label %20, 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 nsw i32 %9, %5
%11 = icmp sgt i32 %10, %4
%12 = select i1 %11, i32 %4, i32 %10
%13 = icmp sgt i32 %4, %10
%14 = icmp sgt i32 %12, 0
%15 = and i1 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = tail call i32 @set_backlight(i8* %1, i32 %12)
br label %18
18: ; preds = %16, %3
%19 = tail call i32 @free(i8* %1)
br label %20
20: ; preds = %0, %18
ret void
}