#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_channel_float(float, int, int, void *, int,
                                                 int, int, void *, int, int,
                                                 int);
int /*<<< orphan*/ c_gamma_correct_channel_word16(float, int, int, void *, int,
                                                  int, int, void *, int, int,
                                                  int);
int /*<<< orphan*/ c_gamma_correct_channel_word32(float, int, int, void *, int,
                                                  int, int, void *, int, int,
                                                  int);
int /*<<< orphan*/ c_gamma_correct_channel_word8(float, int, int, void *, int,
                                                 int, int, void *, int, int,
                                                 int);
void c_gamma_correct_channel(int k_type, float gamma, int width, int height,
                             void *p1, int nchn1, int pad1, int ofs1, void *p2,
                             int nchn2, int pad2, int ofs2) {
  switch (k_type) {
  case 1:
    c_gamma_correct_channel_word8(gamma, width, height, p1, nchn1, pad1, ofs1,
                                  p2, nchn2, pad2, ofs2);
    ;
    break;
  case 2:
    c_gamma_correct_channel_word16(gamma, width, height, p1, nchn1, pad1, ofs1,
                                   p2, nchn2, pad2, ofs2);
    ;
    break;
  case 3:
    c_gamma_correct_channel_word32(gamma, width, height, p1, nchn1, pad1, ofs1,
                                   p2, nchn2, pad2, ofs2);
    ;
    break;
  case 4:
    c_gamma_correct_channel_float(gamma, width, height, p1, nchn1, pad1, ofs1,
                                  p2, nchn2, pad2, ofs2);
    ;
    break;
  }
}


x86 assembly (clang, -O0):
<c_gamma_correct_channel>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x48,%rsp
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0xc(%rbp)
movss  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     12ab <c_gamma_correct_channel+0x16b>
mov    -0x30(%rbp),%rax
lea    0xe6d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%rbx
mov    0x20(%rbp),%r11d
mov    0x28(%rbp),%r10d
mov    0x30(%rbp),%eax
mov    %rbx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1060 <c_gamma_correct_channel_word8@plt>
jmp    12ab <c_gamma_correct_channel+0x16b>
movss  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%rbx
mov    0x20(%rbp),%r11d
mov    0x28(%rbp),%r10d
mov    0x30(%rbp),%eax
mov    %rbx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1050 <c_gamma_correct_channel_word16@plt>
jmp    12ab <c_gamma_correct_channel+0x16b>
movss  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%rbx
mov    0x20(%rbp),%r11d
mov    0x28(%rbp),%r10d
mov    0x30(%rbp),%eax
mov    %rbx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1030 <c_gamma_correct_channel_word32@plt>
jmp    12ab <c_gamma_correct_channel+0x16b>
movss  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%rbx
mov    0x20(%rbp),%r11d
mov    0x28(%rbp),%r10d
mov    0x30(%rbp),%eax
mov    %rbx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1040 <c_gamma_correct_channel_float@plt>
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_gamma_correct_channel>:
push   %r15
push   %r14
push   %rbx
add    $0xffffffff,%edi
cmp    $0x3,%edi
ja     11f7 <c_gamma_correct_channel+0xb7>
mov    0x40(%rsp),%r15d
mov    0x38(%rsp),%r14d
mov    0x30(%rsp),%r11d
mov    0x28(%rsp),%r10
mov    0x20(%rsp),%eax
lea    0xe90(%rip),%rbx
movslq (%rbx,%rdi,4),%rdi
add    %rbx,%rdi
jmp    *%rdi
mov    %esi,%edi
mov    %edx,%esi
mov    %rcx,%rdx
mov    %r8d,%ecx
mov    %r9d,%r8d
mov    %eax,%r9d
push   %r15
push   %r14
push   %r11
push   %r10
call   1060 <c_gamma_correct_channel_word8@plt>
jmp    11f3 <c_gamma_correct_channel+0xb3>
mov    %esi,%edi
mov    %edx,%esi
mov    %rcx,%rdx
mov    %r8d,%ecx
mov    %r9d,%r8d
mov    %eax,%r9d
push   %r15
push   %r14
push   %r11
push   %r10
call   1050 <c_gamma_correct_channel_word16@plt>
jmp    11f3 <c_gamma_correct_channel+0xb3>
mov    %esi,%edi
mov    %edx,%esi
mov    %rcx,%rdx
mov    %r8d,%ecx
mov    %r9d,%r8d
mov    %eax,%r9d
push   %r15
push   %r14
push   %r11
push   %r10
call   1030 <c_gamma_correct_channel_word32@plt>
jmp    11f3 <c_gamma_correct_channel+0xb3>
mov    %esi,%edi
mov    %edx,%esi
mov    %rcx,%rdx
mov    %r8d,%ecx
mov    %r9d,%r8d
mov    %eax,%r9d
push   %r15
push   %r14
push   %r11
push   %r10
call   1040 <c_gamma_correct_channel_float@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @c_gamma_correct_channel(i32 %0, float %1, i32 %2, i32 %3, i8* %4, i32 %5, i32 %6, i32 %7, i8* %8, i32 %9, i32 %10, i32 %11) {
%13 = alloca i32
%14 = alloca float
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i8*
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
store i32 %0, i32* %13
store float %1, float* %14
store i32 %2, i32* %15
store i32 %3, i32* %16
store i8* %4, i8** %17
store i32 %5, i32* %18
store i32 %6, i32* %19
store i32 %7, i32* %20
store i8* %8, i8** %21
store i32 %9, i32* %22
store i32 %10, i32* %23
store i32 %11, i32* %24
%25 = load i32, i32* %13
switch i32 %25, label %78 [
i32 1, label %26
i32 2, label %39
i32 3, label %52
i32 4, label %65
]
26: ; preds = %12
%27 = load float, float* %14
%28 = load i32, i32* %15
%29 = load i32, i32* %16
%30 = load i8*, i8** %17
%31 = load i32, i32* %18
%32 = load i32, i32* %19
%33 = load i32, i32* %20
%34 = load i8*, i8** %21
%35 = load i32, i32* %22
%36 = load i32, i32* %23
%37 = load i32, i32* %24
%38 = call i32 @c_gamma_correct_channel_word8(float %27, i32 %28, i32 %29, i8* %30, i32 %31, i32 %32, i32 %33, i8* %34, i32 %35, i32 %36, i32 %37)
br label %78
39: ; preds = %12
%40 = load float, float* %14
%41 = load i32, i32* %15
%42 = load i32, i32* %16
%43 = load i8*, i8** %17
%44 = load i32, i32* %18
%45 = load i32, i32* %19
%46 = load i32, i32* %20
%47 = load i8*, i8** %21
%48 = load i32, i32* %22
%49 = load i32, i32* %23
%50 = load i32, i32* %24
%51 = call i32 @c_gamma_correct_channel_word16(float %40, i32 %41, i32 %42, i8* %43, i32 %44, i32 %45, i32 %46, i8* %47, i32 %48, i32 %49, i32 %50)
br label %78
52: ; preds = %12
%53 = load float, float* %14
%54 = load i32, i32* %15
%55 = load i32, i32* %16
%56 = load i8*, i8** %17
%57 = load i32, i32* %18
%58 = load i32, i32* %19
%59 = load i32, i32* %20
%60 = load i8*, i8** %21
%61 = load i32, i32* %22
%62 = load i32, i32* %23
%63 = load i32, i32* %24
%64 = call i32 @c_gamma_correct_channel_word32(float %53, i32 %54, i32 %55, i8* %56, i32 %57, i32 %58, i32 %59, i8* %60, i32 %61, i32 %62, i32 %63)
br label %78
65: ; preds = %12
%66 = load float, float* %14
%67 = load i32, i32* %15
%68 = load i32, i32* %16
%69 = load i8*, i8** %17
%70 = load i32, i32* %18
%71 = load i32, i32* %19
%72 = load i32, i32* %20
%73 = load i8*, i8** %21
%74 = load i32, i32* %22
%75 = load i32, i32* %23
%76 = load i32, i32* %24
%77 = call i32 @c_gamma_correct_channel_float(float %66, i32 %67, i32 %68, i8* %69, i32 %70, i32 %71, i32 %72, i8* %73, i32 %74, i32 %75, i32 %76)
br label %78
78: ; preds = %12, %65, %52, %39, %26
ret void
}

LLVM IR (-O2):
define void @c_gamma_correct_channel(i32 %0, float %1, i32 %2, i32 %3, i8* %4, i32 %5, i32 %6, i32 %7, i8* %8, i32 %9, i32 %10, i32 %11) {
switch i32 %0, label %21 [
i32 1, label %13
i32 2, label %15
i32 3, label %17
i32 4, label %19
]
13: ; preds = %12
%14 = tail call i32 @c_gamma_correct_channel_word8(float %1, i32 %2, i32 %3, i8* %4, i32 %5, i32 %6, i32 %7, i8* %8, i32 %9, i32 %10, i32 %11)
br label %21
15: ; preds = %12
%16 = tail call i32 @c_gamma_correct_channel_word16(float %1, i32 %2, i32 %3, i8* %4, i32 %5, i32 %6, i32 %7, i8* %8, i32 %9, i32 %10, i32 %11)
br label %21
17: ; preds = %12
%18 = tail call i32 @c_gamma_correct_channel_word32(float %1, i32 %2, i32 %3, i8* %4, i32 %5, i32 %6, i32 %7, i8* %8, i32 %9, i32 %10, i32 %11)
br label %21
19: ; preds = %12
%20 = tail call i32 @c_gamma_correct_channel_float(float %1, i32 %2, i32 %3, i8* %4, i32 %5, i32 %6, i32 %7, i8* %8, i32 %9, i32 %10, i32 %11)
br label %21
21: ; preds = %12, %19, %17, %15, %13
ret void
}