#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 /*<<< orphan*/ uint32_t;

/* Variables and functions */
int INT_MAX;
int /*<<< orphan*/ MurmurHash3_x86_32(void const *, int, int,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, size_t);
int /*<<< orphan*/ stderr;
uint32_t hash(const void *buf, size_t len) {
  uint32_t hashcode;
  if (len > (size_t)INT_MAX) {
    fprintf(stderr, "Maximum line length (%d) exceeded: %zu.\n", INT_MAX, len);
    exit(1);
  }
  MurmurHash3_x86_32(buf, (int)len, (0x5ca1ab1e), &hashcode);
  return hashcode;
}


x86 assembly (clang, -O0):
<hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2e9d(%rip),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rax
jbe    1183 <hash+0x53>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rcx
lea    0xe8c(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %eax,%esi
mov    $0x5ca1ab1e,%edx
lea    -0x14(%rbp),%rcx
call   1040 <MurmurHash3_x86_32@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash>:
push   %rax
mov    %rsi,%rax
mov    0x2ead(%rip),%rcx
movslq (%rcx),%rdx
cmp    %rsi,%rdx
jb     115a <hash+0x2a>
lea    0x4(%rsp),%rcx
mov    %eax,%esi
mov    $0x5ca1ab1e,%edx
call   1040 <MurmurHash3_x86_32@plt>
mov    0x4(%rsp),%eax
pop    %rcx
ret
mov    0x2e77(%rip),%rcx
mov    (%rcx),%edi
lea    0xe96(%rip),%rsi
mov    %rax,%rcx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@INT_MAX = global i32 0
@stderr = global i32 0
@.str = [41 x i8] c"Maximum line length (%d) exceeded: %zu.\0A\00"
define i32 @hash(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i64, i64* %4
%7 = load i32, i32* @INT_MAX
%8 = sext i32 %7 to i64
%9 = icmp ugt i64 %6, %8
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i32, i32* @INT_MAX
%13 = load i64, i64* %4
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %12, i64 %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8*, i8** %3
%18 = load i64, i64* %4
%19 = trunc i64 %18 to i32
%20 = call i32 @MurmurHash3_x86_32(i8* %17, i32 %19, i32 1554098974, i32* %5)
%21 = load i32, i32* %5
ret i32 %21
}

LLVM IR (-O2):
@INT_MAX = global i32 0
@stderr = global i32 0
@.str = [41 x i8] c"Maximum line length (%d) exceeded: %zu.\0A\00"
define i32 @hash(i8* %0, i64 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i32, i32* @INT_MAX
%6 = sext i32 %5 to i64
%7 = icmp ult i64 %6, %1
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %5, i64 %1)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = trunc i64 %1 to i32
%14 = call i32 @MurmurHash3_x86_32(i8* %0, i32 %13, i32 1554098974, i32* %3)
%15 = load i32, i32* %3
ret i32 %15
}