#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 */
scalar_t__ exists(char *);
const char *scan_max_brightness() {
  if (exists("/sys/class/backlight/gta02-bl/max_brightness"))
    return "/sys/class/backlight/gta02-bl/max_brightness";
  if (exists("/sys/devices/virtual/backlight/acpi_video0/max_brightness"))
    return "/sys/devices/virtual/backlight/acpi_video0/max_brightness";
  return NULL;
}


x86 assembly (clang, -O0):
<scan_max_brightness>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
call   1030 <exists@plt>
cmp    $0x0,%rax
je     113e <scan_max_brightness+0x2e>
lea    0xecb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    116c <scan_max_brightness+0x5c>
lea    0xee8(%rip),%rdi
call   1030 <exists@plt>
cmp    $0x0,%rax
je     1164 <scan_max_brightness+0x54>
lea    0xed2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    116c <scan_max_brightness+0x5c>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_max_brightness>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
call   1030 <exists@plt>
test   %rax,%rax
jne    113b <scan_max_brightness+0x2b>
lea    0xf01(%rip),%rbx
mov    %rbx,%rdi
call   1030 <exists@plt>
test   %rax,%rax
cmove  %rax,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [45 x i8] c"/sys/class/backlight/gta02-bl/max_brightness\00"
@.str.1 = [58 x i8] c"/sys/devices/virtual/backlight/acpi_video0/max_brightness\00"
define i8* @scan_max_brightness() {
%1 = alloca i8*
%2 = call i64 @exists(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %5
4: ; preds = %0
store i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8** %1
br label %10
5: ; preds = %0
%6 = call i64 @exists(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %5
store i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %10
9: ; preds = %5
store i8* null, i8** %1
br label %10
10: ; preds = %9, %8, %4
%11 = load i8*, i8** %1
ret i8* %11
}

LLVM IR (-O2):
@.str = [45 x i8] c"/sys/class/backlight/gta02-bl/max_brightness\00"
@.str.1 = [58 x i8] c"/sys/devices/virtual/backlight/acpi_video0/max_brightness\00"
define i8* @scan_max_brightness() {
%1 = tail call i64 @exists(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = tail call i64 @exists(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i8* null, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0)
br label %7
7: ; preds = %3, %0
%8 = phi i8* [ getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), %0 ], [ %6, %3 ]
ret i8* %8
}