#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_linear_combine_channels_float(float, float, int, int,
                                                   void *, int, int, int,
                                                   void *, int, int, int,
                                                   void *, int, int, int);
int /*<<< orphan*/ c_linear_combine_channels_word16(float, float, int, int,
                                                    void *, int, int, int,
                                                    void *, int, int, int,
                                                    void *, int, int, int);
int /*<<< orphan*/ c_linear_combine_channels_word32(float, float, int, int,
                                                    void *, int, int, int,
                                                    void *, int, int, int,
                                                    void *, int, int, int);
int /*<<< orphan*/ c_linear_combine_channels_word8(float, float, int, int,
                                                   void *, int, int, int,
                                                   void *, int, int, int,
                                                   void *, int, int, int);
void c_linear_combine_channels(int k_type, float weight1, float weight2,
                               int width, int height, void *p1, int nchn1,
                               int pad1, int ofs1, void *p2, int nchn2,
                               int pad2, int ofs2, void *p3, int nchn3,
                               int pad3, int ofs3) {
  switch (k_type) {
  case 1:
    c_linear_combine_channels_word8(weight1, weight2, width, height, p1, nchn1,
                                    pad1, ofs1, p2, nchn2, pad2, ofs2, p3,
                                    nchn3, pad3, ofs3);
    ;
    break;
  case 2:
    c_linear_combine_channels_word16(weight1, weight2, width, height, p1, nchn1,
                                     pad1, ofs1, p2, nchn2, pad2, ofs2, p3,
                                     nchn3, pad3, ofs3);
    ;
    break;
  case 3:
    c_linear_combine_channels_word32(weight1, weight2, width, height, p1, nchn1,
                                     pad1, ofs1, p2, nchn2, pad2, ofs2, p3,
                                     nchn3, pad3, ofs3);
    ;
    break;
  case 4:
    c_linear_combine_channels_float(weight1, weight2, width, height, p1, nchn1,
                                    pad1, ofs1, p2, nchn2, pad2, ofs2, p3,
                                    nchn3, pad3, ofs3);
    ;
    break;
  }
}


x86 assembly (clang, -O0):
<c_linear_combine_channels>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    0x50(%rbp),%eax
mov    0x48(%rbp),%eax
mov    0x40(%rbp),%eax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0x2c(%rbp)
movss  %xmm0,-0x30(%rbp)
movss  %xmm1,-0x34(%rbp)
mov    %esi,-0x38(%rbp)
mov    %edx,-0x3c(%rbp)
mov    %rcx,-0x48(%rbp)
mov    %r8d,-0x4c(%rbp)
mov    %r9d,-0x50(%rbp)
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x58(%rbp)
sub    $0x3,%eax
ja     1369 <c_linear_combine_channels+0x229>
mov    -0x58(%rbp),%rax
lea    0xe53(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x30(%rbp),%xmm0
movss  -0x34(%rbp),%xmm1
mov    -0x38(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x48(%rbp),%rdx
mov    -0x4c(%rbp),%ecx
mov    -0x50(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%r13
mov    0x20(%rbp),%r12d
mov    0x28(%rbp),%r15d
mov    0x30(%rbp),%r14d
mov    0x38(%rbp),%rbx
mov    0x40(%rbp),%r11d
mov    0x48(%rbp),%r10d
mov    0x50(%rbp),%eax
mov    %r13,(%rsp)
mov    %r12d,0x8(%rsp)
mov    %r15d,0x10(%rsp)
mov    %r14d,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11d,0x28(%rsp)
mov    %r10d,0x30(%rsp)
mov    %eax,0x38(%rsp)
call   1040 <c_linear_combine_channels_word8@plt>
jmp    1369 <c_linear_combine_channels+0x229>
movss  -0x30(%rbp),%xmm0
movss  -0x34(%rbp),%xmm1
mov    -0x38(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x48(%rbp),%rdx
mov    -0x4c(%rbp),%ecx
mov    -0x50(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%r13
mov    0x20(%rbp),%r12d
mov    0x28(%rbp),%r15d
mov    0x30(%rbp),%r14d
mov    0x38(%rbp),%rbx
mov    0x40(%rbp),%r11d
mov    0x48(%rbp),%r10d
mov    0x50(%rbp),%eax
mov    %r13,(%rsp)
mov    %r12d,0x8(%rsp)
mov    %r15d,0x10(%rsp)
mov    %r14d,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11d,0x28(%rsp)
mov    %r10d,0x30(%rsp)
mov    %eax,0x38(%rsp)
call   1050 <c_linear_combine_channels_word16@plt>
jmp    1369 <c_linear_combine_channels+0x229>
movss  -0x30(%rbp),%xmm0
movss  -0x34(%rbp),%xmm1
mov    -0x38(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x48(%rbp),%rdx
mov    -0x4c(%rbp),%ecx
mov    -0x50(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%r13
mov    0x20(%rbp),%r12d
mov    0x28(%rbp),%r15d
mov    0x30(%rbp),%r14d
mov    0x38(%rbp),%rbx
mov    0x40(%rbp),%r11d
mov    0x48(%rbp),%r10d
mov    0x50(%rbp),%eax
mov    %r13,(%rsp)
mov    %r12d,0x8(%rsp)
mov    %r15d,0x10(%rsp)
mov    %r14d,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11d,0x28(%rsp)
mov    %r10d,0x30(%rsp)
mov    %eax,0x38(%rsp)
call   1030 <c_linear_combine_channels_word32@plt>
jmp    1369 <c_linear_combine_channels+0x229>
movss  -0x30(%rbp),%xmm0
movss  -0x34(%rbp),%xmm1
mov    -0x38(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x48(%rbp),%rdx
mov    -0x4c(%rbp),%ecx
mov    -0x50(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%r13
mov    0x20(%rbp),%r12d
mov    0x28(%rbp),%r15d
mov    0x30(%rbp),%r14d
mov    0x38(%rbp),%rbx
mov    0x40(%rbp),%r11d
mov    0x48(%rbp),%r10d
mov    0x50(%rbp),%eax
mov    %r13,(%rsp)
mov    %r12d,0x8(%rsp)
mov    %r15d,0x10(%rsp)
mov    %r14d,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11d,0x28(%rsp)
mov    %r10d,0x30(%rsp)
mov    %eax,0x38(%rsp)
call   1060 <c_linear_combine_channels_float@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_linear_combine_channels>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
add    $0xffffffff,%edi
cmp    $0x3,%edi
ja     11b8 <c_linear_combine_channels+0x78>
mov    0x80(%rsp),%ebp
mov    0x78(%rsp),%ebx
mov    0x70(%rsp),%r13d
mov    0x68(%rsp),%r12
mov    0x60(%rsp),%r15d
mov    0x58(%rsp),%r14d
mov    0x50(%rsp),%r11d
mov    0x40(%rsp),%eax
lea    0xe7e(%rip),%r10
movslq (%r10,%rdi,4),%rdi
add    %r10,%rdi
jmp    *%rdi
mov    %esi,%edi
mov    %edx,%esi
mov    %rcx,%rdx
mov    %r8d,%ecx
mov    %r9d,%r8d
mov    %eax,%r9d
push   %rbp
push   %rbx
push   %r13
push   %r12
push   %r15
push   %r14
push   %r11
push   0x80(%rsp)
call   1040 <c_linear_combine_channels_word8@plt>
jmp    123d <c_linear_combine_channels+0xfd>
add    $0x8,%rsp
jmp    1241 <c_linear_combine_channels+0x101>
mov    %esi,%edi
mov    %edx,%esi
mov    %rcx,%rdx
mov    %r8d,%ecx
mov    %r9d,%r8d
mov    %eax,%r9d
push   %rbp
push   %rbx
push   %r13
push   %r12
push   %r15
push   %r14
push   %r11
push   0x80(%rsp)
call   1050 <c_linear_combine_channels_word16@plt>
jmp    123d <c_linear_combine_channels+0xfd>
mov    %esi,%edi
mov    %edx,%esi
mov    %rcx,%rdx
mov    %r8d,%ecx
mov    %r9d,%r8d
mov    %eax,%r9d
push   %rbp
push   %rbx
push   %r13
push   %r12
push   %r15
push   %r14
push   %r11
push   0x80(%rsp)
call   1030 <c_linear_combine_channels_word32@plt>
jmp    123d <c_linear_combine_channels+0xfd>
mov    %esi,%edi
mov    %edx,%esi
mov    %rcx,%rdx
mov    %r8d,%ecx
mov    %r9d,%r8d
mov    %eax,%r9d
push   %rbp
push   %rbx
push   %r13
push   %r12
push   %r15
push   %r14
push   %r11
push   0x80(%rsp)
call   1060 <c_linear_combine_channels_float@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @c_linear_combine_channels(i32 %0, float %1, float %2, i32 %3, i32 %4, i8* %5, i32 %6, i32 %7, i32 %8, i8* %9, i32 %10, i32 %11, i32 %12, i8* %13, i32 %14, i32 %15, i32 %16) {
%18 = alloca i32
%19 = alloca float
%20 = alloca float
%21 = alloca i32
%22 = alloca i32
%23 = alloca i8*
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i8*
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca i8*
%32 = alloca i32
%33 = alloca i32
%34 = alloca i32
store i32 %0, i32* %18
store float %1, float* %19
store float %2, float* %20
store i32 %3, i32* %21
store i32 %4, i32* %22
store i8* %5, i8** %23
store i32 %6, i32* %24
store i32 %7, i32* %25
store i32 %8, i32* %26
store i8* %9, i8** %27
store i32 %10, i32* %28
store i32 %11, i32* %29
store i32 %12, i32* %30
store i8* %13, i8** %31
store i32 %14, i32* %32
store i32 %15, i32* %33
store i32 %16, i32* %34
%35 = load i32, i32* %18
switch i32 %35, label %108 [
i32 1, label %36
i32 2, label %54
i32 3, label %72
i32 4, label %90
]
36: ; preds = %17
%37 = load float, float* %19
%38 = load float, float* %20
%39 = load i32, i32* %21
%40 = load i32, i32* %22
%41 = load i8*, i8** %23
%42 = load i32, i32* %24
%43 = load i32, i32* %25
%44 = load i32, i32* %26
%45 = load i8*, i8** %27
%46 = load i32, i32* %28
%47 = load i32, i32* %29
%48 = load i32, i32* %30
%49 = load i8*, i8** %31
%50 = load i32, i32* %32
%51 = load i32, i32* %33
%52 = load i32, i32* %34
%53 = call i32 @c_linear_combine_channels_word8(float %37, float %38, i32 %39, i32 %40, i8* %41, i32 %42, i32 %43, i32 %44, i8* %45, i32 %46, i32 %47, i32 %48, i8* %49, i32 %50, i32 %51, i32 %52)
br label %108
54: ; preds = %17
%55 = load float, float* %19
%56 = load float, float* %20
%57 = load i32, i32* %21
%58 = load i32, i32* %22
%59 = load i8*, i8** %23
%60 = load i32, i32* %24
%61 = load i32, i32* %25
%62 = load i32, i32* %26
%63 = load i8*, i8** %27
%64 = load i32, i32* %28
%65 = load i32, i32* %29
%66 = load i32, i32* %30
%67 = load i8*, i8** %31
%68 = load i32, i32* %32
%69 = load i32, i32* %33
%70 = load i32, i32* %34
%71 = call i32 @c_linear_combine_channels_word16(float %55, float %56, i32 %57, i32 %58, i8* %59, i32 %60, i32 %61, i32 %62, i8* %63, i32 %64, i32 %65, i32 %66, i8* %67, i32 %68, i32 %69, i32 %70)
br label %108
72: ; preds = %17
%73 = load float, float* %19
%74 = load float, float* %20
%75 = load i32, i32* %21
%76 = load i32, i32* %22
%77 = load i8*, i8** %23
%78 = load i32, i32* %24
%79 = load i32, i32* %25
%80 = load i32, i32* %26
%81 = load i8*, i8** %27
%82 = load i32, i32* %28
%83 = load i32, i32* %29
%84 = load i32, i32* %30
%85 = load i8*, i8** %31
%86 = load i32, i32* %32
%87 = load i32, i32* %33
%88 = load i32, i32* %34
%89 = call i32 @c_linear_combine_channels_word32(float %73, float %74, i32 %75, i32 %76, i8* %77, i32 %78, i32 %79, i32 %80, i8* %81, i32 %82, i32 %83, i32 %84, i8* %85, i32 %86, i32 %87, i32 %88)
br label %108
90: ; preds = %17
%91 = load float, float* %19
%92 = load float, float* %20
%93 = load i32, i32* %21
%94 = load i32, i32* %22
%95 = load i8*, i8** %23
%96 = load i32, i32* %24
%97 = load i32, i32* %25
%98 = load i32, i32* %26
%99 = load i8*, i8** %27
%100 = load i32, i32* %28
%101 = load i32, i32* %29
%102 = load i32, i32* %30
%103 = load i8*, i8** %31
%104 = load i32, i32* %32
%105 = load i32, i32* %33
%106 = load i32, i32* %34
%107 = call i32 @c_linear_combine_channels_float(float %91, float %92, i32 %93, i32 %94, i8* %95, i32 %96, i32 %97, i32 %98, i8* %99, i32 %100, i32 %101, i32 %102, i8* %103, i32 %104, i32 %105, i32 %106)
br label %108
108: ; preds = %17, %90, %72, %54, %36
ret void
}

LLVM IR (-O2):
define void @c_linear_combine_channels(i32 %0, float %1, float %2, i32 %3, i32 %4, i8* %5, i32 %6, i32 %7, i32 %8, i8* %9, i32 %10, i32 %11, i32 %12, i8* %13, i32 %14, i32 %15, i32 %16) {
switch i32 %0, label %26 [
i32 1, label %18
i32 2, label %20
i32 3, label %22
i32 4, label %24
]
18: ; preds = %17
%19 = tail call i32 @c_linear_combine_channels_word8(float %1, float %2, i32 %3, i32 %4, i8* %5, i32 %6, i32 %7, i32 %8, i8* %9, i32 %10, i32 %11, i32 %12, i8* %13, i32 %14, i32 %15, i32 %16)
br label %26
20: ; preds = %17
%21 = tail call i32 @c_linear_combine_channels_word16(float %1, float %2, i32 %3, i32 %4, i8* %5, i32 %6, i32 %7, i32 %8, i8* %9, i32 %10, i32 %11, i32 %12, i8* %13, i32 %14, i32 %15, i32 %16)
br label %26
22: ; preds = %17
%23 = tail call i32 @c_linear_combine_channels_word32(float %1, float %2, i32 %3, i32 %4, i8* %5, i32 %6, i32 %7, i32 %8, i8* %9, i32 %10, i32 %11, i32 %12, i8* %13, i32 %14, i32 %15, i32 %16)
br label %26
24: ; preds = %17
%25 = tail call i32 @c_linear_combine_channels_float(float %1, float %2, i32 %3, i32 %4, i8* %5, i32 %6, i32 %7, i32 %8, i8* %9, i32 %10, i32 %11, i32 %12, i8* %13, i32 %14, i32 %15, i32 %16)
br label %26
26: ; preds = %17, %24, %22, %20, %18
ret void
}