#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*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
void kobo_set_led_rgb(int red, int green, int blue) {
  int fd;
  fd = open("/sys/devices/platform/pmic_light.1/lit", O_WRONLY);
  if (fd) {
    write(fd, "ch 4\n", 5);
    write(fd, "cur 0\n", 6);
    write(fd, "dc 0\n", 5);
    close(fd);
  }
}


x86 assembly (clang, -O0):
<kobo_set_led_rgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
lea    0xeaf(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11a7 <kobo_set_led_rgb+0x77>
mov    -0x10(%rbp),%edi
lea    0xeba(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    -0x10(%rbp),%edi
lea    0xeac(%rip),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
mov    -0x10(%rbp),%edi
lea    0xe9f(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    -0x10(%rbp),%edi
call   1040 <close@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kobo_set_led_rgb>:
push   %rbx
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
lea    0xebf(%rip),%rdi
call   1050 <open@plt>
test   %eax,%eax
je     118d <kobo_set_led_rgb+0x5d>
mov    %eax,%ebx
lea    0xed4(%rip),%rsi
mov    %eax,%edi
mov    $0x5,%edx
call   1030 <write@plt>
lea    0xec7(%rip),%rsi
mov    %ebx,%edi
mov    $0x6,%edx
call   1030 <write@plt>
lea    0xebb(%rip),%rsi
mov    %ebx,%edi
mov    $0x5,%edx
call   1030 <write@plt>
mov    %ebx,%edi
pop    %rbx
jmp    1040 <close@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [39 x i8] c"/sys/devices/platform/pmic_light.1/lit\00"
@O_WRONLY = global i32 0
@.str.1 = [6 x i8] c"ch 4\0A\00"
@.str.2 = [7 x i8] c"cur 0\0A\00"
@.str.3 = [6 x i8] c"dc 0\0A\00"
define void @kobo_set_led_rgb(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* @O_WRONLY
%9 = call i32 @open(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %8)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %3
%13 = load i32, i32* %7
%14 = call i32 @write(i32 %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%15 = load i32, i32* %7
%16 = call i32 @write(i32 %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%17 = load i32, i32* %7
%18 = call i32 @write(i32 %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%19 = load i32, i32* %7
%20 = call i32 @close(i32 %19)
br label %21
21: ; preds = %12, %3
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"/sys/devices/platform/pmic_light.1/lit\00"
@O_WRONLY = global i32 0
@.str.1 = [6 x i8] c"ch 4\0A\00"
@.str.2 = [7 x i8] c"cur 0\0A\00"
@.str.3 = [6 x i8] c"dc 0\0A\00"
define void @kobo_set_led_rgb(i32 %0, i32 %1, i32 %2) {
%4 = load i32, i32* @O_WRONLY
%5 = tail call i32 @open(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = tail call i32 @write(i32 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%9 = tail call i32 @write(i32 %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%10 = tail call i32 @write(i32 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%11 = tail call i32 @close(i32 %5)
br label %12
12: ; preds = %7, %3
ret void
}