#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 __glTexImage1D_size(GLenum format, GLenum type, GLsizei w) {
  GLint elements, esize;
  if (w < 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 (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;
}


x86 assembly (clang, -O0):
<__glTexImage1D_size>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    1123 <__glTexImage1D_size+0x23>
movl   $0x0,-0x4(%rbp)
jmp    1265 <__glTexImage1D_size+0x165>
mov    -0x8(%rbp),%eax
add    $0xffffff70,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xd,%eax
ja     118a <__glTexImage1D_size+0x8a>
mov    -0x20(%rbp),%rax
lea    0xebb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x14(%rbp)
jmp    1196 <__glTexImage1D_size+0x96>
movl   $0x1,-0x14(%rbp)
jmp    1196 <__glTexImage1D_size+0x96>
movl   $0x2,-0x14(%rbp)
jmp    1196 <__glTexImage1D_size+0x96>
movl   $0x3,-0x14(%rbp)
jmp    1196 <__glTexImage1D_size+0x96>
movl   $0x4,-0x14(%rbp)
jmp    1196 <__glTexImage1D_size+0x96>
movl   $0x0,-0x4(%rbp)
jmp    1265 <__glTexImage1D_size+0x165>
mov    -0xc(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x1b,%eax
ja     124b <__glTexImage1D_size+0x14b>
mov    -0x28(%rbp),%rax
lea    0xe82(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x98,-0x8(%rbp)
jne    11e2 <__glTexImage1D_size+0xe2>
mov    -0x10(%rbp),%eax
add    $0x7,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1265 <__glTexImage1D_size+0x165>
movl   $0x0,-0x4(%rbp)
jmp    1265 <__glTexImage1D_size+0x165>
movl   $0x1,-0x18(%rbp)
jmp    1257 <__glTexImage1D_size+0x157>
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    1257 <__glTexImage1D_size+0x157>
movl   $0x2,-0x18(%rbp)
jmp    1257 <__glTexImage1D_size+0x157>
movl   $0x2,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    1257 <__glTexImage1D_size+0x157>
movl   $0x4,-0x18(%rbp)
jmp    1257 <__glTexImage1D_size+0x157>
movl   $0x4,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    1257 <__glTexImage1D_size+0x157>
movl   $0x0,-0x4(%rbp)
jmp    1265 <__glTexImage1D_size+0x165>
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__glTexImage1D_size>:
xor    %eax,%eax
test   %edx,%edx
js     1183 <__glTexImage1D_size+0x83>
lea    -0x90(%rdi),%r8d
cmp    $0xd,%r8d
ja     1183 <__glTexImage1D_size+0x83>
mov    $0x355f,%ecx
bt     %r8d,%ecx
jae    1183 <__glTexImage1D_size+0x83>
add    $0xffffff80,%esi
cmp    $0x1b,%esi
ja     1183 <__glTexImage1D_size+0x83>
movslq %r8d,%r8
lea    0xf40(%rip),%rcx
mov    (%rcx,%r8,4),%ecx
mov    $0x1,%r8d
lea    0xebf(%rip),%r9
movslq (%r9,%rsi,4),%rsi
add    %r9,%rsi
jmp    *%rsi
mov    $0x2,%r8d
jmp    1158 <__glTexImage1D_size+0x58>
mov    $0x4,%r8d
mov    $0x1,%ecx
jmp    117a <__glTexImage1D_size+0x7a>
mov    $0x4,%r8d
jmp    117a <__glTexImage1D_size+0x7a>
mov    $0x2,%r8d
jmp    117a <__glTexImage1D_size+0x7a>
mov    $0x1,%ecx
mov    $0x1,%r8d
imul   %edx,%ecx
imul   %r8d,%ecx
mov    %ecx,%eax
ret
cmp    $0x98,%edi
jne    1183 <__glTexImage1D_size+0x83>
add    $0x7,%edx
shr    $0x3,%edx
mov    %edx,%eax
ret

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

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