#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 /*<<< orphan*/ lookUpTable(int *, int *, int *, int *, int *);
int pow(int, double);
void imgGamma(int *image, double *gamma_value, int *width, int *height,
              int *depth, int *ret) {
  int i = 0;
  int lut[256];
  for (i = 0; i < 256; i++) {
    lut[i] = (int)(pow(i / 255.0, 1.0 / *gamma_value) * 255);
  }
  lookUpTable(image, width, height, depth, lut);
  *ret = 1;
  return;
}


x86 assembly (clang, -O0):
<imgGamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x100,-0x34(%rbp)
jge    11a7 <imgGamma+0x87>
cvtsi2sdl -0x34(%rbp),%xmm0
movsd  0xe9d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    -0x10(%rbp),%rax
movsd  0xe81(%rip),%xmm0
divsd  (%rax),%xmm0
call   1040 <pow@plt>
imul   $0xff,%eax,%ecx
movslq -0x34(%rbp),%rax
mov    %ecx,-0x440(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1151 <imgGamma+0x31>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    -0x440(%rbp),%r8
call   1030 <lookUpTable@plt>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imgGamma>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%rbx
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
divsd  0xea0(%rip),%xmm0
cvttsd2si %xmm0,%edi
movsd  0xe9c(%rip),%xmm0
divsd  0x0(%rbp),%xmm0
call   1040 <pow@plt>
mov    %eax,%ecx
shl    $0x8,%ecx
sub    %eax,%ecx
mov    %ecx,0x10(%rsp,%r14,4)
add    $0x1,%r14
cmp    $0x100,%r14
jne    1150 <imgGamma+0x30>
lea    0x10(%rsp),%r8
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
call   1030 <lookUpTable@plt>
mov    0x8(%rsp),%rax
movl   $0x1,(%rax)
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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