#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*/ c_gamma_correct_all_channels_float(float, int, int, int,
                                                      void *, int, void *, int);
int /*<<< orphan*/ c_gamma_correct_all_channels_word16(float, int, int, int,
                                                       void *, int, void *,
                                                       int);
int /*<<< orphan*/ c_gamma_correct_all_channels_word32(float, int, int, int,
                                                       void *, int, void *,
                                                       int);
int /*<<< orphan*/ c_gamma_correct_all_channels_word8(float, int, int, int,
                                                      void *, int, void *, int);
void c_gamma_correct_all_channels(int k_type, float gamma, int width,
                                  int height, int nchn, void *p1, int pad1,
                                  void *p2, int pad2) {
  switch (k_type) {
  case 1:
    c_gamma_correct_all_channels_word8(gamma, width, height, nchn, p1, pad1, p2,
                                       pad2);
    ;
    break;
  case 2:
    c_gamma_correct_all_channels_word16(gamma, width, height, nchn, p1, pad1,
                                        p2, pad2);
    ;
    break;
  case 3:
    c_gamma_correct_all_channels_word32(gamma, width, height, nchn, p1, pad1,
                                        p2, pad2);
    ;
    break;
  case 4:
    c_gamma_correct_all_channels_float(gamma, width, height, nchn, p1, pad1, p2,
                                       pad2);
    ;
    break;
  }
}


x86 assembly (clang, -O0):
<c_gamma_correct_all_channels>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     1234 <c_gamma_correct_all_channels+0xf4>
mov    -0x30(%rbp),%rax
lea    0xe78(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <c_gamma_correct_all_channels_word8@plt>
jmp    1234 <c_gamma_correct_all_channels+0xf4>
movss  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <c_gamma_correct_all_channels_word16@plt>
jmp    1234 <c_gamma_correct_all_channels+0xf4>
movss  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%eax
mov    %eax,(%rsp)
call   1050 <c_gamma_correct_all_channels_word32@plt>
jmp    1234 <c_gamma_correct_all_channels+0xf4>
movss  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%eax
mov    %eax,(%rsp)
call   1060 <c_gamma_correct_all_channels_float@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_gamma_correct_all_channels>:
push   %rax
add    $0xffffffff,%edi
cmp    $0x3,%edi
ja     11cd <c_gamma_correct_all_channels+0x8d>
mov    0x18(%rsp),%r11d
mov    0x10(%rsp),%r10
lea    0xea2(%rip),%rax
movslq (%rax,%rdi,4),%rdi
add    %rax,%rdi
jmp    *%rdi
mov    %r11d,(%rsp)
mov    %esi,%edi
mov    %edx,%esi
mov    %ecx,%edx
mov    %r8,%rcx
mov    %r9d,%r8d
mov    %r10,%r9
call   1040 <c_gamma_correct_all_channels_word8@plt>
pop    %rax
ret
mov    %r11d,(%rsp)
mov    %esi,%edi
mov    %edx,%esi
mov    %ecx,%edx
mov    %r8,%rcx
mov    %r9d,%r8d
mov    %r10,%r9
call   1030 <c_gamma_correct_all_channels_word16@plt>
pop    %rax
ret
mov    %r11d,(%rsp)
mov    %esi,%edi
mov    %edx,%esi
mov    %ecx,%edx
mov    %r8,%rcx
mov    %r9d,%r8d
mov    %r10,%r9
call   1050 <c_gamma_correct_all_channels_word32@plt>
pop    %rax
ret
mov    %r11d,(%rsp)
mov    %esi,%edi
mov    %edx,%esi
mov    %ecx,%edx
mov    %r8,%rcx
mov    %r9d,%r8d
mov    %r10,%r9
call   1060 <c_gamma_correct_all_channels_float@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @c_gamma_correct_all_channels(i32 %0, float %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6, i8* %7, i32 %8) {
%10 = alloca i32
%11 = alloca float
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i32
store i32 %0, i32* %10
store float %1, float* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i8* %5, i8** %15
store i32 %6, i32* %16
store i8* %7, i8** %17
store i32 %8, i32* %18
%19 = load i32, i32* %10
switch i32 %19, label %60 [
i32 1, label %20
i32 2, label %30
i32 3, label %40
i32 4, label %50
]
20: ; preds = %9
%21 = load float, float* %11
%22 = load i32, i32* %12
%23 = load i32, i32* %13
%24 = load i32, i32* %14
%25 = load i8*, i8** %15
%26 = load i32, i32* %16
%27 = load i8*, i8** %17
%28 = load i32, i32* %18
%29 = call i32 @c_gamma_correct_all_channels_word8(float %21, i32 %22, i32 %23, i32 %24, i8* %25, i32 %26, i8* %27, i32 %28)
br label %60
30: ; preds = %9
%31 = load float, float* %11
%32 = load i32, i32* %12
%33 = load i32, i32* %13
%34 = load i32, i32* %14
%35 = load i8*, i8** %15
%36 = load i32, i32* %16
%37 = load i8*, i8** %17
%38 = load i32, i32* %18
%39 = call i32 @c_gamma_correct_all_channels_word16(float %31, i32 %32, i32 %33, i32 %34, i8* %35, i32 %36, i8* %37, i32 %38)
br label %60
40: ; preds = %9
%41 = load float, float* %11
%42 = load i32, i32* %12
%43 = load i32, i32* %13
%44 = load i32, i32* %14
%45 = load i8*, i8** %15
%46 = load i32, i32* %16
%47 = load i8*, i8** %17
%48 = load i32, i32* %18
%49 = call i32 @c_gamma_correct_all_channels_word32(float %41, i32 %42, i32 %43, i32 %44, i8* %45, i32 %46, i8* %47, i32 %48)
br label %60
50: ; preds = %9
%51 = load float, float* %11
%52 = load i32, i32* %12
%53 = load i32, i32* %13
%54 = load i32, i32* %14
%55 = load i8*, i8** %15
%56 = load i32, i32* %16
%57 = load i8*, i8** %17
%58 = load i32, i32* %18
%59 = call i32 @c_gamma_correct_all_channels_float(float %51, i32 %52, i32 %53, i32 %54, i8* %55, i32 %56, i8* %57, i32 %58)
br label %60
60: ; preds = %9, %50, %40, %30, %20
ret void
}

LLVM IR (-O2):
define void @c_gamma_correct_all_channels(i32 %0, float %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6, i8* %7, i32 %8) {
switch i32 %0, label %18 [
i32 1, label %10
i32 2, label %12
i32 3, label %14
i32 4, label %16
]
10: ; preds = %9
%11 = tail call i32 @c_gamma_correct_all_channels_word8(float %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6, i8* %7, i32 %8)
br label %18
12: ; preds = %9
%13 = tail call i32 @c_gamma_correct_all_channels_word16(float %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6, i8* %7, i32 %8)
br label %18
14: ; preds = %9
%15 = tail call i32 @c_gamma_correct_all_channels_word32(float %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6, i8* %7, i32 %8)
br label %18
16: ; preds = %9
%17 = tail call i32 @c_gamma_correct_all_channels_float(float %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6, i8* %7, i32 %8)
br label %18
18: ; preds = %9, %16, %14, %12, %10
ret void
}