#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 pow(float, float);
void apply_gamma(unsigned char colortab[6144], float gamma) {
  int i;
  for (i = 0; i < 6144; i++)
    colortab[i] = (int)(pow((float)colortab[i] / 256., gamma) * 256);
}


x86 assembly (clang, -O0):
<apply_gamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x1800,-0x10(%rbp)
jge    1181 <apply_gamma+0x71>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeaf(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
call   1030 <pow@plt>
shl    $0x8,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1128 <apply_gamma+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apply_gamma>:
push   %r14
push   %rbx
push   %rax
movss  %xmm0,0x4(%rsp)
mov    %rdi,%r14
mov    $0x2,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl -0x2(%r14,%rbx,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xebb(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0x4(%rsp),%xmm1
call   1030 <pow@plt>
movb   $0x0,-0x2(%r14,%rbx,1)
movzbl -0x1(%r14,%rbx,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe8d(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0x4(%rsp),%xmm1
call   1030 <pow@plt>
movb   $0x0,-0x1(%r14,%rbx,1)
movzbl (%r14,%rbx,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe64(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0x4(%rsp),%xmm1
call   1030 <pow@plt>
movb   $0x0,(%r14,%rbx,1)
add    $0x3,%rbx
cmp    $0x1802,%rbx
jne    1130 <apply_gamma+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @apply_gamma(i8* %0, float %1) {
%3 = alloca i8*
%4 = alloca float
%5 = alloca i32
store i8* %0, i8** %3
store float %1, float* %4
store i32 0, i32* %5
br label %6
6: ; preds = %27, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 6144
br i1 %8, label %9, label %30
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = uitofp i8 %14 to float
%16 = fpext float %15 to double
%17 = fdiv double %16, 2.560000e+02
%18 = fptrunc double %17 to float
%19 = load float, float* %4
%20 = call i32 @pow(float %18, float %19)
%21 = mul nsw i32 %20, 256
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 %22, i8* %26
br label %27
27: ; preds = %9
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %6
30: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @apply_gamma(i8* nocapture %0, float %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ 0, %2 ], [ %25, %3 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = uitofp i8 %6 to double
%8 = fmul double %7, 3.906250e-03
%9 = fptrunc double %8 to float
%10 = tail call i32 @pow(float %9, float %1)
store i8 0, i8* %5
%11 = add nuw nsw i64 %4, 1
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = uitofp i8 %13 to double
%15 = fmul double %14, 3.906250e-03
%16 = fptrunc double %15 to float
%17 = tail call i32 @pow(float %16, float %1)
store i8 0, i8* %12
%18 = add nuw nsw i64 %4, 2
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = uitofp i8 %20 to double
%22 = fmul double %21, 3.906250e-03
%23 = fptrunc double %22 to float
%24 = tail call i32 @pow(float %23, float %1)
store i8 0, i8* %19
%25 = add nuw nsw i64 %4, 3
%26 = icmp eq i64 %25, 6144
br i1 %26, label %27, label %3
27: ; preds = %3
ret void
}