#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 GLint;
typedef int GLenum;

/* Variables and functions */
#define GL_ABGR_EXT 158
#define GL_ALPHA 157
#define GL_BGR 156
#define GL_BGRA 155
#define GL_BLUE 154
#define GL_BYTE 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 __glGetTexImage_size(GLenum target, GLint level, GLenum format,
                           GLenum type, GLint width, GLint height,
                           GLint depth) {
  GLint elements, esize;
  GLint padding, rowsize;
  switch (format) {
  case GL_RGBA:
  case GL_BGRA:
  case GL_ABGR_EXT:
    elements = 4;
    break;
  case GL_RGB:
  case GL_BGR:
    elements = 3;
    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;
  default:
    return -1;
  }
  switch (type) {
  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 -1;
  }
  rowsize = width * elements * esize;
  padding = rowsize % 4;
  if (padding) {
    rowsize += 4 - padding;
  }
  return (rowsize * height * depth);
}


x86 assembly (clang, -O0):
<__glGetTexImage_size>:
push   %rbp
mov    %rsp,%rbp
mov    0x10(%rbp),%eax
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    -0x10(%rbp),%eax
add    $0xffffff70,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0xe,%eax
ja     1176 <__glGetTexImage_size+0x76>
mov    -0x38(%rbp),%rax
lea    0xec3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x4,-0x20(%rbp)
jmp    1182 <__glGetTexImage_size+0x82>
movl   $0x3,-0x20(%rbp)
jmp    1182 <__glGetTexImage_size+0x82>
movl   $0x1,-0x20(%rbp)
jmp    1182 <__glGetTexImage_size+0x82>
movl   $0x2,-0x20(%rbp)
jmp    1182 <__glGetTexImage_size+0x82>
movl   $0xffffffff,-0x4(%rbp)
jmp    1256 <__glGetTexImage_size+0x156>
mov    -0x14(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x19,%eax
ja     1208 <__glGetTexImage_size+0x108>
mov    -0x40(%rbp),%rax
lea    0xe9a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x24(%rbp)
jmp    1214 <__glGetTexImage_size+0x114>
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    1214 <__glGetTexImage_size+0x114>
movl   $0x2,-0x24(%rbp)
jmp    1214 <__glGetTexImage_size+0x114>
movl   $0x2,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    1214 <__glGetTexImage_size+0x114>
movl   $0x4,-0x24(%rbp)
jmp    1214 <__glGetTexImage_size+0x114>
movl   $0x4,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    1214 <__glGetTexImage_size+0x114>
movl   $0xffffffff,-0x4(%rbp)
jmp    1256 <__glGetTexImage_size+0x156>
mov    -0x18(%rbp),%eax
imul   -0x20(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     1248 <__glGetTexImage_size+0x148>
mov    $0x4,%eax
sub    -0x28(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x1c(%rbp),%eax
imul   0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__glGetTexImage_size>:
add    $0xffffff70,%edx
mov    $0xffffffff,%eax
cmp    $0xe,%edx
ja     11a8 <__glGetTexImage_size+0xa8>
mov    $0x7cbf,%esi
bt     %edx,%esi
jae    11a8 <__glGetTexImage_size+0xa8>
add    $0xffffff80,%ecx
cmp    $0x19,%ecx
ja     11a8 <__glGetTexImage_size+0xa8>
movslq %edx,%rdx
lea    0xf34(%rip),%rsi
mov    (%rsi,%rdx,4),%edx
mov    $0x1,%esi
lea    0xebd(%rip),%rdi
movslq (%rdi,%rcx,4),%rcx
add    %rdi,%rcx
jmp    *%rcx
mov    $0x2,%esi
jmp    1158 <__glGetTexImage_size+0x58>
mov    $0x4,%esi
mov    $0x1,%edx
jmp    1177 <__glGetTexImage_size+0x77>
mov    $0x4,%esi
jmp    1177 <__glGetTexImage_size+0x77>
mov    $0x1,%edx
mov    $0x1,%esi
jmp    1177 <__glGetTexImage_size+0x77>
mov    $0x2,%esi
imul   %r8d,%edx
imul   %esi,%edx
lea    0x3(%rdx),%eax
test   %edx,%edx
cmovns %edx,%eax
and    $0xfffffffc,%eax
mov    %edx,%ecx
sub    %eax,%ecx
mov    $0x4,%eax
sub    %ecx,%eax
test   %ecx,%ecx
cmove  %ecx,%eax
add    %edx,%eax
imul   0x8(%rsp),%r9d
imul   %eax,%r9d
mov    %r9d,%eax
ret

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

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