#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__ Colormap;

/* Variables and functions */
int /*<<< orphan*/ allocColour(scalar_t__, int, int, int);
int /*<<< orphan*/ init_x();
scalar_t__ initialColourMap();
int /*<<< orphan*/ listColourMaps();
int /*<<< orphan*/ listVisuals();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ queryColours(scalar_t__, int);
void main() {
  Colormap cm;
  init_x();
  listVisuals();
  cm = initialColourMap();
  listColourMaps();
  printf("Colour Map : %x\n", (int)cm);
  allocColour(cm, 255 * 0xFF, 0, 0);
  allocColour(cm, 0, 255 * 0xFF, 0);
  allocColour(cm, 0, 0, 255 * 0xFF);
  queryColours(cm, 2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <init_x@plt>
mov    $0x0,%al
call   1090 <listVisuals@plt>
mov    $0x0,%al
call   1060 <initialColourMap@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <listColourMaps@plt>
mov    -0x8(%rbp),%rax
mov    %eax,%esi
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0xfe01,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1080 <allocColour@plt>
mov    -0x8(%rbp),%rdi
xor    %ecx,%ecx
mov    $0xfe01,%edx
mov    %ecx,%esi
call   1080 <allocColour@plt>
mov    -0x8(%rbp),%rdi
xor    %edx,%edx
mov    $0xfe01,%ecx
mov    %edx,%esi
call   1080 <allocColour@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   1070 <queryColours@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <init_x@plt>
xor    %eax,%eax
call   1090 <listVisuals@plt>
xor    %eax,%eax
call   1060 <initialColourMap@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <listColourMaps@plt>
lea    0xe69(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xfe01,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1080 <allocColour@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xfe01,%edx
xor    %ecx,%ecx
call   1080 <allocColour@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    $0xfe01,%ecx
call   1080 <allocColour@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
pop    %rbx
jmp    1070 <queryColours@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"Colour Map : %x\0A\00"
define void @main() {
%1 = alloca i64
%2 = call i32 (...) @init_x()
%3 = call i32 (...) @listVisuals()
%4 = call i64 (...) @initialColourMap()
store i64 %4, i64* %1
%5 = call i32 (...) @listColourMaps()
%6 = load i64, i64* %1
%7 = trunc i64 %6 to i32
%8 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i64, i64* %1
%10 = call i32 @allocColour(i64 %9, i32 65025, i32 0, i32 0)
%11 = load i64, i64* %1
%12 = call i32 @allocColour(i64 %11, i32 0, i32 65025, i32 0)
%13 = load i64, i64* %1
%14 = call i32 @allocColour(i64 %13, i32 0, i32 0, i32 65025)
%15 = load i64, i64* %1
%16 = call i32 @queryColours(i64 %15, i32 2)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"Colour Map : %x\0A\00"
define void @main() {
%1 = tail call i32 (...) @init_x()
%2 = tail call i32 (...) @listVisuals()
%3 = tail call i64 (...) @initialColourMap()
%4 = tail call i32 (...) @listColourMaps()
%5 = trunc i64 %3 to i32
%6 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @allocColour(i64 %3, i32 65025, i32 0, i32 0)
%8 = tail call i32 @allocColour(i64 %3, i32 0, i32 65025, i32 0)
%9 = tail call i32 @allocColour(i64 %3, i32 0, i32 0, i32 65025)
%10 = tail call i32 @queryColours(i64 %3, i32 2)
ret void
}