#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 int uint8_t;

/* Variables and functions */
void render_pixel(int i, uint8_t pixel[3]) {
  static uint8_t palet[][3] = {
      {0, 0, 0},    {1, 2, 1},    {2, 4, 2},    {3, 6, 3},    {4, 8, 4},
      {5, 10, 5},   {6, 12, 6},   {7, 14, 7},   {8, 15, 8},   {9, 15, 9},
      {10, 15, 10}, {11, 15, 11}, {12, 15, 12}, {13, 15, 13}, {14, 15, 14},
      {15, 15, 15}, {15, 15, 15}};
  pixel[0] = 16 * palet[i][0];
  pixel[1] = 16 * palet[i][1];
  pixel[2] = 16 * palet[i][2];
}


x86 assembly (clang, -O0):
<render_pixel>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movslq -0x4(%rbp),%rcx
lea    0x2f1a(%rip),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%ecx
shl    $0x4,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movslq -0x4(%rbp),%rcx
lea    0x2efd(%rip),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x4(%rax),%ecx
shl    $0x4,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
movslq -0x4(%rbp),%rcx
lea    0x2ede(%rip),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%ecx
shl    $0x4,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<render_pixel>:
movslq %edi,%rax
lea    (%rax,%rax,2),%rax
lea    0xef2(%rip),%rcx
mov    (%rcx,%rax,4),%edx
mov    0x4(%rcx,%rax,4),%edi
shl    $0x4,%edx
mov    %edx,(%rsi)
shl    $0x4,%edi
mov    %edi,0x4(%rsi)
mov    0x8(%rcx,%rax,4),%eax
shl    $0x4,%eax
mov    %eax,0x8(%rsi)
ret

LLVM IR (-O0):
@render_pixel.palet = internal global [17 x [3 x i32]] [[3 x i32] zeroinitializer, [3 x i32] [i32 1, i32 2, i32 1], [3 x i32] [i32 2, i32 4, i32 2], [3 x i32] [i32 3, i32 6, i32 3], [3 x i32] [i32 4, i32 8, i32 4], [3 x i32] [i32 5, i32 10, i32 5], [3 x i32] [i32 6, i32 12, i32 6], [3 x i32] [i32 7, i32 14, i32 7], [3 x i32] [i32 8, i32 15, i32 8], [3 x i32] [i32 9, i32 15, i32 9], [3 x i32] [i32 10, i32 15, i32 10], [3 x i32] [i32 11, i32 15, i32 11], [3 x i32] [i32 12, i32 15, i32 12], [3 x i32] [i32 13, i32 15, i32 13], [3 x i32] [i32 14, i32 15, i32 14], [3 x i32] [i32 15, i32 15, i32 15], [3 x i32] [i32 15, i32 15, i32 15]]
define void @render_pixel(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
store i32 %0, i32* %3
store i32* %1, i32** %4
%5 = load i32, i32* %3
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [17 x [3 x i32]], [17 x [3 x i32]]* @render_pixel.palet, i64 0, i64 %6
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%9 = load i32, i32* %8
%10 = mul nsw i32 16, %9
%11 = load i32*, i32** %4
%12 = getelementptr inbounds i32, i32* %11, i64 0
store i32 %10, i32* %12
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [17 x [3 x i32]], [17 x [3 x i32]]* @render_pixel.palet, i64 0, i64 %14
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %15, i64 0, i64 1
%17 = load i32, i32* %16
%18 = mul nsw i32 16, %17
%19 = load i32*, i32** %4
%20 = getelementptr inbounds i32, i32* %19, i64 1
store i32 %18, i32* %20
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [17 x [3 x i32]], [17 x [3 x i32]]* @render_pixel.palet, i64 0, i64 %22
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %23, i64 0, i64 2
%25 = load i32, i32* %24
%26 = mul nsw i32 16, %25
%27 = load i32*, i32** %4
%28 = getelementptr inbounds i32, i32* %27, i64 2
store i32 %26, i32* %28
ret void
}

LLVM IR (-O2):
@render_pixel.palet = internal unnamed_addr constant [17 x [3 x i32]] [[3 x i32] zeroinitializer, [3 x i32] [i32 1, i32 2, i32 1], [3 x i32] [i32 2, i32 4, i32 2], [3 x i32] [i32 3, i32 6, i32 3], [3 x i32] [i32 4, i32 8, i32 4], [3 x i32] [i32 5, i32 10, i32 5], [3 x i32] [i32 6, i32 12, i32 6], [3 x i32] [i32 7, i32 14, i32 7], [3 x i32] [i32 8, i32 15, i32 8], [3 x i32] [i32 9, i32 15, i32 9], [3 x i32] [i32 10, i32 15, i32 10], [3 x i32] [i32 11, i32 15, i32 11], [3 x i32] [i32 12, i32 15, i32 12], [3 x i32] [i32 13, i32 15, i32 13], [3 x i32] [i32 14, i32 15, i32 14], [3 x i32] [i32 15, i32 15, i32 15], [3 x i32] [i32 15, i32 15, i32 15]]
define void @render_pixel(i32 %0, i32* nocapture writeonly %1) {
%3 = sext i32 %0 to i64
%4 = getelementptr inbounds [17 x [3 x i32]], [17 x [3 x i32]]* @render_pixel.palet, i64 0, i64 %3, i64 0
%5 = load i32, i32* %4
%6 = shl nsw i32 %5, 4
store i32 %6, i32* %1
%7 = getelementptr inbounds [17 x [3 x i32]], [17 x [3 x i32]]* @render_pixel.palet, i64 0, i64 %3, i64 1
%8 = load i32, i32* %7
%9 = shl nsw i32 %8, 4
%10 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %9, i32* %10
%11 = getelementptr inbounds [17 x [3 x i32]], [17 x [3 x i32]]* @render_pixel.palet, i64 0, i64 %3, i64 2
%12 = load i32, i32* %11
%13 = shl nsw i32 %12, 4
%14 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %13, i32* %14
ret void
}