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


x86 assembly (clang, -O0):
<backlight_led_rgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%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)
mov    -0x10(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
lea    -0x1a(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xe7f(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x2c(%rbp),%edi
lea    -0x1a(%rbp),%rsi
call   1030 <sn3218_lcd_set@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<backlight_led_rgb>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%eax
mov    %edx,%ecx
mov    %esi,%r8d
movslq %edi,%rbx
imul   $0x2aaaaaab,%rbx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
shr    $0x20,%rdx
add    %esi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,2),%edx
sub    %edx,%ebx
lea    0xff(%r8),%edx
test   %r8d,%r8d
cmovns %r8d,%edx
and    $0xffffff00,%edx
sub    %edx,%r8d
lea    0xff(%rcx),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
and    $0xffffff00,%edx
sub    %edx,%ecx
lea    0xff(%rax),%edx
test   %eax,%eax
cmovns %eax,%edx
and    $0xffffff00,%edx
sub    %edx,%eax
lea    0xe70(%rip),%rsi
lea    0xe(%rsp),%r14
mov    %r14,%rdi
mov    %eax,%edx
call   1040 <sprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <sn3218_lcd_set@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

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