#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 *lxqt_backlight_backend_get_driver();
int read_backlight(char *);
int /*<<< orphan*/ stderr;
int lxqt_backlight_backend_get() {
  char *driver = lxqt_backlight_backend_get_driver();
  if (driver == NULL) {
    fprintf(stderr, "Error: /sys/class/backlight is empty.");
    return -1;
  }
  int value = read_backlight(driver);
  free(driver);
  return value;
}


x86 assembly (clang, -O0):
<lxqt_backlight_backend_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <lxqt_backlight_backend_get_driver@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117f <lxqt_backlight_backend_get+0x3f>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
lea    0xe92(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    119a <lxqt_backlight_backend_get+0x5a>
mov    -0x10(%rbp),%rdi
call   1060 <read_backlight@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lxqt_backlight_backend_get>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <lxqt_backlight_backend_get_driver@plt>
test   %rax,%rax
je     1168 <lxqt_backlight_backend_get+0x28>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <read_backlight@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
jmp    1182 <lxqt_backlight_backend_get+0x42>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"Error: /sys/class/backlight is empty.\00"
define i32 @lxqt_backlight_backend_get() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = call i8* (...) @lxqt_backlight_backend_get_driver()
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %16
10: ; preds = %0
%11 = load i8*, i8** %2
%12 = call i32 @read_backlight(i8* %11)
store i32 %12, i32* %3
%13 = load i8*, i8** %2
%14 = call i32 @free(i8* %13)
%15 = load i32, i32* %3
store i32 %15, i32* %1
br label %16
16: ; preds = %10, %7
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"Error: /sys/class/backlight is empty.\00"
define i32 @lxqt_backlight_backend_get() {
%1 = tail call i8* (...) @lxqt_backlight_backend_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 %9
6: ; preds = %0
%7 = tail call i32 @read_backlight(i8* %1)
%8 = tail call i32 @free(i8* %1)
br label %9
9: ; preds = %6, %3
%10 = phi i32 [ -1, %3 ], [ %7, %6 ]
ret i32 %10
}