#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 scalar_t__ uint8_t;
typedef int uint32_t;
typedef scalar_t__ uint16_t;

/* Variables and functions */
int Get_RGB_LED_Max_Value();
int /*<<< orphan*/ Get_RGB_LED_Values(scalar_t__ *);
void LED_RGB_Get(uint8_t *rgb) {
  int i = 0;
  uint16_t values[3];
  Get_RGB_LED_Values(values);
  for (i = 0; i < 3; i++) {
    rgb[i] =
        (uint8_t)(((uint32_t)(values[i]) << 8) / (Get_RGB_LED_Max_Value()));
  }
}


x86 assembly (clang, -O0):
<LED_RGB_Get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <Get_RGB_LED_Values@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    1188 <LED_RGB_Get+0x68>
movslq -0xc(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rax
shl    $0x8,%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1030 <Get_RGB_LED_Max_Value@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cltd
idiv   %ecx
movslq %eax,%rdx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <LED_RGB_Get+0x23>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LED_RGB_Get>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
call   1040 <Get_RGB_LED_Values@plt>
mov    (%rsp),%ebp
shl    $0x8,%ebp
xor    %eax,%eax
call   1030 <Get_RGB_LED_Max_Value@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
cltq
mov    %rax,(%rbx)
mov    0x8(%rsp),%ebp
shl    $0x8,%ebp
xor    %eax,%eax
call   1030 <Get_RGB_LED_Max_Value@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
cltq
mov    %rax,0x8(%rbx)
mov    0x10(%rsp),%ebp
shl    $0x8,%ebp
xor    %eax,%eax
call   1030 <Get_RGB_LED_Max_Value@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
cltq
mov    %rax,0x10(%rbx)
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @LED_RGB_Get(i64* %0) {
%2 = alloca i64*
%3 = alloca i32
%4 = alloca [3 x i64]
store i64* %0, i64** %2
store i32 0, i32* %3
%5 = getelementptr inbounds [3 x i64], [3 x i64]* %4, i64 0, i64 0
%6 = call i32 @Get_RGB_LED_Values(i64* %5)
store i32 0, i32* %3
br label %7
7: ; preds = %24, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %27
10: ; preds = %7
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [3 x i64], [3 x i64]* %4, i64 0, i64 %12
%14 = load i64, i64* %13
%15 = trunc i64 %14 to i32
%16 = shl i32 %15, 8
%17 = call i32 (...) @Get_RGB_LED_Max_Value()
%18 = sdiv i32 %16, %17
%19 = sext i32 %18 to i64
%20 = load i64*, i64** %2
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i64, i64* %20, i64 %22
store i64 %19, i64* %23
br label %24
24: ; preds = %10
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %7
27: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @LED_RGB_Get(i64* nocapture writeonly %0) {
%2 = alloca [3 x i64]
%3 = bitcast [3 x i64]* %2 to i8*
%4 = getelementptr inbounds [3 x i64], [3 x i64]* %2, i64 0, i64 0
%5 = call i32 @Get_RGB_LED_Values(i64* %4)
%6 = load i64, i64* %4
%7 = trunc i64 %6 to i32
%8 = shl i32 %7, 8
%9 = call i32 (...) @Get_RGB_LED_Max_Value()
%10 = sdiv i32 %8, %9
%11 = sext i32 %10 to i64
store i64 %11, i64* %0
%12 = getelementptr inbounds [3 x i64], [3 x i64]* %2, i64 0, i64 1
%13 = load i64, i64* %12
%14 = trunc i64 %13 to i32
%15 = shl i32 %14, 8
%16 = call i32 (...) @Get_RGB_LED_Max_Value()
%17 = sdiv i32 %15, %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i64, i64* %0, i64 1
store i64 %18, i64* %19
%20 = getelementptr inbounds [3 x i64], [3 x i64]* %2, i64 0, i64 2
%21 = load i64, i64* %20
%22 = trunc i64 %21 to i32
%23 = shl i32 %22, 8
%24 = call i32 (...) @Get_RGB_LED_Max_Value()
%25 = sdiv i32 %23, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i64, i64* %0, i64 2
store i64 %26, i64* %27
ret void
}