#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 scalar_t__ uint8_t;
typedef int uint16_t;

/* Variables and functions */
int _getNameIndex(scalar_t__ *, size_t);
int _getNameLength(scalar_t__ *, size_t);
size_t _getContentHashLength(uint8_t *buffer, size_t length) {
  int offset =
      _getNameIndex(buffer, length) + _getNameLength(buffer, length) + 2;
  uint16_t len =
      ((uint16_t)(buffer[offset]) << 8) | (uint16_t)(buffer[offset + 1]);
  return (size_t)len;
}


x86 assembly (clang, -O0):
<_getContentHashLength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <_getNameIndex@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <_getNameLength@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
shl    $0x8,%eax
mov    -0x8(%rbp),%rcx
mov    -0x14(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
mov    (%rcx,%rdx,8),%rcx
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_getContentHashLength>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <_getNameIndex@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <_getNameLength@plt>
add    %ebp,%eax
cltq
mov    0x10(%rbx,%rax,8),%ecx
shl    $0x8,%ecx
or     0x18(%rbx,%rax,8),%ecx
movslq %ecx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i64 @_getContentHashLength(i64* %0, i64 %1) {
%3 = alloca i64*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i64* %0, i64** %3
store i64 %1, i64* %4
%7 = load i64*, i64** %3
%8 = load i64, i64* %4
%9 = call i32 @_getNameIndex(i64* %7, i64 %8)
%10 = load i64*, i64** %3
%11 = load i64, i64* %4
%12 = call i32 @_getNameLength(i64* %10, i64 %11)
%13 = add nsw i32 %9, %12
%14 = add nsw i32 %13, 2
store i32 %14, i32* %5
%15 = load i64*, i64** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i64, i64* %15, i64 %17
%19 = load i64, i64* %18
%20 = trunc i64 %19 to i32
%21 = shl i32 %20, 8
%22 = load i64*, i64** %3
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i64, i64* %22, i64 %25
%27 = load i64, i64* %26
%28 = trunc i64 %27 to i32
%29 = or i32 %21, %28
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
ret i64 %31
}

LLVM IR (-O2):
define i64 @_getContentHashLength(i64* %0, i64 %1) {
%3 = tail call i32 @_getNameIndex(i64* %0, i64 %1)
%4 = tail call i32 @_getNameLength(i64* %0, i64 %1)
%5 = add nsw i32 %4, %3
%6 = add nsw i32 %5, 2
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i64, i64* %0, i64 %7
%9 = load i64, i64* %8
%10 = trunc i64 %9 to i32
%11 = shl i32 %10, 8
%12 = add nsw i32 %5, 3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i64, i64* %0, i64 %13
%15 = load i64, i64* %14
%16 = trunc i64 %15 to i32
%17 = or i32 %11, %16
%18 = sext i32 %17 to i64
ret i64 %18
}