#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*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int disable_timer(void) {
  FILE *f = fopen("/sys/class/leds/"
                  "power"
                  "/trigger",
                  "w");
  if (!f)
    return -1;
  fwrite("none", sizeof "none", 1, f);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<disable_timer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0xed8(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1166 <disable_timer+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    1190 <disable_timer+0x60>
mov    -0x10(%rbp),%rcx
lea    0xeaf(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disable_timer>:
push   %rbx
lea    0xec8(%rip),%rdi
lea    0xedf(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     1171 <disable_timer+0x41>
mov    %rax,%rbx
lea    0xecd(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1050 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"/sys/class/leds/power/trigger\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"none\00"
define i32 @disable_timer() {
%1 = alloca i32
%2 = alloca i32*
%3 = call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %2
%4 = load i32*, i32** %2
%5 = icmp ne i32* %4, null
br i1 %5, label %7, label %6
6: ; preds = %0
store i32 -1, i32* %1
br label %12
7: ; preds = %0
%8 = load i32*, i32** %2
%9 = call i32 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 5, i32 1, i32* %8)
%10 = load i32*, i32** %2
%11 = call i32 @fclose(i32* %10)
store i32 0, i32* %1
br label %12
12: ; preds = %7, %6
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@.str = [30 x i8] c"/sys/class/leds/power/trigger\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"none\00"
define i32 @disable_timer() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = tail call i32 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 5, i32 1, i32* %1)
%5 = tail call i32 @fclose(i32* %1)
br label %6
6: ; preds = %0, %3
%7 = phi i32 [ 0, %3 ], [ -1, %0 ]
ret i32 %7
}