#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*/ v;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ collisions_found(int, int, char const **, void *);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ memcpy(int *, char const *, int);
uint32_t create_fnv_func(int n, const char *strings[], const char *random,
                         size_t size_random, void *mem) {
  const char *last_random;
  uint32_t func = 0;
  if (size_random < sizeof(uint32_t))
    goto done;
  for (last_random = random + size_random - sizeof(uint32_t);
       random <= last_random; random++) {
    uint32_t v;
    memcpy(&v, random, sizeof(v));
    if (v > 0xf000000 && !collisions_found(v, n, strings, mem)) {
      func = v;
      goto done;
    }
  }
done:
  free(mem);
  return func;
}


x86 assembly (clang, -O0):
<create_fnv_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
cmpq   $0x4,-0x20(%rbp)
jae    1162 <create_fnv_func+0x32>
jmp    11e1 <create_fnv_func+0xb1>
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x30(%rbp),%rax
ja     11dc <create_fnv_func+0xac>
mov    -0x18(%rbp),%rsi
lea    -0x38(%rbp),%rdi
mov    $0x4,%edx
call   1050 <memcpy@plt>
cmpl   $0xf000000,-0x38(%rbp)
jle    11c6 <create_fnv_func+0x96>
mov    -0x38(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <collisions_found@plt>
cmp    $0x0,%eax
jne    11c6 <create_fnv_func+0x96>
mov    -0x38(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    11e1 <create_fnv_func+0xb1>
jmp    11cb <create_fnv_func+0x9b>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1172 <create_fnv_func+0x42>
jmp    11e1 <create_fnv_func+0xb1>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_fnv_func>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r12
xor    %r13d,%r13d
cmp    $0x4,%rcx
jb     11b0 <create_fnv_func+0x80>
mov    %rdx,%rbp
lea    (%rdx,%rcx,1),%r14
add    $0xfffffffffffffffc,%r14
cmp    %rdx,%r14
jb     11b0 <create_fnv_func+0x80>
mov    %rsi,%r15
mov    %edi,%ebx
lea    0x4(%rsp),%r13
jmp    1179 <create_fnv_func+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
cmp    %r14,%rbp
ja     11ad <create_fnv_func+0x7d>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
mov    0x4(%rsp),%edi
cmp    $0xf000001,%edi
jl     1170 <create_fnv_func+0x40>
mov    %ebx,%esi
mov    %r15,%rdx
mov    %r12,%rcx
call   1040 <collisions_found@plt>
test   %eax,%eax
jne    1170 <create_fnv_func+0x40>
mov    0x4(%rsp),%r13d
jmp    11b0 <create_fnv_func+0x80>
xor    %r13d,%r13d
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @create_fnv_func(i32 %0, i8** %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i8* %4, i8** %10
store i32 0, i32* %12
%14 = load i64, i64* %9
%15 = icmp ult i64 %14, 4
br i1 %15, label %16, label %17
16: ; preds = %5
br label %45
17: ; preds = %5
%18 = load i8*, i8** %8
%19 = load i64, i64* %9
%20 = getelementptr inbounds i8, i8* %18, i64 %19
%21 = getelementptr inbounds i8, i8* %20, i64 -4
store i8* %21, i8** %11
br label %22
22: ; preds = %41, %17
%23 = load i8*, i8** %8
%24 = load i8*, i8** %11
%25 = icmp ule i8* %23, %24
br i1 %25, label %26, label %44
26: ; preds = %22
%27 = load i8*, i8** %8
%28 = call i32 @memcpy(i32* %13, i8* %27, i32 4)
%29 = load i32, i32* %13
%30 = icmp sgt i32 %29, 251658240
br i1 %30, label %31, label %40
31: ; preds = %26
%32 = load i32, i32* %13
%33 = load i32, i32* %6
%34 = load i8**, i8*** %7
%35 = load i8*, i8** %10
%36 = call i32 @collisions_found(i32 %32, i32 %33, i8** %34, i8* %35)
%37 = icmp ne i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %31
%39 = load i32, i32* %13
store i32 %39, i32* %12
br label %45
40: ; preds = %31, %26
br label %41
41: ; preds = %40
%42 = load i8*, i8** %8
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %8
br label %22
44: ; preds = %22
br label %45
45: ; preds = %44, %38, %16
%46 = load i8*, i8** %10
%47 = call i32 @free(i8* %46)
%48 = load i32, i32* %12
ret i32 %48
}

LLVM IR (-O2):
define i32 @create_fnv_func(i32 %0, i8** %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca i32
%7 = icmp ult i64 %3, 4
br i1 %7, label %27, label %8
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %2, i64 %3
%10 = getelementptr inbounds i8, i8* %9, i64 -4
%11 = icmp ult i8* %10, %2
br i1 %11, label %27, label %12
12: ; preds = %8
%13 = bitcast i32* %6 to i8*
br label %14
14: ; preds = %12, %24
%15 = phi i8* [ %2, %12 ], [ %25, %24 ]
%16 = call i32 @memcpy(i32* %6, i8* %15, i32 4)
%17 = load i32, i32* %6
%18 = icmp sgt i32 %17, 251658240
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = call i32 @collisions_found(i32 %17, i32 %0, i8** %1, i8* %4)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = load i32, i32* %6
br label %27
24: ; preds = %14, %19
%25 = getelementptr inbounds i8, i8* %15, i64 1
%26 = icmp ugt i8* %25, %10
br i1 %26, label %27, label %14
27: ; preds = %24, %8, %22, %5
%28 = phi i32 [ 0, %5 ], [ %23, %22 ], [ 0, %8 ], [ 0, %24 ]
%29 = call i32 @free(i8* %4)
ret i32 %28
}