#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 */
typedef int GLsizei;
typedef int GLint;
typedef int GLenum;

/* Variables and functions */
#define GL_ABGR_EXT 157
#define GL_ALPHA 156
#define GL_BITMAP 155
#define GL_BLUE 154
#define GL_BYTE 153
#define GL_COLOR_INDEX 152
#define GL_FLOAT 151
#define GL_GREEN 150
#define GL_INT 149
#define GL_LUMINANCE 148
#define GL_LUMINANCE_ALPHA 147
#define GL_RED 146
#define GL_RGB 145
#define GL_RGBA 144
#define GL_SHORT 143
#define GL_UNSIGNED_BYTE 142
#define GL_UNSIGNED_BYTE_2_3_3_REV 141
#define GL_UNSIGNED_BYTE_3_3_2 140
#define GL_UNSIGNED_INT 139
#define GL_UNSIGNED_INT_10_10_10_2 138
#define GL_UNSIGNED_INT_2_10_10_10_REV 137
#define GL_UNSIGNED_INT_8_8_8_8 136
#define GL_UNSIGNED_INT_8_8_8_8_REV 135
#define GL_UNSIGNED_SHORT 134
#define GL_UNSIGNED_SHORT_1_5_5_5_REV 133
#define GL_UNSIGNED_SHORT_4_4_4_4 132
#define GL_UNSIGNED_SHORT_4_4_4_4_REV 131
#define GL_UNSIGNED_SHORT_5_5_5_1 130
#define GL_UNSIGNED_SHORT_5_6_5 129
#define GL_UNSIGNED_SHORT_5_6_5_REV 128
GLint __glTexImage3D_size(GLenum format, GLenum type, GLsizei w, GLsizei h,
                          GLsizei d) {
  GLint elements, esize;
  if (w < 0)
    return 0;
  if (h < 0)
    return 0;
  if (d < 0)
    return 0;
  switch (format) {
  case GL_COLOR_INDEX:
    elements = 1;
    break;
  case GL_RED:
  case GL_GREEN:
  case GL_BLUE:
  case GL_ALPHA:
  case GL_LUMINANCE:
    elements = 1;
    break;
  case GL_LUMINANCE_ALPHA:
    elements = 2;
    break;
  case GL_RGB:
    elements = 3;
    break;
  case GL_RGBA:
  case GL_ABGR_EXT:
    elements = 4;
    break;
  default:
    return 0;
  }
  switch (type) {
  case GL_BITMAP:
    if (format == GL_COLOR_INDEX) {
      return (d * (h * ((w + 7) / 8)));
    } else {
      return 0;
    }
  case GL_BYTE:
  case GL_UNSIGNED_BYTE:
    esize = 1;
    break;
  case GL_UNSIGNED_BYTE_3_3_2:
  case GL_UNSIGNED_BYTE_2_3_3_REV:
    esize = 1;
    elements = 1;
    break;
  case GL_SHORT:
  case GL_UNSIGNED_SHORT:
    esize = 2;
    break;
  case GL_UNSIGNED_SHORT_5_6_5:
  case GL_UNSIGNED_SHORT_5_6_5_REV:
  case GL_UNSIGNED_SHORT_4_4_4_4:
  case GL_UNSIGNED_SHORT_4_4_4_4_REV:
  case GL_UNSIGNED_SHORT_5_5_5_1:
  case GL_UNSIGNED_SHORT_1_5_5_5_REV:
    esize = 2;
    elements = 1;
    break;
  case GL_INT:
  case GL_UNSIGNED_INT:
  case GL_FLOAT:
    esize = 4;
    break;
  case GL_UNSIGNED_INT_8_8_8_8:
  case GL_UNSIGNED_INT_8_8_8_8_REV:
  case GL_UNSIGNED_INT_10_10_10_2:
  case GL_UNSIGNED_INT_2_10_10_10_REV:
    esize = 4;
    elements = 1;
    break;
  default:
    return 0;
  }
  return elements * esize * w * h * d;
}


x86 assembly (clang, -O0):
<__glTexImage3D_size>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    112a <__glTexImage3D_size+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    12b4 <__glTexImage3D_size+0x1b4>
cmpl   $0x0,-0x14(%rbp)
jge    1140 <__glTexImage3D_size+0x40>
movl   $0x0,-0x4(%rbp)
jmp    12b4 <__glTexImage3D_size+0x1b4>
cmpl   $0x0,-0x18(%rbp)
jge    1156 <__glTexImage3D_size+0x56>
movl   $0x0,-0x4(%rbp)
jmp    12b4 <__glTexImage3D_size+0x1b4>
mov    -0x8(%rbp),%eax
add    $0xffffff70,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0xd,%eax
ja     11bd <__glTexImage3D_size+0xbd>
mov    -0x28(%rbp),%rax
lea    0xe88(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x1c(%rbp)
jmp    11c9 <__glTexImage3D_size+0xc9>
movl   $0x1,-0x1c(%rbp)
jmp    11c9 <__glTexImage3D_size+0xc9>
movl   $0x2,-0x1c(%rbp)
jmp    11c9 <__glTexImage3D_size+0xc9>
movl   $0x3,-0x1c(%rbp)
jmp    11c9 <__glTexImage3D_size+0xc9>
movl   $0x4,-0x1c(%rbp)
jmp    11c9 <__glTexImage3D_size+0xc9>
movl   $0x0,-0x4(%rbp)
jmp    12b4 <__glTexImage3D_size+0x1b4>
mov    -0xc(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x1b,%eax
ja     1292 <__glTexImage3D_size+0x192>
mov    -0x30(%rbp),%rax
lea    0xe4f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x98,-0x8(%rbp)
jne    1229 <__glTexImage3D_size+0x129>
mov    -0x18(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%eax
add    $0x7,%eax
mov    $0x8,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x34(%rbp),%eax
imul   %edx,%ecx
imul   %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    12b4 <__glTexImage3D_size+0x1b4>
movl   $0x0,-0x4(%rbp)
jmp    12b4 <__glTexImage3D_size+0x1b4>
movl   $0x1,-0x20(%rbp)
jmp    129e <__glTexImage3D_size+0x19e>
movl   $0x1,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    129e <__glTexImage3D_size+0x19e>
movl   $0x2,-0x20(%rbp)
jmp    129e <__glTexImage3D_size+0x19e>
movl   $0x2,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    129e <__glTexImage3D_size+0x19e>
movl   $0x4,-0x20(%rbp)
jmp    129e <__glTexImage3D_size+0x19e>
movl   $0x4,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    129e <__glTexImage3D_size+0x19e>
movl   $0x0,-0x4(%rbp)
jmp    12b4 <__glTexImage3D_size+0x1b4>
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
imul   -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__glTexImage3D_size>:
mov    %ecx,%r9d
or     %edx,%r9d
xor    %eax,%eax
or     %r8d,%r9d
js     119b <__glTexImage3D_size+0x9b>
lea    -0x90(%rdi),%r9d
cmp    $0xd,%r9d
ja     119b <__glTexImage3D_size+0x9b>
mov    $0x355f,%r10d
bt     %r9d,%r10d
jae    119b <__glTexImage3D_size+0x9b>
add    $0xffffff80,%esi
cmp    $0x1b,%esi
ja     119b <__glTexImage3D_size+0x9b>
movslq %r9d,%r9
lea    0xf34(%rip),%r10
mov    (%r10,%r9,4),%r9d
mov    $0x1,%r10d
lea    0xeb3(%rip),%r11
movslq (%r11,%rsi,4),%rsi
add    %r11,%rsi
jmp    *%rsi
mov    $0x2,%r10d
jmp    1164 <__glTexImage3D_size+0x64>
mov    $0x4,%r10d
mov    $0x1,%r9d
jmp    1188 <__glTexImage3D_size+0x88>
mov    $0x4,%r10d
jmp    1188 <__glTexImage3D_size+0x88>
mov    $0x2,%r10d
jmp    1188 <__glTexImage3D_size+0x88>
mov    $0x1,%r9d
mov    $0x1,%r10d
imul   %r10d,%r9d
imul   %ecx,%r8d
imul   %edx,%r8d
imul   %r9d,%r8d
mov    %r8d,%eax
ret
cmp    $0x98,%edi
jne    119b <__glTexImage3D_size+0x9b>
add    $0x7,%edx
shr    $0x3,%edx
imul   %ecx,%r8d
imul   %edx,%r8d
jmp    1198 <__glTexImage3D_size+0x98>

LLVM IR (-O0):
define i32 @__glTexImage3D_size(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%14 = load i32, i32* %9
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %5
store i32 0, i32* %6
br label %64
17: ; preds = %5
%18 = load i32, i32* %10
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 0, i32* %6
br label %64
21: ; preds = %17
%22 = load i32, i32* %11
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 0, i32* %6
br label %64
25: ; preds = %21
%26 = load i32, i32* %7
switch i32 %26, label %32 [
i32 152, label %27
i32 146, label %28
i32 150, label %28
i32 154, label %28
i32 156, label %28
i32 148, label %28
i32 147, label %29
i32 145, label %30
i32 144, label %31
i32 157, label %31
]
27: ; preds = %25
store i32 1, i32* %12
br label %33
28: ; preds = %25, %25, %25, %25, %25
store i32 1, i32* %12
br label %33
29: ; preds = %25
store i32 2, i32* %12
br label %33
30: ; preds = %25
store i32 3, i32* %12
br label %33
31: ; preds = %25, %25
store i32 4, i32* %12
br label %33
32: ; preds = %25
store i32 0, i32* %6
br label %64
33: ; preds = %31, %30, %29, %28, %27
%34 = load i32, i32* %8
switch i32 %34, label %53 [
i32 155, label %35
i32 153, label %47
i32 142, label %47
i32 140, label %48
i32 141, label %48
i32 143, label %49
i32 134, label %49
i32 129, label %50
i32 128, label %50
i32 132, label %50
i32 131, label %50
i32 130, label %50
i32 133, label %50
i32 149, label %51
i32 139, label %51
i32 151, label %51
i32 136, label %52
i32 135, label %52
i32 138, label %52
i32 137, label %52
]
35: ; preds = %33
%36 = load i32, i32* %7
%37 = icmp eq i32 %36, 152
br i1 %37, label %38, label %46
38: ; preds = %35
%39 = load i32, i32* %11
%40 = load i32, i32* %10
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 7
%43 = sdiv i32 %42, 8
%44 = mul nsw i32 %40, %43
%45 = mul nsw i32 %39, %44
store i32 %45, i32* %6
br label %64
46: ; preds = %35
store i32 0, i32* %6
br label %64
47: ; preds = %33, %33
store i32 1, i32* %13
br label %54
48: ; preds = %33, %33
store i32 1, i32* %13
store i32 1, i32* %12
br label %54
49: ; preds = %33, %33
store i32 2, i32* %13
br label %54
50: ; preds = %33, %33, %33, %33, %33, %33
store i32 2, i32* %13
store i32 1, i32* %12
br label %54
51: ; preds = %33, %33, %33
store i32 4, i32* %13
br label %54
52: ; preds = %33, %33, %33, %33
store i32 4, i32* %13
store i32 1, i32* %12
br label %54
53: ; preds = %33
store i32 0, i32* %6
br label %64
54: ; preds = %52, %51, %50, %49, %48, %47
%55 = load i32, i32* %12
%56 = load i32, i32* %13
%57 = mul nsw i32 %55, %56
%58 = load i32, i32* %9
%59 = mul nsw i32 %57, %58
%60 = load i32, i32* %10
%61 = mul nsw i32 %59, %60
%62 = load i32, i32* %11
%63 = mul nsw i32 %61, %62
store i32 %63, i32* %6
br label %64
64: ; preds = %54, %53, %46, %38, %32, %24, %20, %16
%65 = load i32, i32* %6
ret i32 %65
}

LLVM IR (-O2):
@switch.table.__glTexImage3D_size = [14 x i32] [i32 4, i32 3, i32 1, i32 2, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 4]
define i32 @__glTexImage3D_size(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = or i32 %3, %2
%7 = or i32 %6, %4
%8 = icmp sgt i32 %7, -1
br i1 %8, label %9, label %40
9: ; preds = %5
%10 = add i32 %0, -144
%11 = icmp ult i32 %10, 14
br i1 %11, label %12, label %40
12: ; preds = %9
%13 = trunc i32 %10 to i16
%14 = lshr i16 13663, %13
%15 = and i16 %14, 1
%16 = icmp eq i16 %15, 0
br i1 %16, label %40, label %17
17: ; preds = %12
%18 = sext i32 %10 to i64
%19 = getelementptr inbounds [14 x i32], [14 x i32]* @switch.table.__glTexImage3D_size, i64 0, i64 %18
%20 = load i32, i32* %19
switch i32 %1, label %40 [
i32 155, label %21
i32 153, label %33
i32 142, label %33
i32 140, label %28
i32 141, label %28
i32 143, label %29
i32 134, label %29
i32 129, label %30
i32 128, label %30
i32 132, label %30
i32 131, label %30
i32 130, label %30
i32 133, label %30
i32 149, label %31
i32 139, label %31
i32 151, label %31
i32 136, label %32
i32 135, label %32
i32 138, label %32
i32 137, label %32
]
21: ; preds = %17
%22 = icmp eq i32 %0, 152
br i1 %22, label %23, label %40
23: ; preds = %21
%24 = add nuw nsw i32 %2, 7
%25 = lshr i32 %24, 3
%26 = mul i32 %4, %3
%27 = mul i32 %26, %25
br label %40
28: ; preds = %17, %17
br label %33
29: ; preds = %17, %17
br label %33
30: ; preds = %17, %17, %17, %17, %17, %17
br label %33
31: ; preds = %17, %17, %17
br label %33
32: ; preds = %17, %17, %17, %17
br label %33
33: ; preds = %17, %17, %32, %31, %30, %29, %28
%34 = phi i32 [ 1, %32 ], [ %20, %31 ], [ 1, %30 ], [ %20, %29 ], [ 1, %28 ], [ %20, %17 ], [ %20, %17 ]
%35 = phi i32 [ 4, %32 ], [ 4, %31 ], [ 2, %30 ], [ 2, %29 ], [ 1, %28 ], [ 1, %17 ], [ 1, %17 ]
%36 = mul i32 %4, %3
%37 = mul i32 %36, %2
%38 = mul i32 %37, %34
%39 = mul i32 %38, %35
br label %40
40: ; preds = %12, %9, %17, %21, %5, %33, %23
%41 = phi i32 [ %39, %33 ], [ %27, %23 ], [ 0, %5 ], [ 0, %9 ], [ 0, %21 ], [ 0, %17 ], [ 0, %12 ]
ret i32 %41
}