#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 acpi_set_lcd_brightness(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ hardware_set_lcd_brightness(int);
int /*<<< orphan*/ stderr;
void toshiba_set_lcd_brightness(int brightness, int use_hardware_call) {
  static int acpi_ok = 1;
  if (!use_hardware_call) {
    acpi_set_lcd_brightness(brightness);
    return;
  }
  if (!acpi_ok) {
    hardware_set_lcd_brightness(brightness);
    return;
  }
  acpi_ok = acpi_set_lcd_brightness(brightness);
  if (!acpi_ok) {
    fprintf(stderr, "Trying to control directly Toshiba lcd hardware\n");
    hardware_set_lcd_brightness(brightness);
  }
}


x86 assembly (clang, -O0):
<toshiba_set_lcd_brightness>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1155 <toshiba_set_lcd_brightness+0x25>
mov    -0x4(%rbp),%edi
call   1050 <acpi_set_lcd_brightness@plt>
jmp    11a7 <toshiba_set_lcd_brightness+0x77>
cmpl   $0x0,0x2edc(%rip)
jne    116f <toshiba_set_lcd_brightness+0x3f>
mov    -0x4(%rbp),%edi
call   1030 <hardware_set_lcd_brightness@plt>
jmp    11a7 <toshiba_set_lcd_brightness+0x77>
mov    -0x4(%rbp),%edi
call   1050 <acpi_set_lcd_brightness@plt>
mov    %eax,0x2ebb(%rip)
cmpl   $0x0,0x2eb4(%rip)
jne    11a7 <toshiba_set_lcd_brightness+0x77>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xe66(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%edi
call   1030 <hardware_set_lcd_brightness@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<toshiba_set_lcd_brightness>:
push   %rbx
mov    %edi,%ebx
test   %esi,%esi
je     1153 <toshiba_set_lcd_brightness+0x23>
cmpl   $0x0,0x2efa(%rip)
je     1170 <toshiba_set_lcd_brightness+0x40>
mov    %ebx,%edi
call   1050 <acpi_set_lcd_brightness@plt>
mov    %eax,0x2eeb(%rip)
test   %eax,%eax
je     115b <toshiba_set_lcd_brightness+0x2b>
pop    %rbx
ret
mov    %ebx,%edi
pop    %rbx
jmp    1050 <acpi_set_lcd_brightness@plt>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
call   1040 <fprintf@plt>
mov    %ebx,%edi
pop    %rbx
jmp    1030 <hardware_set_lcd_brightness@plt>

LLVM IR (-O0):
@toshiba_set_lcd_brightness.acpi_ok = internal global i32 1
@stderr = global i32 0
@.str = [49 x i8] c"Trying to control directly Toshiba lcd hardware\0A\00"
define void @toshiba_set_lcd_brightness(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp ne i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32, i32* %3
%9 = call i32 @acpi_set_lcd_brightness(i32 %8)
br label %26
10: ; preds = %2
%11 = load i32, i32* @toshiba_set_lcd_brightness.acpi_ok
%12 = icmp ne i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %3
%15 = call i32 @hardware_set_lcd_brightness(i32 %14)
br label %26
16: ; preds = %10
%17 = load i32, i32* %3
%18 = call i32 @acpi_set_lcd_brightness(i32 %17)
store i32 %18, i32* @toshiba_set_lcd_brightness.acpi_ok
%19 = load i32, i32* @toshiba_set_lcd_brightness.acpi_ok
%20 = icmp ne i32 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* %3
%25 = call i32 @hardware_set_lcd_brightness(i32 %24)
br label %26
26: ; preds = %7, %13, %21, %16
ret void
}

LLVM IR (-O2):
@toshiba_set_lcd_brightness.acpi_ok = internal unnamed_addr global i32 1
@stderr = global i32 0
@.str = [49 x i8] c"Trying to control directly Toshiba lcd hardware\0A\00"
define void @toshiba_set_lcd_brightness(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @acpi_set_lcd_brightness(i32 %0)
br label %18
6: ; preds = %2
%7 = load i32, i32* @toshiba_set_lcd_brightness.acpi_ok
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @hardware_set_lcd_brightness(i32 %0)
br label %18
11: ; preds = %6
%12 = tail call i32 @acpi_set_lcd_brightness(i32 %0)
store i32 %12, i32* @toshiba_set_lcd_brightness.acpi_ok
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @hardware_set_lcd_brightness(i32 %0)
br label %18
18: ; preds = %4, %9, %14, %11
ret void
}