#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_extract_channel_float(int, int, void *, int, int, int,
                                           void *, int, int, int);
int /*<<< orphan*/ c_extract_channel_word16(int, int, void *, int, int, int,
                                            void *, int, int, int);
int /*<<< orphan*/ c_extract_channel_word32(int, int, void *, int, int, int,
                                            void *, int, int, int);
int /*<<< orphan*/ c_extract_channel_word8(int, int, void *, int, int, int,
                                           void *, int, int, int);
void c_extract_channel(int k_type, 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_extract_channel_word8(width, height, p1, nchn1, pad1, ofs1, p2, nchn2,
                            pad2, ofs2);
    ;
    break;
  case 2:
    c_extract_channel_word16(width, height, p1, nchn1, pad1, ofs1, p2, nchn2,
                             pad2, ofs2);
    ;
    break;
  case 3:
    c_extract_channel_word32(width, height, p1, nchn1, pad1, ofs1, p2, nchn2,
                             pad2, ofs2);
    ;
    break;
  case 4:
    c_extract_channel_float(width, height, p1, nchn1, pad1, ofs1, p2, nchn2,
                            pad2, ofs2);
    ;
    break;
  }
}


x86 assembly (clang, -O0):
<c_extract_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)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%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     1292 <c_extract_channel+0x152>
mov    -0x30(%rbp),%rax
lea    0xe72(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%edi
mov    -0x14(%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_extract_channel_word8@plt>
jmp    1292 <c_extract_channel+0x152>
mov    -0x10(%rbp),%edi
mov    -0x14(%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_extract_channel_word16@plt>
jmp    1292 <c_extract_channel+0x152>
mov    -0x10(%rbp),%edi
mov    -0x14(%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_extract_channel_word32@plt>
jmp    1292 <c_extract_channel+0x152>
mov    -0x10(%rbp),%edi
mov    -0x14(%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_extract_channel_float@plt>
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_extract_channel>:
push   %r15
push   %r14
push   %rbx
add    $0xffffffff,%edi
cmp    $0x3,%edi
ja     11f7 <c_extract_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   1050 <c_extract_channel_word8@plt>
jmp    11f3 <c_extract_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   1060 <c_extract_channel_word16@plt>
jmp    11f3 <c_extract_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_extract_channel_word32@plt>
jmp    11f3 <c_extract_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_extract_channel_float@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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