#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 __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:
    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 (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    $0xd,%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    $0x1b,%eax
ja     1272 <__glTexImage2D_size+0x172>
mov    -0x30(%rbp),%rax
lea    0xe69(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x98,-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    $0xd,%r8d
ja     1192 <__glTexImage2D_size+0x92>
mov    $0x355f,%r9d
bt     %r8d,%r9d
jae    1192 <__glTexImage2D_size+0x92>
add    $0xffffff80,%esi
cmp    $0x1b,%esi
ja     1192 <__glTexImage2D_size+0x92>
movslq %r8d,%r8
lea    0xf37(%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    $0x98,%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 152, label %21
i32 146, label %22
i32 150, label %22
i32 154, label %22
i32 156, label %22
i32 148, label %22
i32 147, label %23
i32 145, label %24
i32 144, label %25
i32 157, label %25
]
21: ; preds = %19
store i32 1, i32* %10
br label %27
22: ; preds = %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
store i32 3, i32* %10
br label %27
25: ; preds = %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 155, label %29
i32 153, 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 149, label %43
i32 139, label %43
i32 151, 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, 152
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 = [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 @__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 %36
7: ; preds = %4
%8 = add i32 %0, -144
%9 = icmp ult i32 %8, 14
br i1 %9, label %10, label %36
10: ; preds = %7
%11 = trunc i32 %8 to i16
%12 = lshr i16 13663, %11
%13 = and i16 %12, 1
%14 = icmp eq i16 %13, 0
br i1 %14, label %36, label %15
15: ; preds = %10
%16 = sext i32 %8 to i64
%17 = getelementptr inbounds [14 x i32], [14 x i32]* @switch.table.__glTexImage2D_size, i64 0, i64 %16
%18 = load i32, i32* %17
switch i32 %1, label %36 [
i32 155, label %19
i32 153, label %30
i32 142, label %30
i32 140, label %25
i32 141, label %25
i32 143, label %26
i32 134, label %26
i32 129, label %27
i32 128, label %27
i32 132, label %27
i32 131, label %27
i32 130, label %27
i32 133, label %27
i32 149, label %28
i32 139, label %28
i32 151, label %28
i32 136, label %29
i32 135, label %29
i32 138, label %29
i32 137, label %29
]
19: ; preds = %15
%20 = icmp eq i32 %0, 152
br i1 %20, label %21, label %36
21: ; preds = %19
%22 = add nuw nsw i32 %2, 7
%23 = lshr i32 %22, 3
%24 = mul nsw i32 %23, %3
br label %36
25: ; preds = %15, %15
br label %30
26: ; preds = %15, %15
br label %30
27: ; preds = %15, %15, %15, %15, %15, %15
br label %30
28: ; preds = %15, %15, %15
br label %30
29: ; preds = %15, %15, %15, %15
br label %30
30: ; preds = %15, %15, %29, %28, %27, %26, %25
%31 = phi i32 [ 1, %29 ], [ %18, %28 ], [ 1, %27 ], [ %18, %26 ], [ 1, %25 ], [ %18, %15 ], [ %18, %15 ]
%32 = phi i32 [ 4, %29 ], [ 4, %28 ], [ 2, %27 ], [ 2, %26 ], [ 1, %25 ], [ 1, %15 ], [ 1, %15 ]
%33 = mul i32 %3, %2
%34 = mul i32 %33, %31
%35 = mul i32 %34, %32
br label %36
36: ; preds = %10, %7, %15, %19, %4, %30, %21
%37 = phi i32 [ %35, %30 ], [ %24, %21 ], [ 0, %4 ], [ 0, %7 ], [ 0, %19 ], [ 0, %15 ], [ 0, %10 ]
ret i32 %37
}