#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 */

/* Variables and functions */
int /*<<< orphan*/ MD5(unsigned char *, int, unsigned char *);
int MD5_DIGEST_LENGTH;
unsigned short carbon_hashpos(const char *key, const char *end) {
  unsigned char md5[MD5_DIGEST_LENGTH];
  MD5((unsigned char *)key, end - key, md5);
  return ((md5[0] << 8) + md5[1]);
}


x86 assembly (clang, -O0):
<carbon_hashpos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2eb9(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x28(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1030 <MD5@plt>
mov    -0x28(%rbp),%rcx
movzbl (%rcx),%eax
shl    $0x8,%eax
movzbl 0x1(%rcx),%ecx
add    %ecx,%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
movzwl %ax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<carbon_hashpos>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    0x2ec2(%rip),%rax
mov    (%rax),%ebx
mov    %rsp,%r14
add    $0xf,%rbx
and    $0xfffffffffffffff0,%rbx
mov    %r14,%rdx
sub    %rbx,%rdx
mov    %rdx,%rsp
neg    %rbx
sub    %edi,%esi
call   1030 <MD5@plt>
movzwl (%r14,%rbx,1),%eax
rol    $0x8,%ax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@MD5_DIGEST_LENGTH = global i32 0
define zeroext i16 @carbon_hashpos(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i32, i32* @MD5_DIGEST_LENGTH
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %5
%10 = alloca i8, i64 %8
store i64 %8, i64* %6
%11 = load i8*, i8** %3
%12 = load i8*, i8** %4
%13 = load i8*, i8** %3
%14 = ptrtoint i8* %12 to i64
%15 = ptrtoint i8* %13 to i64
%16 = sub i64 %14, %15
%17 = trunc i64 %16 to i32
%18 = call i32 @MD5(i8* %11, i32 %17, i8* %10)
%19 = getelementptr inbounds i8, i8* %10, i64 0
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = shl i32 %21, 8
%23 = getelementptr inbounds i8, i8* %10, i64 1
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = add nsw i32 %22, %25
%27 = trunc i32 %26 to i16
%28 = load i8*, i8** %5
ret i16 %27
}

LLVM IR (-O2):
@MD5_DIGEST_LENGTH = global i32 0
define zeroext i16 @carbon_hashpos(i8* %0, i8* %1) {
%3 = load i32, i32* @MD5_DIGEST_LENGTH
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = ptrtoint i8* %1 to i64
%7 = ptrtoint i8* %0 to i64
%8 = sub i64 %6, %7
%9 = trunc i64 %8 to i32
%10 = call i32 @MD5(i8* %0, i32 %9, i8* %5)
%11 = load i8, i8* %5
%12 = zext i8 %11 to i16
%13 = shl nuw i16 %12, 8
%14 = getelementptr inbounds i8, i8* %5, i64 1
%15 = load i8, i8* %14
%16 = zext i8 %15 to i16
%17 = or i16 %13, %16
ret i16 %17
}