#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 get_graphics_color_address(int, int, int, unsigned int **);
int vis5d_get_color(int index, int type, int number, float *red, float *green,
                    float *blue, float *alpha) {
  unsigned int *ptr;
  int n;
  n = get_graphics_color_address(index, type, number, &ptr);
  if (n) {
    return n;
  }
  *red = ((*ptr) & 0xff) / 255.0;
  *green = (((*ptr) >> 8) & 0xff) / 255.0;
  *blue = (((*ptr) >> 16) & 0xff) / 255.0;
  *alpha = (((*ptr) >> 24) & 0xff) / 255.0;
  return 0;
}


x86 assembly (clang, -O0):
<vis5d_get_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    -0x30(%rbp),%rcx
call   1030 <get_graphics_color_address@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     115b <vis5d_get_color+0x4b>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11e1 <vis5d_get_color+0xd1>
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe92(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movzbl 0x1(%rax),%eax
cvtsi2sd %eax,%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movzbl 0x2(%rax),%eax
cvtsi2sd %eax,%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movzbl 0x3(%rax),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe36(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    0x10(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vis5d_get_color>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%rbx
lea    0x8(%rsp),%rcx
call   1030 <get_graphics_color_address@plt>
test   %eax,%eax
jne    11a0 <vis5d_get_color+0x90>
mov    0x8(%rsp),%rcx
mov    (%rcx),%ecx
movzbl %cl,%edx
cvtsi2sd %edx,%xmm0
movsd  0xeba(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx)
movzbl %ch,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r15)
mov    %ecx,%edx
shr    $0x10,%edx
movzbl %dl,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
mov    0x30(%rsp),%rdx
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14)
shr    $0x18,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rdx)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @vis5d_get_color(i32 %0, i32 %1, i32 %2, float* %3, float* %4, float* %5, float* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca float*
%13 = alloca float*
%14 = alloca float*
%15 = alloca float*
%16 = alloca i32*
%17 = alloca i32
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store float* %3, float** %12
store float* %4, float** %13
store float* %5, float** %14
store float* %6, float** %15
%18 = load i32, i32* %9
%19 = load i32, i32* %10
%20 = load i32, i32* %11
%21 = call i32 @get_graphics_color_address(i32 %18, i32 %19, i32 %20, i32** %16)
store i32 %21, i32* %17
%22 = load i32, i32* %17
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %7
%25 = load i32, i32* %17
store i32 %25, i32* %8
br label %58
26: ; preds = %7
%27 = load i32*, i32** %16
%28 = load i32, i32* %27
%29 = and i32 %28, 255
%30 = uitofp i32 %29 to double
%31 = fdiv double %30, 2.550000e+02
%32 = fptrunc double %31 to float
%33 = load float*, float** %12
store float %32, float* %33
%34 = load i32*, i32** %16
%35 = load i32, i32* %34
%36 = lshr i32 %35, 8
%37 = and i32 %36, 255
%38 = uitofp i32 %37 to double
%39 = fdiv double %38, 2.550000e+02
%40 = fptrunc double %39 to float
%41 = load float*, float** %13
store float %40, float* %41
%42 = load i32*, i32** %16
%43 = load i32, i32* %42
%44 = lshr i32 %43, 16
%45 = and i32 %44, 255
%46 = uitofp i32 %45 to double
%47 = fdiv double %46, 2.550000e+02
%48 = fptrunc double %47 to float
%49 = load float*, float** %14
store float %48, float* %49
%50 = load i32*, i32** %16
%51 = load i32, i32* %50
%52 = lshr i32 %51, 24
%53 = and i32 %52, 255
%54 = uitofp i32 %53 to double
%55 = fdiv double %54, 2.550000e+02
%56 = fptrunc double %55 to float
%57 = load float*, float** %15
store float %56, float* %57
store i32 0, i32* %8
br label %58
58: ; preds = %26, %24
%59 = load i32, i32* %8
ret i32 %59
}

LLVM IR (-O2):
define i32 @vis5d_get_color(i32 %0, i32 %1, i32 %2, float* nocapture writeonly %3, float* nocapture writeonly %4, float* nocapture writeonly %5, float* nocapture writeonly %6) {
%8 = alloca i32*
%9 = bitcast i32** %8 to i8*
%10 = call i32 @get_graphics_color_address(i32 %0, i32 %1, i32 %2, i32** %8)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %33
12: ; preds = %7
%13 = load i32*, i32** %8
%14 = load i32, i32* %13
%15 = and i32 %14, 255
%16 = uitofp i32 %15 to double
%17 = fdiv double %16, 2.550000e+02
%18 = fptrunc double %17 to float
store float %18, float* %3
%19 = lshr i32 %14, 8
%20 = and i32 %19, 255
%21 = uitofp i32 %20 to double
%22 = fdiv double %21, 2.550000e+02
%23 = fptrunc double %22 to float
store float %23, float* %4
%24 = lshr i32 %14, 16
%25 = and i32 %24, 255
%26 = uitofp i32 %25 to double
%27 = fdiv double %26, 2.550000e+02
%28 = fptrunc double %27 to float
store float %28, float* %5
%29 = lshr i32 %14, 24
%30 = uitofp i32 %29 to double
%31 = fdiv double %30, 2.550000e+02
%32 = fptrunc double %31 to float
store float %32, float* %6
br label %33
33: ; preds = %7, %12
ret i32 %10
}