#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
void set_power(int power_value) {
  if (power_value > 1)
    power_value = 0;
  if (power_value < 0)
    power_value = 1;
  FILE *power_file;
  power_file = fopen("/sys/class/backlight/rpi_backlight/bl_power", "w");
  fprintf(power_file, "%d", power_value);
  fclose(power_file);
}


x86 assembly (clang, -O0):
<set_power>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    114c <set_power+0x1c>
movl   $0x0,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    115d <set_power+0x2d>
movl   $0x1,-0x4(%rbp)
lea    0xe9c(%rip),%rdi
lea    0xec1(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xeac(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_power>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
cmp    $0x2,%edi
cmovl  %edi,%eax
test   %eax,%eax
mov    $0x1,%ebx
cmovns %eax,%ebx
lea    0xeb3(%rip),%rdi
lea    0xed8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
lea    0xecb(%rip),%rsi
mov    %rax,%rdi
mov    %ebx,%edx
call   1040 <fprintf@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"/sys/class/backlight/rpi_backlight/bl_power\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%d\00"
define void @set_power(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp sgt i32 %4, 1
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 0, i32* %2
br label %7
7: ; preds = %6, %1
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 1, i32* %2
br label %11
11: ; preds = %10, %7
%12 = call i32* @fopen(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %3
%13 = load i32*, i32** %3
%14 = load i32, i32* %2
%15 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = load i32*, i32** %3
%17 = call i32 @fclose(i32* %16)
ret void
}

LLVM IR (-O2):
@.str = [44 x i8] c"/sys/class/backlight/rpi_backlight/bl_power\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%d\00"
define void @set_power(i32 %0) {
%2 = icmp sgt i32 %0, 1
%3 = select i1 %2, i32 0, i32 %0
%4 = icmp slt i32 %3, 0
%5 = select i1 %4, i32 1, i32 %3
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%8 = tail call i32 @fclose(i32* %6)
ret void
}