#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 increases_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 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    1198 <increases_blacklight+0x38>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1215 <increases_blacklight+0xb5>
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 <increases_blacklight+0x6f>
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    11ea <increases_blacklight+0x8a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120c <increases_blacklight+0xac>
cmpl   $0x0,-0x18(%rbp)
jle    120c <increases_blacklight+0xac>
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):
<increases_blacklight>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <get_driver@plt>
test   %rax,%rax
je     11d1 <increases_blacklight+0x71>
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),%ecx
mov    $0x1,%esi
cmp    $0x13,%ecx
jb     11ab <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    11c2 <increases_blacklight+0x62>
test   %esi,%esi
jle    11c2 <increases_blacklight+0x62>
mov    %rbx,%rdi
call   1080 <set_backlight@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%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 @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 %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 %45
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 = add nsw i32 %23, %24
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = load i32, i32* %2
%28 = icmp sgt i32 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %22
%30 = load i32, i32* %2
store i32 %30, i32* %5
br label %31
31: ; preds = %29, %22
%32 = load i32, i32* %5
%33 = load i32, i32* %2
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %42
35: ; preds = %31
%36 = load i32, i32* %5
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i8*, i8** %1
%40 = load i32, i32* %5
%41 = call i32 @set_backlight(i8* %39, i32 %40)
br label %42
42: ; preds = %38, %35, %31
%43 = load i8*, i8** %1
%44 = call i32 @free(i8* %43)
br label %45
45: ; preds = %42, %9
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"Error: /sys/class/backlight is empty.\00"
define void @increases_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 %23
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 nsw i32 %12, %8
%14 = icmp sgt i32 %13, %7
%15 = select i1 %14, i32 %7, i32 %13
%16 = icmp sgt i32 %7, %13
%17 = icmp sgt i32 %15, 0
%18 = and i1 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %6
%20 = tail call i32 @set_backlight(i8* %1, i32 %15)
br label %21
21: ; preds = %19, %6
%22 = tail call i32 @free(i8* %1)
br label %23
23: ; preds = %21, %3
ret void
}