#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*/ sn3218_monocolor(char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
void backlight_rgb(int R, int G, int B) {
  char v[10];
  int red, green, blue;
  red = R % 256;
  green = G % 256;
  blue = B % 256;
  sprintf(v, "%02X%02X%02X", blue, green, red);
  sn3218_monocolor(v);
}


x86 assembly (clang, -O0):
<backlight_rgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
lea    -0x16(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe90(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x16(%rbp),%rdi
call   1030 <sn3218_monocolor@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<backlight_rgb>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ecx
mov    %edi,%r8d
lea    0xff(%r8),%eax
test   %edi,%edi
cmovns %edi,%eax
and    $0xffffff00,%eax
sub    %eax,%r8d
lea    0xff(%rcx),%eax
test   %esi,%esi
cmovns %esi,%eax
and    $0xffffff00,%eax
sub    %eax,%ecx
lea    0xff(%rdx),%eax
test   %edx,%edx
cmovns %edx,%eax
and    $0xffffff00,%eax
sub    %eax,%edx
lea    0xe97(%rip),%rsi
lea    0x6(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <sn3218_monocolor@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%02X%02X%02X\00"
define void @backlight_rgb(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [10 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %4
%12 = srem i32 %11, 256
store i32 %12, i32* %8
%13 = load i32, i32* %5
%14 = srem i32 %13, 256
store i32 %14, i32* %9
%15 = load i32, i32* %6
%16 = srem i32 %15, 256
store i32 %16, i32* %10
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%18 = load i32, i32* %10
%19 = load i32, i32* %9
%20 = load i32, i32* %8
%21 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19, i32 %20)
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%23 = call i32 @sn3218_monocolor(i8* %22)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"%02X%02X%02X\00"
define void @backlight_rgb(i32 %0, i32 %1, i32 %2) {
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%6 = srem i32 %0, 256
%7 = srem i32 %1, 256
%8 = srem i32 %2, 256
%9 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %7, i32 %6)
%10 = call i32 @sn3218_monocolor(i8* %5)
ret void
}