#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 */
int GL_BITMAP;
int GL_COLOR_INDEX;
#define GL_PROXY_COLOR_TABLE 139
#define GL_PROXY_HISTOGRAM 138
#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 137
#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 136
#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 135
#define GL_PROXY_TEXTURE_1D 134
#define GL_PROXY_TEXTURE_2D 133
#define GL_PROXY_TEXTURE_3D 132
#define GL_PROXY_TEXTURE_4D_SGIS 131
#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 130
#define GL_PROXY_TEXTURE_CUBE_MAP 129
#define GL_PROXY_TEXTURE_RECTANGLE_ARB 128
int GL_STENCIL_INDEX;
int __glBytesPerElement(int);
int __glElementsPerGroup(int, int);
GLint __glImageSize(GLsizei width, GLsizei height, GLsizei depth, GLenum format,
                    GLenum type, GLenum target) {
  int bytes_per_row;
  int components;
  switch (target) {
  case GL_PROXY_TEXTURE_1D:
  case GL_PROXY_TEXTURE_2D:
  case GL_PROXY_TEXTURE_3D:
  case GL_PROXY_TEXTURE_4D_SGIS:
  case GL_PROXY_TEXTURE_CUBE_MAP:
  case GL_PROXY_TEXTURE_RECTANGLE_ARB:
  case GL_PROXY_HISTOGRAM:
  case GL_PROXY_COLOR_TABLE:
  case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
  case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
  case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
  case GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP:
    return 0;
  }
  if (width < 0 || height < 0 || depth < 0) {
    return 0;
  }
  components = __glElementsPerGroup(format, type);
  if (type == GL_BITMAP) {
    if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) {
      bytes_per_row = (width + 7) >> 3;
    } else {
      return 0;
    }
  } else {
    bytes_per_row = __glBytesPerElement(type) * width;
  }
  return bytes_per_row * height * depth * components;
}


x86 assembly (clang, -O0):
<__glImageSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffff80,%eax
sub    $0xb,%eax
ja     115c <__glImageSize+0x3c>
jmp    1150 <__glImageSize+0x30>
movl   $0x0,-0x4(%rbp)
jmp    120d <__glImageSize+0xed>
cmpl   $0x0,-0x8(%rbp)
jl     117a <__glImageSize+0x5a>
cmpl   $0x0,-0xc(%rbp)
jl     117a <__glImageSize+0x5a>
cmpl   $0x0,-0x10(%rbp)
jge    1186 <__glImageSize+0x66>
movl   $0x0,-0x4(%rbp)
jmp    120d <__glImageSize+0xed>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <__glElementsPerGroup@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e4a(%rip),%rcx
cmp    (%rcx),%eax
jne    11ec <__glImageSize+0xcc>
mov    -0x14(%rbp),%eax
mov    0x2e28(%rip),%rcx
cmp    (%rcx),%eax
je     11ca <__glImageSize+0xaa>
mov    -0x14(%rbp),%eax
mov    0x2e1e(%rip),%rcx
cmp    (%rcx),%eax
jne    11db <__glImageSize+0xbb>
mov    -0x8(%rbp),%eax
add    $0x7,%eax
sar    $0x3,%eax
mov    %eax,-0x20(%rbp)
jmp    11e7 <__glImageSize+0xc7>
movl   $0x0,-0x4(%rbp)
jmp    120d <__glImageSize+0xed>
jmp    11fb <__glImageSize+0xdb>
mov    -0x18(%rbp),%edi
call   1040 <__glBytesPerElement@plt>
imul   -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__glImageSize>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
add    $0xffffff80,%r9d
xor    %ebp,%ebp
cmp    $0xc,%r9d
jb     11a4 <__glImageSize+0x84>
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%r15d
mov    %esi,%eax
or     %edi,%eax
or     %edx,%eax
js     11a4 <__glImageSize+0x84>
mov    %r8d,%r12d
mov    %ecx,%r13d
mov    %ecx,%edi
mov    %r8d,%esi
call   1030 <__glElementsPerGroup@plt>
mov    %eax,%ecx
mov    0x2e88(%rip),%rax
cmp    %r12d,(%rax)
jne    1187 <__glImageSize+0x67>
mov    0x2e6c(%rip),%rax
cmp    %r13d,(%rax)
je     117d <__glImageSize+0x5d>
mov    0x2e68(%rip),%rax
cmp    %r13d,(%rax)
jne    11a4 <__glImageSize+0x84>
add    $0x7,%r15d
sar    $0x3,%r15d
jmp    1197 <__glImageSize+0x77>
mov    %r12d,%edi
mov    %ecx,%ebp
call   1040 <__glBytesPerElement@plt>
mov    %ebp,%ecx
imul   %eax,%r15d
imul   %r14d,%ebx
imul   %ecx,%ebx
imul   %r15d,%ebx
mov    %ebx,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GL_BITMAP = global i32 0
@GL_COLOR_INDEX = global i32 0
@GL_STENCIL_INDEX = global i32 0
define i32 @__glImageSize(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
%16 = load i32, i32* %13
switch i32 %16, label %18 [
i32 134, label %17
i32 133, label %17
i32 132, label %17
i32 131, label %17
i32 129, label %17
i32 128, label %17
i32 138, label %17
i32 139, label %17
i32 130, label %17
i32 136, label %17
i32 137, label %17
i32 135, label %17
]
17: ; preds = %6, %6, %6, %6, %6, %6, %6, %6, %6, %6, %6, %6
store i32 0, i32* %7
br label %62
18: ; preds = %6
%19 = load i32, i32* %8
%20 = icmp slt i32 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %18
%22 = load i32, i32* %9
%23 = icmp slt i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i32, i32* %10
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %24, %21, %18
store i32 0, i32* %7
br label %62
28: ; preds = %24
%29 = load i32, i32* %11
%30 = load i32, i32* %12
%31 = call i32 @__glElementsPerGroup(i32 %29, i32 %30)
store i32 %31, i32* %15
%32 = load i32, i32* %12
%33 = load i32, i32* @GL_BITMAP
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %49
35: ; preds = %28
%36 = load i32, i32* %11
%37 = load i32, i32* @GL_COLOR_INDEX
%38 = icmp eq i32 %36, %37
br i1 %38, label %43, label %39
39: ; preds = %35
%40 = load i32, i32* %11
%41 = load i32, i32* @GL_STENCIL_INDEX
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %47
43: ; preds = %39, %35
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 7
%46 = ashr i32 %45, 3
store i32 %46, i32* %14
br label %48
47: ; preds = %39
store i32 0, i32* %7
br label %62
48: ; preds = %43
br label %54
49: ; preds = %28
%50 = load i32, i32* %12
%51 = call i32 @__glBytesPerElement(i32 %50)
%52 = load i32, i32* %8
%53 = mul nsw i32 %51, %52
store i32 %53, i32* %14
br label %54
54: ; preds = %49, %48
%55 = load i32, i32* %14
%56 = load i32, i32* %9
%57 = mul nsw i32 %55, %56
%58 = load i32, i32* %10
%59 = mul nsw i32 %57, %58
%60 = load i32, i32* %15
%61 = mul nsw i32 %59, %60
store i32 %61, i32* %7
br label %62
62: ; preds = %54, %47, %27, %17
%63 = load i32, i32* %7
ret i32 %63
}

LLVM IR (-O2):
@GL_BITMAP = global i32 0
@GL_COLOR_INDEX = global i32 0
@GL_STENCIL_INDEX = global i32 0
define i32 @__glImageSize(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = add i32 %5, -128
%8 = icmp ult i32 %7, 12
br i1 %8, label %34, label %9
9: ; preds = %6
%10 = or i32 %1, %0
%11 = or i32 %10, %2
%12 = icmp sgt i32 %11, -1
br i1 %12, label %13, label %34
13: ; preds = %9
%14 = tail call i32 @__glElementsPerGroup(i32 %3, i32 %4)
%15 = load i32, i32* @GL_BITMAP
%16 = icmp eq i32 %15, %4
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i32, i32* @GL_COLOR_INDEX
%19 = icmp eq i32 %18, %3
%20 = load i32, i32* @GL_STENCIL_INDEX
%21 = icmp eq i32 %20, %3
%22 = select i1 %19, i1 true, i1 %21
br i1 %22, label %23, label %34
23: ; preds = %17
%24 = add nsw i32 %0, 7
%25 = ashr i32 %24, 3
br label %29
26: ; preds = %13
%27 = tail call i32 @__glBytesPerElement(i32 %4)
%28 = mul nsw i32 %27, %0
br label %29
29: ; preds = %26, %23
%30 = phi i32 [ %25, %23 ], [ %28, %26 ]
%31 = mul i32 %2, %1
%32 = mul i32 %31, %14
%33 = mul i32 %32, %30
br label %34
34: ; preds = %17, %9, %6, %29
%35 = phi i32 [ %33, %29 ], [ 0, %6 ], [ 0, %9 ], [ 0, %17 ]
ret i32 %35
}