#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 /*<<< orphan*/ printf(char *);
void hw_display_off(void) {
  FILE *f;
  printf("hw_nanonote: Display off requested.\n");
  if ((f = fopen("/sys/class/lcd/gpm940b0-lcd/lcd_power", "w"))) {
    fprintf(f, "4\n");
    fclose(f);
  }
}


x86 assembly (clang, -O0):
<hw_display_off>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
lea    0xee9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     118e <hw_display_off+0x4e>
mov    -0x8(%rbp),%rdi
lea    0xecd(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hw_display_off>:
push   %rbx
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
lea    0xecb(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     118a <hw_display_off+0x4a>
mov    %rax,%rbx
lea    0xeb9(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <fclose@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"hw_nanonote: Display off requested.\0A\00"
@.str.1 = [38 x i8] c"/sys/class/lcd/gpm940b0-lcd/lcd_power\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"4\0A\00"
define void @hw_display_off() {
%1 = alloca i32*
%2 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%3 = call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %3, i32** %1
%4 = icmp ne i32* %3, null
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = load i32*, i32** %1
%7 = call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%8 = load i32*, i32** %1
%9 = call i32 @fclose(i32* %8)
br label %10
10: ; preds = %5, %0
ret void
}

LLVM IR (-O2):
@.str.1 = [38 x i8] c"/sys/class/lcd/gpm940b0-lcd/lcd_power\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"4\0A\00"
@str = [36 x i8] c"hw_nanonote: Display off requested.\00"
define void @hw_display_off() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %7, label %4
4: ; preds = %0
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 2, i64 1, i32* %2)
%6 = tail call i32 @fclose(i32* %2)
br label %7
7: ; preds = %4, %0
ret void
}