#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int image_channel_data_type;
  int image_channel_order;
};
typedef TYPE_1__ cl_image_format;
typedef int cl_channel_type;
typedef int cl_channel_order;

/* Variables and functions */
#define CL_A 155
#define CL_ARGB 154
#define CL_BGRA 153
#define CL_FLOAT 152
#define CL_HALF_FLOAT 151
#define CL_INTENSITY 150
#define CL_LUMINANCE 149
#define CL_R 148
#define CL_RA 147
#define CL_RG 146
#define CL_RGB 145
#define CL_RGBA 144
#define CL_RGBx 143
#define CL_RGx 142
#define CL_Rx 141
#define CL_SIGNED_INT16 140
#define CL_SIGNED_INT32 139
#define CL_SIGNED_INT8 138
#define CL_SNORM_INT16 137
#define CL_SNORM_INT8 136
#define CL_UNORM_INT16 135
#define CL_UNORM_INT8 134
#define CL_UNORM_INT_101010 133
#define CL_UNORM_SHORT_555 132
#define CL_UNORM_SHORT_565 131
#define CL_UNSIGNED_INT16 130
#define CL_UNSIGNED_INT32 129
#define CL_UNSIGNED_INT8 128
unsigned getImageDataSize(const cl_image_format *format) {
  cl_channel_type type = format->image_channel_data_type;
  cl_channel_order order = format->image_channel_order;
  unsigned byteChannel = 1;
  unsigned numChannels = 1;
  switch (type) {
  case CL_SNORM_INT8:
  case CL_UNORM_INT8:
  case CL_SIGNED_INT8:
  case CL_UNSIGNED_INT8:
    byteChannel = 1;
    break;
  case CL_SNORM_INT16:
  case CL_UNORM_INT16:
  case CL_SIGNED_INT16:
  case CL_HALF_FLOAT:
  case CL_UNSIGNED_INT16:
    byteChannel = 2;
    break;
  case CL_UNORM_SHORT_565:
    byteChannel = 2;
    break;
  case CL_UNORM_SHORT_555:
    byteChannel = 2;
    break;
  case CL_SIGNED_INT32:
  case CL_UNSIGNED_INT32:
  case CL_FLOAT:
    byteChannel = 4;
    break;
  case CL_UNORM_INT_101010:
    byteChannel = 4;
    break;
  default:
    byteChannel = 0;
  }
  switch (order) {
  case CL_R:
  case CL_Rx:
  case CL_A:
    numChannels = 1;
    break;
  case CL_INTENSITY:
  case CL_LUMINANCE:
    numChannels = 1;
    break;
  case CL_RG:
  case CL_RGx:
  case CL_RA:
    numChannels = 2;
    break;
  case CL_RGB:
  case CL_RGBx:
    numChannels = 1;
    break;
  case CL_RGBA:
    numChannels = 4;
    break;
  case CL_ARGB:
  case CL_BGRA:
    numChannels = 4;
    break;
  default:
    numChannels = 0;
  }
  return byteChannel * numChannels;
}


x86 assembly (clang, -O0):
<getImageDataSize>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x18,%eax
ja     119a <getImageDataSize+0x9a>
mov    -0x20(%rbp),%rax
lea    0xeb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x14(%rbp)
jmp    11a1 <getImageDataSize+0xa1>
movl   $0x2,-0x14(%rbp)
jmp    11a1 <getImageDataSize+0xa1>
movl   $0x2,-0x14(%rbp)
jmp    11a1 <getImageDataSize+0xa1>
movl   $0x2,-0x14(%rbp)
jmp    11a1 <getImageDataSize+0xa1>
movl   $0x4,-0x14(%rbp)
jmp    11a1 <getImageDataSize+0xa1>
movl   $0x4,-0x14(%rbp)
jmp    11a1 <getImageDataSize+0xa1>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffff73,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0xe,%eax
ja     1214 <getImageDataSize+0x114>
mov    -0x28(%rbp),%rax
lea    0xea1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x18(%rbp)
jmp    121b <getImageDataSize+0x11b>
movl   $0x1,-0x18(%rbp)
jmp    121b <getImageDataSize+0x11b>
movl   $0x2,-0x18(%rbp)
jmp    121b <getImageDataSize+0x11b>
movl   $0x1,-0x18(%rbp)
jmp    121b <getImageDataSize+0x11b>
movl   $0x4,-0x18(%rbp)
jmp    121b <getImageDataSize+0x11b>
movl   $0x4,-0x18(%rbp)
jmp    121b <getImageDataSize+0x11b>
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getImageDataSize>:
mov    (%rdi),%esi
mov    0x4(%rdi),%ecx
add    $0xffffff80,%esi
xor    %eax,%eax
mov    $0x0,%edx
cmp    $0x18,%esi
ja     1121 <getImageDataSize+0x21>
movslq %esi,%rdx
lea    0xee2(%rip),%rsi
mov    (%rsi,%rdx,4),%edx
add    $0xffffff73,%ecx
cmp    $0xe,%ecx
ja     1139 <getImageDataSize+0x39>
movslq %ecx,%rax
lea    0xf2e(%rip),%rcx
mov    (%rcx,%rax,4),%eax
imul   %edx,%eax
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
define i32 @getImageDataSize(%struct.TYPE_3__* %0) {
%2 = alloca %struct.TYPE_3__*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %2
%7 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
%9 = load i32, i32* %8
store i32 %9, i32* %3
%10 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 1
%12 = load i32, i32* %11
store i32 %12, i32* %4
store i32 1, i32* %5
store i32 1, i32* %6
%13 = load i32, i32* %3
switch i32 %13, label %20 [
i32 136, label %14
i32 134, label %14
i32 138, label %14
i32 128, label %14
i32 137, label %15
i32 135, label %15
i32 140, label %15
i32 151, label %15
i32 130, label %15
i32 131, label %16
i32 132, label %17
i32 139, label %18
i32 129, label %18
i32 152, label %18
i32 133, label %19
]
14: ; preds = %1, %1, %1, %1
store i32 1, i32* %5
br label %21
15: ; preds = %1, %1, %1, %1, %1
store i32 2, i32* %5
br label %21
16: ; preds = %1
store i32 2, i32* %5
br label %21
17: ; preds = %1
store i32 2, i32* %5
br label %21
18: ; preds = %1, %1, %1
store i32 4, i32* %5
br label %21
19: ; preds = %1
store i32 4, i32* %5
br label %21
20: ; preds = %1
store i32 0, i32* %5
br label %21
21: ; preds = %20, %19, %18, %17, %16, %15, %14
%22 = load i32, i32* %4
switch i32 %22, label %29 [
i32 148, label %23
i32 141, label %23
i32 155, label %23
i32 150, label %24
i32 149, label %24
i32 146, label %25
i32 142, label %25
i32 147, label %25
i32 145, label %26
i32 143, label %26
i32 144, label %27
i32 154, label %28
i32 153, label %28
]
23: ; preds = %21, %21, %21
store i32 1, i32* %6
br label %30
24: ; preds = %21, %21
store i32 1, i32* %6
br label %30
25: ; preds = %21, %21, %21
store i32 2, i32* %6
br label %30
26: ; preds = %21, %21
store i32 1, i32* %6
br label %30
27: ; preds = %21
store i32 4, i32* %6
br label %30
28: ; preds = %21, %21
store i32 4, i32* %6
br label %30
29: ; preds = %21
store i32 0, i32* %6
br label %30
30: ; preds = %29, %28, %27, %26, %25, %24, %23
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = mul i32 %31, %32
ret i32 %33
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@switch.table.getImageDataSize = [25 x i32] [i32 1, i32 4, i32 2, i32 2, i32 2, i32 4, i32 1, i32 2, i32 1, i32 2, i32 1, i32 4, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 2, i32 4]
@switch.table.getImageDataSize.1 = [15 x i32] [i32 1, i32 2, i32 1, i32 4, i32 1, i32 2, i32 2, i32 1, i32 1, i32 1, i32 0, i32 0, i32 4, i32 4, i32 1]
define i32 @getImageDataSize(%struct.TYPE_3__* nocapture %0) {
%2 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%5 = load i32, i32* %4
%6 = add i32 %3, -128
%7 = icmp ult i32 %6, 25
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = sext i32 %6 to i64
%10 = getelementptr inbounds [25 x i32], [25 x i32]* @switch.table.getImageDataSize, i64 0, i64 %9
%11 = load i32, i32* %10
br label %12
12: ; preds = %1, %8
%13 = phi i32 [ %11, %8 ], [ 0, %1 ]
%14 = add i32 %5, -141
%15 = icmp ult i32 %14, 15
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = sext i32 %14 to i64
%18 = getelementptr inbounds [15 x i32], [15 x i32]* @switch.table.getImageDataSize.1, i64 0, i64 %17
%19 = load i32, i32* %18
br label %20
20: ; preds = %12, %16
%21 = phi i32 [ %19, %16 ], [ 0, %12 ]
%22 = mul nuw nsw i32 %21, %13
ret i32 %22
}