#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 *lxqt_backlight_backend_get_driver();
int read_bl_power(char *);
int read_max_backlight(char *);
int lxqt_backlight_backend_get_max() {
  char *driver = lxqt_backlight_backend_get_driver();
  if (driver == NULL) {
    return -1;
  }
  int value = read_max_backlight(driver);
  int bl_power = read_bl_power(driver);
  free(driver);
  return bl_power == 0 ? value : -1;
}


x86 assembly (clang, -O0):
<lxqt_backlight_backend_get_max>:
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    116a <lxqt_backlight_backend_get_max+0x2a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b3 <lxqt_backlight_backend_get_max+0x73>
mov    -0x10(%rbp),%rdi
call   1060 <read_max_backlight@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <read_bl_power@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x18(%rbp)
jne    11a0 <lxqt_backlight_backend_get_max+0x60>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11ad <lxqt_backlight_backend_get_max+0x6d>
mov    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ad <lxqt_backlight_backend_get_max+0x6d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lxqt_backlight_backend_get_max>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <lxqt_backlight_backend_get_driver@plt>
test   %rax,%rax
je     1179 <lxqt_backlight_backend_get_max+0x39>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <read_max_backlight@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1040 <read_bl_power@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
neg    %ebp
sbb    %eax,%eax
or     %r14d,%eax
jmp    117e <lxqt_backlight_backend_get_max+0x3e>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @lxqt_backlight_backend_get_max() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = call i8* (...) @lxqt_backlight_backend_get_driver()
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 -1, i32* %1
br label %23
9: ; preds = %0
%10 = load i8*, i8** %2
%11 = call i32 @read_max_backlight(i8* %10)
store i32 %11, i32* %3
%12 = load i8*, i8** %2
%13 = call i32 @read_bl_power(i8* %12)
store i32 %13, i32* %4
%14 = load i8*, i8** %2
%15 = call i32 @free(i8* %14)
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %9
%19 = load i32, i32* %3
br label %21
20: ; preds = %9
br label %21
21: ; preds = %20, %18
%22 = phi i32 [ %19, %18 ], [ -1, %20 ]
store i32 %22, i32* %1
br label %23
23: ; preds = %21, %8
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
define i32 @lxqt_backlight_backend_get_max() {
%1 = tail call i8* (...) @lxqt_backlight_backend_get_driver()
%2 = icmp eq i8* %1, null
br i1 %2, label %9, label %3
3: ; preds = %0
%4 = tail call i32 @read_max_backlight(i8* %1)
%5 = tail call i32 @read_bl_power(i8* %1)
%6 = tail call i32 @free(i8* %1)
%7 = icmp eq i32 %5, 0
%8 = select i1 %7, i32 %4, i32 -1
br label %9
9: ; preds = %0, %3
%10 = phi i32 [ %8, %3 ], [ -1, %0 ]
ret i32 %10
}