#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 */
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ color;
struct TYPE_4__ {
  unsigned short red;
  unsigned short green;
  unsigned short blue;
  int flags;
  int /*<<< orphan*/ pixel;
};
typedef TYPE_1__ XColor;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ GC;
typedef int /*<<< orphan*/ Display;
typedef int /*<<< orphan*/ Colormap;

/* Variables and functions */
int DoBlue;
int DoGreen;
int DoRed;
int /*<<< orphan*/ XAllocColor(int /*<<< orphan*/ *, int /*<<< orphan*/ const,
                               TYPE_1__ *);
int /*<<< orphan*/ XCreateGC(int /*<<< orphan*/ *, int /*<<< orphan*/ const,
                             int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ XSetForeground(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  int /*<<< orphan*/);
int /*<<< orphan*/ memset(TYPE_1__ *, int /*<<< orphan*/, int);
void createGC(GC *gc, const Colormap *cmap, Display *dpy, const Window *win,
              unsigned char red, unsigned char green, unsigned char blue) {
  float coloratio = (float)65535 / 255;
  XColor color;
  *gc = XCreateGC(dpy, *win, 0, 0);
  memset(&color, 0, sizeof(color));
  color.red = (unsigned short)(coloratio * red);
  color.green = (unsigned short)(coloratio * green);
  color.blue = (unsigned short)(coloratio * blue);
  color.flags = DoRed | DoGreen | DoBlue;
  XAllocColor(dpy, *cmap, &color);
  XSetForeground(dpy, *gc, color.pixel);
}


x86 assembly (clang, -O0):
<createGC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %r8d,-0x5c(%rbp)
mov    %rcx,%rax
mov    -0x5c(%rbp),%ecx
mov    %rax,-0x58(%rbp)
mov    %rdx,%rax
mov    -0x58(%rbp),%rdx
mov    %rax,-0x50(%rbp)
mov    %rsi,%rax
mov    -0x50(%rbp),%rsi
mov    %rax,-0x48(%rbp)
mov    %rdi,%r8
mov    -0x48(%rbp),%rdi
mov    %r9b,%al
mov    0x10(%rbp),%r9b
mov    %r8,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %cl,-0x21(%rbp)
mov    %al,-0x22(%rbp)
movl   $0x43808000,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
xor    %ecx,%ecx
mov    %ecx,-0x3c(%rbp)
mov    %ecx,%edx
call   1050 <XCreateGC@plt>
mov    -0x3c(%rbp),%esi
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x38(%rbp),%rdi
mov    $0x10,%edx
call   1040 <memset@plt>
movss  -0x28(%rbp),%xmm0
movzbl -0x21(%rbp),%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %ax,-0x38(%rbp)
movss  -0x28(%rbp),%xmm0
movzbl -0x22(%rbp),%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %ax,-0x36(%rbp)
movss  -0x28(%rbp),%xmm0
movzbl 0x10(%rbp),%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %ax,-0x34(%rbp)
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
mov    0x2daf(%rip),%rcx
or     (%rcx),%eax
mov    0x2dae(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1030 <XAllocColor@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x2c(%rbp),%edx
call   1060 <XSetForeground@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createGC>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%ebp
mov    %r8d,%ebx
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%r14
movzbl 0x50(%rsp),%r12d
mov    (%rcx),%esi
mov    %rdx,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <XCreateGC@plt>
mov    %eax,(%r14)
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    %ebx,%eax
shl    $0x8,%eax
or     %ebx,%eax
mov    %ax,0x8(%rsp)
mov    %ebp,%eax
shl    $0x8,%eax
or     %ebp,%eax
mov    %ax,0xa(%rsp)
mov    %r12d,%eax
shl    $0x8,%eax
or     %r12d,%eax
mov    %ax,0xc(%rsp)
mov    0x2e36(%rip),%rax
mov    0x2e17(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e14(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x10(%rsp)
mov    (%r15),%esi
mov    %r13,%rdi
lea    0x8(%rsp),%rdx
call   1030 <XAllocColor@plt>
mov    (%r14),%esi
mov    0x14(%rsp),%edx
mov    %r13,%rdi
call   1060 <XSetForeground@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i16, i16, i16, i32, i32 }
@DoRed = global i32 0
@DoGreen = global i32 0
@DoBlue = global i32 0
define void @createGC(i32* %0, i32* %1, i32* %2, i32* %3, i8 zeroext %4, i8 zeroext %5, i8 zeroext %6) {
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8
%13 = alloca i8
%14 = alloca i8
%15 = alloca float
%16 = alloca %struct.TYPE_4__
store i32* %0, i32** %8
store i32* %1, i32** %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i8 %4, i8* %12
store i8 %5, i8* %13
store i8 %6, i8* %14
store float 2.570000e+02, float* %15
%17 = load i32*, i32** %10
%18 = load i32*, i32** %11
%19 = load i32, i32* %18
%20 = call i32 @XCreateGC(i32* %17, i32 %19, i32 0, i32 0)
%21 = load i32*, i32** %8
store i32 %20, i32* %21
%22 = call i32 @memset(%struct.TYPE_4__* %16, i32 0, i32 16)
%23 = load float, float* %15
%24 = load i8, i8* %12
%25 = zext i8 %24 to i32
%26 = sitofp i32 %25 to float
%27 = fmul float %23, %26
%28 = fptoui float %27 to i16
%29 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %16, i32 0, i32 0
store i16 %28, i16* %29
%30 = load float, float* %15
%31 = load i8, i8* %13
%32 = zext i8 %31 to i32
%33 = sitofp i32 %32 to float
%34 = fmul float %30, %33
%35 = fptoui float %34 to i16
%36 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %16, i32 0, i32 1
store i16 %35, i16* %36
%37 = load float, float* %15
%38 = load i8, i8* %14
%39 = zext i8 %38 to i32
%40 = sitofp i32 %39 to float
%41 = fmul float %37, %40
%42 = fptoui float %41 to i16
%43 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %16, i32 0, i32 2
store i16 %42, i16* %43
%44 = load i32, i32* @DoRed
%45 = load i32, i32* @DoGreen
%46 = or i32 %44, %45
%47 = load i32, i32* @DoBlue
%48 = or i32 %46, %47
%49 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %16, i32 0, i32 3
store i32 %48, i32* %49
%50 = load i32*, i32** %10
%51 = load i32*, i32** %9
%52 = load i32, i32* %51
%53 = call i32 @XAllocColor(i32* %50, i32 %52, %struct.TYPE_4__* %16)
%54 = load i32*, i32** %10
%55 = load i32*, i32** %8
%56 = load i32, i32* %55
%57 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %16, i32 0, i32 4
%58 = load i32, i32* %57
%59 = call i32 @XSetForeground(i32* %54, i32 %56, i32 %58)
ret void
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i16, i16, i16, i32, i32 }
@DoRed = global i32 0
@DoGreen = global i32 0
@DoBlue = global i32 0
define void @createGC(i32* nocapture %0, i32* nocapture %1, i32* %2, i32* nocapture %3, i8 zeroext %4, i8 zeroext %5, i8 zeroext %6) {
%8 = alloca %struct.TYPE_4__
%9 = bitcast %struct.TYPE_4__* %8 to i8*
%10 = load i32, i32* %3
%11 = tail call i32 @XCreateGC(i32* %2, i32 %10, i32 0, i32 0)
store i32 %11, i32* %0
%12 = call i32 @memset(%struct.TYPE_4__* %8, i32 0, i32 16)
%13 = zext i8 %4 to i16
%14 = mul nuw i16 %13, 257
%15 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %8, i64 0, i32 0
store i16 %14, i16* %15
%16 = zext i8 %5 to i16
%17 = mul nuw i16 %16, 257
%18 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %8, i64 0, i32 1
store i16 %17, i16* %18
%19 = zext i8 %6 to i16
%20 = mul nuw i16 %19, 257
%21 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %8, i64 0, i32 2
store i16 %20, i16* %21
%22 = load i32, i32* @DoRed
%23 = load i32, i32* @DoGreen
%24 = or i32 %23, %22
%25 = load i32, i32* @DoBlue
%26 = or i32 %24, %25
%27 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %8, i64 0, i32 3
store i32 %26, i32* %27
%28 = load i32, i32* %1
%29 = call i32 @XAllocColor(i32* %2, i32 %28, %struct.TYPE_4__* %8)
%30 = load i32, i32* %0
%31 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %8, i64 0, i32 4
%32 = load i32, i32* %31
%33 = call i32 @XSetForeground(i32* %2, i32 %30, i32 %32)
ret void
}