#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 160
#define GL_ALPHA 159
#define GL_BGR 158
#define GL_BGRA 157
#define GL_BITMAP 156
#define GL_BLUE 155
#define GL_BYTE 154
#define GL_COLOR_INDEX 153
#define GL_FLOAT 152
#define GL_GREEN 151
#define GL_INT 150
#define GL_INTENSITY 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 __glTexImage2D_size(GLenum format, GLenum type, GLsizei w, GLsizei h) {
  GLint elements, esize;
  if (w < 0)
    return 0;
  if (h < 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:
  case GL_INTENSITY:
    elements = 1;
    break;
  case GL_LUMINANCE_ALPHA:
    elements = 2;
    break;
  case GL_RGB:
  case GL_BGR:
    elements = 3;
    break;
  case GL_RGBA:
  case GL_BGRA:
  case GL_ABGR_EXT:
    elements = 4;
    break;
  default:
    return 0;
  }
  switch (type) {
  case GL_BITMAP:
    if (format == GL_COLOR_INDEX) {
      return (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);
}


x86 assembly (clang, -O0):
<__glTexImage2D_size>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    1126 <__glTexImage2D_size+0x26>
movl   $0x0,-0x4(%rbp)
jmp    1290 <__glTexImage2D_size+0x190>
cmpl   $0x0,-0x14(%rbp)
jge    113c <__glTexImage2D_size+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    1290 <__glTexImage2D_size+0x190>
mov    -0x8(%rbp),%eax
add    $0xffffff70,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x10,%eax
ja     11a3 <__glTexImage2D_size+0xa3>
mov    -0x28(%rbp),%rax
lea    0xea2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x18(%rbp)
jmp    11af <__glTexImage2D_size+0xaf>
movl   $0x1,-0x18(%rbp)
jmp    11af <__glTexImage2D_size+0xaf>
movl   $0x2,-0x18(%rbp)
jmp    11af <__glTexImage2D_size+0xaf>
movl   $0x3,-0x18(%rbp)
jmp    11af <__glTexImage2D_size+0xaf>
movl   $0x4,-0x18(%rbp)
jmp    11af <__glTexImage2D_size+0xaf>
movl   $0x0,-0x4(%rbp)
jmp    1290 <__glTexImage2D_size+0x190>
mov    -0xc(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x1c,%eax
ja     1272 <__glTexImage2D_size+0x172>
mov    -0x30(%rbp),%rax
lea    0xe75(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x99,-0x8(%rbp)
jne    1209 <__glTexImage2D_size+0x109>
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%eax
add    $0x7,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1290 <__glTexImage2D_size+0x190>
movl   $0x0,-0x4(%rbp)
jmp    1290 <__glTexImage2D_size+0x190>
movl   $0x1,-0x1c(%rbp)
jmp    127e <__glTexImage2D_size+0x17e>
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    127e <__glTexImage2D_size+0x17e>
movl   $0x2,-0x1c(%rbp)
jmp    127e <__glTexImage2D_size+0x17e>
movl   $0x2,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    127e <__glTexImage2D_size+0x17e>
movl   $0x4,-0x1c(%rbp)
jmp    127e <__glTexImage2D_size+0x17e>
movl   $0x4,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    127e <__glTexImage2D_size+0x17e>
movl   $0x0,-0x4(%rbp)
jmp    1290 <__glTexImage2D_size+0x190>
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
imul   -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__glTexImage2D_size>:
xor    %eax,%eax
mov    %ecx,%r8d
or     %edx,%r8d
js     1192 <__glTexImage2D_size+0x92>
lea    -0x90(%rdi),%r8d
cmp    $0x10,%r8d
ja     1192 <__glTexImage2D_size+0x92>
mov    $0x1eabf,%r9d
bt     %r8d,%r9d
jae    1192 <__glTexImage2D_size+0x92>
add    $0xffffff80,%esi
cmp    $0x1c,%esi
ja     1192 <__glTexImage2D_size+0x92>
movslq %r8d,%r8
lea    0xf3b(%rip),%r9
mov    (%r9,%r8,4),%r8d
mov    $0x1,%r9d
lea    0xeb6(%rip),%r10
movslq (%r10,%rsi,4),%rsi
add    %r10,%rsi
jmp    *%rsi
mov    $0x2,%r9d
jmp    1161 <__glTexImage2D_size+0x61>
mov    $0x4,%r9d
mov    $0x1,%r8d
jmp    1185 <__glTexImage2D_size+0x85>
mov    $0x4,%r9d
jmp    1185 <__glTexImage2D_size+0x85>
mov    $0x2,%r9d
jmp    1185 <__glTexImage2D_size+0x85>
mov    $0x1,%r8d
mov    $0x1,%r9d
imul   %r9d,%r8d
imul   %edx,%ecx
imul   %r8d,%ecx
mov    %ecx,%eax
ret
cmp    $0x99,%edi
jne    1192 <__glTexImage2D_size+0x92>
add    $0x7,%edx
shr    $0x3,%edx
imul   %ecx,%edx
mov    %edx,%eax
ret

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

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