#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 __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:
  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 (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    $0x10,%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    $0x1c,%eax
ja     124b <__glTexImage1D_size+0x14b>
mov    -0x28(%rbp),%rax
lea    0xe8e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x99,-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    $0x10,%r8d
ja     1183 <__glTexImage1D_size+0x83>
mov    $0x1eabf,%ecx
bt     %r8d,%ecx
jae    1183 <__glTexImage1D_size+0x83>
add    $0xffffff80,%esi
cmp    $0x1c,%esi
ja     1183 <__glTexImage1D_size+0x83>
movslq %r8d,%r8
lea    0xf44(%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    $0x99,%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 153, label %15
i32 146, label %16
i32 151, label %16
i32 155, label %16
i32 159, label %16
i32 148, label %16
i32 149, label %16
i32 147, label %17
i32 145, label %18
i32 158, label %18
i32 144, label %19
i32 157, label %19
i32 160, label %19
]
15: ; preds = %13
store i32 1, i32* %8
br label %21
16: ; preds = %13, %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, %13
store i32 3, i32* %8
br label %21
19: ; preds = %13, %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 156, label %23
i32 154, 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 150, label %35
i32 139, label %35
i32 152, 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, 153
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 = [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 @__glTexImage1D_size(i32 %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %2, 0
br i1 %4, label %31, label %5
5: ; preds = %3
%6 = add i32 %0, -144
%7 = icmp ult i32 %6, 17
br i1 %7, label %8, label %31
8: ; preds = %5
%9 = lshr i32 125631, %6
%10 = and i32 %9, 1
%11 = icmp eq i32 %10, 0
br i1 %11, label %31, label %12
12: ; preds = %8
%13 = sext i32 %6 to i64
%14 = getelementptr inbounds [17 x i32], [17 x i32]* @switch.table.__glTexImage1D_size, i64 0, i64 %13
%15 = load i32, i32* %14
switch i32 %1, label %31 [
i32 156, label %16
i32 154, label %26
i32 142, label %26
i32 140, label %21
i32 141, label %21
i32 143, label %22
i32 134, label %22
i32 129, label %23
i32 128, label %23
i32 132, label %23
i32 131, label %23
i32 130, label %23
i32 133, label %23
i32 150, label %24
i32 139, label %24
i32 152, label %24
i32 136, label %25
i32 135, label %25
i32 138, label %25
i32 137, label %25
]
16: ; preds = %12
%17 = icmp eq i32 %0, 153
br i1 %17, label %18, label %31
18: ; preds = %16
%19 = add nuw nsw i32 %2, 7
%20 = lshr i32 %19, 3
br label %31
21: ; preds = %12, %12
br label %26
22: ; preds = %12, %12
br label %26
23: ; preds = %12, %12, %12, %12, %12, %12
br label %26
24: ; preds = %12, %12, %12
br label %26
25: ; preds = %12, %12, %12, %12
br label %26
26: ; preds = %12, %12, %25, %24, %23, %22, %21
%27 = phi i32 [ 1, %25 ], [ %15, %24 ], [ 1, %23 ], [ %15, %22 ], [ 1, %21 ], [ %15, %12 ], [ %15, %12 ]
%28 = phi i32 [ 4, %25 ], [ 4, %24 ], [ 2, %23 ], [ 2, %22 ], [ 1, %21 ], [ 1, %12 ], [ 1, %12 ]
%29 = mul i32 %27, %2
%30 = mul i32 %29, %28
br label %31
31: ; preds = %8, %5, %12, %16, %3, %26, %18
%32 = phi i32 [ %30, %26 ], [ %20, %18 ], [ 0, %3 ], [ 0, %5 ], [ 0, %16 ], [ 0, %12 ], [ 0, %8 ]
ret i32 %32
}