#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 */
int rgbs(double);
int round(int);
void create_table(uint8_t table[][3], uint8_t white[3]) {
  int i, j;
  for (i = 0; i < 256; i++) {
    double t = i / 255.0;
    for (j = 0; j < 3; j++) {
      table[i][j] = round(rgbs(t) * white[j]);
    }
  }
}


x86 assembly (clang, -O0):
<create_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    11c1 <create_table+0xa1>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xeaf(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    11ae <create_table+0x8e>
movsd  -0x20(%rbp),%xmm0
call   1030 <rgbs@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   (%rax,%rcx,4),%edi
call   1040 <round@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1161 <create_table+0x41>
jmp    11b3 <create_table+0x93>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <create_table+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_table>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0x8,%rbx
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
divsd  0xeb0(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <rgbs@plt>
imul   (%r14),%eax
mov    %eax,%edi
call   1040 <round@plt>
mov    %eax,-0x8(%rbx)
movsd  0x8(%rsp),%xmm0
call   1030 <rgbs@plt>
imul   0x4(%r14),%eax
mov    %eax,%edi
call   1040 <round@plt>
mov    %eax,-0x4(%rbx)
movsd  0x8(%rsp),%xmm0
call   1030 <rgbs@plt>
imul   0x8(%r14),%eax
mov    %eax,%edi
call   1040 <round@plt>
mov    %eax,(%rbx)
add    $0x1,%r15
add    $0xc,%rbx
cmp    $0x100,%r15
jne    1140 <create_table+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @create_table([3 x i32]* %0, i32* %1) {
%3 = alloca [3 x i32]*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store [3 x i32]* %0, [3 x i32]** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %8
8: ; preds = %39, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 256
br i1 %10, label %11, label %42
11: ; preds = %8
%12 = load i32, i32* %5
%13 = sitofp i32 %12 to double
%14 = fdiv double %13, 2.550000e+02
store double %14, double* %7
store i32 0, i32* %6
br label %15
15: ; preds = %35, %11
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %38
18: ; preds = %15
%19 = load double, double* %7
%20 = call i32 @rgbs(double %19)
%21 = load i32*, i32** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = mul nsw i32 %20, %25
%27 = call i32 @round(i32 %26)
%28 = load [3 x i32]*, [3 x i32]** %3
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [3 x i32], [3 x i32]* %28, i64 %30
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [3 x i32], [3 x i32]* %31, i64 0, i64 %33
store i32 %27, i32* %34
br label %35
35: ; preds = %18
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %15
38: ; preds = %15
br label %39
39: ; preds = %38
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %8
42: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @create_table([3 x i32]* nocapture writeonly %0, i32* nocapture %1) {
%3 = getelementptr inbounds i32, i32* %1, i64 1
%4 = getelementptr inbounds i32, i32* %1, i64 2
br label %5
5: ; preds = %2, %5
%6 = phi i64 [ 0, %2 ], [ %25, %5 ]
%7 = trunc i64 %6 to i32
%8 = sitofp i32 %7 to double
%9 = fdiv double %8, 2.550000e+02
%10 = tail call i32 @rgbs(double %9)
%11 = load i32, i32* %1
%12 = mul nsw i32 %11, %10
%13 = tail call i32 @round(i32 %12)
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 %6, i64 0
store i32 %13, i32* %14
%15 = tail call i32 @rgbs(double %9)
%16 = load i32, i32* %3
%17 = mul nsw i32 %16, %15
%18 = tail call i32 @round(i32 %17)
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 %6, i64 1
store i32 %18, i32* %19
%20 = tail call i32 @rgbs(double %9)
%21 = load i32, i32* %4
%22 = mul nsw i32 %21, %20
%23 = tail call i32 @round(i32 %22)
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 %6, i64 2
store i32 %23, i32* %24
%25 = add nuw nsw i64 %6, 1
%26 = icmp eq i64 %25, 256
br i1 %26, label %27, label %5
27: ; preds = %5
ret void
}