#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 /*<<< orphan*/ printf(char *, char *, int, int);
int read_backlight(char *);
int read_max_backlight(char *);
int /*<<< orphan*/ stderr;
void show_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);
  printf("%s %d %d\n", driver, max_value, actual);
  free(driver);
}


x86 assembly (clang, -O0):
<show_blacklight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <get_driver@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1198 <show_blacklight+0x38>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11cf <show_blacklight+0x6f>
mov    -0x8(%rbp),%rdi
call   1080 <read_max_backlight@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <read_backlight@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_blacklight>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <get_driver@plt>
test   %rax,%rax
je     11a5 <show_blacklight+0x45>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <read_max_backlight@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <read_backlight@plt>
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <free@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"Error: /sys/class/backlight is empty.\00"
@.str.1 = [10 x i8] c"%s %d %d\0A\00"
define void @show_blacklight() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = call i8* (...) @get_driver()
store i8* %4, i8** %1
%5 = load i8*, i8** %1
%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))
br label %21
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 i8*, i8** %1
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 %16, i32 %17)
%19 = load i8*, i8** %1
%20 = call i32 @free(i8* %19)
br label %21
21: ; preds = %10, %7
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"Error: /sys/class/backlight is empty.\00"
@.str.1 = [10 x i8] c"%s %d %d\0A\00"
define void @show_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 %11
6: ; preds = %0
%7 = tail call i32 @read_max_backlight(i8* %1)
%8 = tail call i32 @read_backlight(i8* %1)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %7, i32 %8)
%10 = tail call i32 @free(i8* %1)
br label %11
11: ; preds = %6, %3
ret void
}