user: 请从给定的汇编指令推导出C源代码：

```asm
<__glTexImage2D_size>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  mov    %edx,-0x1c(%rbp)
  mov    %ecx,-0x20(%rbp)
  cmpl   $0x0,-0x1c(%rbp)
  jns    L147
  mov    $0x0,%eax
  jmp    L189
L147:
  cmpl   $0x0,-0x20(%rbp)
  jns    L87
  mov    $0x0,%eax
  jmp    L189
L87:
  mov    -0x14(%rbp),%eax
  sub    $0x90,%eax
  cmp    $0x10,%eax
  ja     L5
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  lea    D0(%rip),%rax
  mov    (%rdx,%rax,1),%eax
  cltq
  lea    D0(%rip),%rdx
  add    %rdx,%rax
  notrack jmp *%rax
  movl   $0x1,-0x8(%rbp)
  jmp    L28
  movl   $0x1,-0x8(%rbp)
  jmp    L28
  movl   $0x2,-0x8(%rbp)
  jmp    L28
  movl   $0x3,-0x8(%rbp)
  jmp    L28
  movl   $0x4,-0x8(%rbp)
  jmp    L28
L5:
  mov    $0x0,%eax
  jmp    L189
L28:
  mov    -0x18(%rbp),%eax
  add    $0xffffff80,%eax
  cmp    $0x1c,%eax
  ja     L9
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  lea    D28(%rip),%rax
  mov    (%rdx,%rax,1),%eax
  cltq
  lea    D28(%rip),%rdx
  add    %rdx,%rax
  notrack jmp *%rax
  cmpl   $0x99,-0x14(%rbp)
  jne    L51
  mov    -0x1c(%rbp),%eax
  add    $0x7,%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  imul   -0x20(%rbp),%eax
  jmp    L189
L51:
  mov    $0x0,%eax
  jmp    L189
  movl   $0x1,-0x4(%rbp)
  jmp    L130
  movl   $0x1,-0x4(%rbp)
  movl   $0x1,-0x8(%rbp)
  jmp    L130
  movl   $0x2,-0x4(%rbp)
  jmp    L130
  movl   $0x2,-0x4(%rbp)
  movl   $0x1,-0x8(%rbp)
  jmp    L130
  movl   $0x4,-0x4(%rbp)
  jmp    L130
  movl   $0x4,-0x4(%rbp)
  movl   $0x1,-0x8(%rbp)
  jmp    L130
L9:
  mov    $0x0,%eax
  jmp    L189
L130:
  mov    -0x8(%rbp),%eax
  imul   -0x4(%rbp),%eax
  imul   -0x1c(%rbp),%eax
  imul   -0x20(%rbp),%eax
L189:
  pop    %rbp
  ret
```

assistant: ```c
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:
  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 (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);
}
```