#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*/ FBIOBLANK;
int /*<<< orphan*/ FB_BLANK_POWERDOWN;
int /*<<< orphan*/ FB_BLANK_UNBLANK;
int /*<<< orphan*/ O_RDWR;
int ioctl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int om_screen_power_set(int val) {
  int fd, ret;
  fd = open("/dev/fb0", O_RDWR);
  if (fd < 0)
    return -1;
  ret = ioctl(fd, FBIOBLANK, val ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN);
  if (ret != 0)
    return -2;
  return 0;
}


x86 assembly (clang, -O0):
<om_screen_power_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2eb6(%rip),%rax
mov    (%rax),%esi
lea    0xec5(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1159 <om_screen_power_set+0x39>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c0 <om_screen_power_set+0xa0>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1186 <om_screen_power_set+0x66>
mov    0x2e64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    1192 <om_screen_power_set+0x72>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%edx
call   1030 <ioctl@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11b9 <om_screen_power_set+0x99>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11c0 <om_screen_power_set+0xa0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<om_screen_power_set>:
push   %rbx
mov    %edi,%ebx
mov    0x2ebe(%rip),%rax
mov    (%rax),%esi
lea    0xecd(%rip),%rdi
call   1040 <open@plt>
test   %eax,%eax
js     1152 <om_screen_power_set+0x32>
mov    0x2e85(%rip),%rcx
mov    (%rcx),%esi
test   %ebx,%ebx
jne    1159 <om_screen_power_set+0x39>
mov    0x2e88(%rip),%rcx
jmp    1160 <om_screen_power_set+0x40>
mov    $0xffffffff,%eax
pop    %rbx
ret
mov    0x2e80(%rip),%rcx
mov    (%rcx),%edx
mov    %eax,%edi
call   1030 <ioctl@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
lea    (%rcx,%rcx,1),%eax
add    $0xfffffffe,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@FBIOBLANK = global i32 0
@FB_BLANK_UNBLANK = global i32 0
@FB_BLANK_POWERDOWN = global i32 0
define i32 @om_screen_power_set(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* @O_RDWR
%7 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 -1, i32* %2
br label %27
11: ; preds = %1
%12 = load i32, i32* %4
%13 = load i32, i32* @FBIOBLANK
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = load i32, i32* @FB_BLANK_UNBLANK
br label %20
18: ; preds = %11
%19 = load i32, i32* @FB_BLANK_POWERDOWN
br label %20
20: ; preds = %18, %16
%21 = phi i32 [ %17, %16 ], [ %19, %18 ]
%22 = call i32 @ioctl(i32 %12, i32 %13, i32 %21)
store i32 %22, i32* %5
%23 = load i32, i32* %5
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 -2, i32* %2
br label %27
26: ; preds = %20
store i32 0, i32* %2
br label %27
27: ; preds = %26, %25, %10
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@FBIOBLANK = global i32 0
@FB_BLANK_UNBLANK = global i32 0
@FB_BLANK_POWERDOWN = global i32 0
define i32 @om_screen_power_set(i32 %0) {
%2 = load i32, i32* @O_RDWR
%3 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp slt i32 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = load i32, i32* @FBIOBLANK
%7 = icmp eq i32 %0, 0
%8 = load i32, i32* @FB_BLANK_UNBLANK
%9 = load i32, i32* @FB_BLANK_POWERDOWN
%10 = select i1 %7, i32 %9, i32 %8
%11 = tail call i32 @ioctl(i32 %3, i32 %6, i32 %10)
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 0, i32 -2
br label %14
14: ; preds = %5, %1
%15 = phi i32 [ -1, %1 ], [ %13, %5 ]
ret i32 %15
}