// File: /workspace/github_c_makefile_star2_O0/vlenhart[P]q3bsp/q3bsp.cpp
// Function: QuakeHeader::LumpInfo(QuakeLumps, void const*, int&, int&)
const void * QuakeHeader::LumpInfo(QuakeLumps lump,
                                 const void *mem,
                                 int &lsize,
                                 int &lcount)
{

  switch ( lump )
  {
   case LUMP_ENTITIES :
      lsize = 1;
      break;

    case Q3_SHADERREFS: // LUMP_SHADERS
      lsize = sizeof(dshader_t); 
      break;
    case Q3_PLANES: // LUMP_PLANES
      lsize = sizeof(float)*4; // size of a plane equations.
      break;
    case Q3_NODES: //LUMP_NODES
      lsize = sizeof(dnode_t); // sizeof(int)*9;
      break;
    case Q3_LEAFS:
      lsize = sizeof(dleaf_t); // sizeof(int)*12;
      break;
    case Q3_FACES:
      lsize = sizeof(int)*26;
      break;
    case Q3_VERTS:
      lsize = sizeof(int)*11;
      break;
    case Q3_LFACES:
      lsize = sizeof(int);
      break;
    case Q3_ELEMS:
      lsize = sizeof(int);
      break;
    case Q3_MODELS:
      lsize = sizeof(int)*10;
      break;
    case Q3_LIGHTMAPS:
      lsize = 1;
      break;
    case Q3_VISIBILITY:
      lsize = 1;
      break;
    default:
      assert( 0 ); // unsupported query type
  }

  int flen = mLumps[lump].GetFileLength();

  assert( flen );
  assert( (flen%lsize) == 0 ); // must be evenly divisible by lump size.
  lcount = flen/lsize; // number of lump items.

  const char *foo = (const char *)mem;
  foo = &foo[ mLumps[lump].GetFileOffset() ];
  return (const void *) foo;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0xc(%rbp), %eax
movq %rax, -0x40(%rbp)
subq $0x10, %rax
ja 0x10061
movq -0x40(%rbp), %rax
leaq 0x19c11(%rip), %rcx     # 0x29bd0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
jmp 0x10080
movq -0x20(%rbp), %rax
movl $0x48, (%rax)
jmp 0x10080
movq -0x20(%rbp), %rax
movl $0x10, (%rax)
jmp 0x10080
movq -0x20(%rbp), %rax
movl $0x24, (%rax)
jmp 0x10080
movq -0x20(%rbp), %rax
movl $0x30, (%rax)
jmp 0x10080
movq -0x20(%rbp), %rax
movl $0x68, (%rax)
jmp 0x10080
movq -0x20(%rbp), %rax
movl $0x2c, (%rax)
jmp 0x10080
movq -0x20(%rbp), %rax
movl $0x4, (%rax)
jmp 0x10080
movq -0x20(%rbp), %rax
movl $0x4, (%rax)
jmp 0x10080
movq -0x20(%rbp), %rax
movl $0x28, (%rax)
jmp 0x10080
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
jmp 0x10080
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
jmp 0x10080
leaq 0x1a03b(%rip), %rdi     # 0x2a0a3
leaq 0x19bc3(%rip), %rsi     # 0x29c32
movl $0xa6, %edx
leaq 0x19beb(%rip), %rcx     # 0x29c66
callq 0x31c0
movq -0x48(%rbp), %rdi
addq $0x8, %rdi
movl -0xc(%rbp), %eax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x124e0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x100a2
jmp 0x100c1
leaq 0x19c07(%rip), %rdi     # 0x29cb0
leaq 0x19b82(%rip), %rsi     # 0x29c32
movl $0xab, %edx
leaq 0x19baa(%rip), %rcx     # 0x29c66
callq 0x31c0
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
cltd
idivl (%rcx)
cmpl $0x0, %edx
jne 0x100d2
jmp 0x100f1
leaq 0x19bdc(%rip), %rdi     # 0x29cb5
leaq 0x19b52(%rip), %rsi     # 0x29c32
movl $0xac, %edx
leaq 0x19b7a(%rip), %rcx     # 0x29c66
callq 0x31c0
movq -0x48(%rbp), %rdi
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
cltd
idivl (%rcx)
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
addq $0x8, %rdi
movl -0xc(%rbp), %eax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x12500
movl %eax, %ecx
movq -0x50(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)