#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 */
struct ebt_mac_wormhash {
  scalar_t__ *table;
  scalar_t__ poolsize;
};

/* Variables and functions */
int ebt_mac_wormhash_check_integrity(const struct ebt_mac_wormhash *wh) {
  int i;
  for (i = 0; i < 256; i++) {
    if (wh->table[i] > wh->table[i + 1])
      return -0x100 - i;
    if (wh->table[i] < 0)
      return -0x200 - i;
    if (wh->table[i] > wh->poolsize)
      return -0x300 - i;
  }
  if (wh->table[256] > wh->poolsize)
    return -0xc00;
  return 0;
}


x86 assembly (clang, -O0):
<ebt_mac_wormhash_check_integrity>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    11bb <ebt_mac_wormhash_check_integrity+0xbb>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
mov    -0x14(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,8),%rax
jle    1155 <ebt_mac_wormhash_check_integrity+0x55>
mov    $0xffffff00,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ea <ebt_mac_wormhash_check_integrity+0xea>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jge    117b <ebt_mac_wormhash_check_integrity+0x7b>
mov    $0xfffffe00,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ea <ebt_mac_wormhash_check_integrity+0xea>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x10(%rbp),%rcx
cmp    0x8(%rcx),%rax
jle    11a8 <ebt_mac_wormhash_check_integrity+0xa8>
mov    $0xfffffd00,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ea <ebt_mac_wormhash_check_integrity+0xea>
jmp    11ad <ebt_mac_wormhash_check_integrity+0xad>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    110f <ebt_mac_wormhash_check_integrity+0xf>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x800(%rax),%rax
mov    -0x10(%rbp),%rcx
cmp    0x8(%rcx),%rax
jle    11e3 <ebt_mac_wormhash_check_integrity+0xe3>
movl   $0xfffff400,-0x4(%rbp)
jmp    11ea <ebt_mac_wormhash_check_integrity+0xea>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ebt_mac_wormhash_check_integrity>:
mov    (%rdi),%rax
mov    $0xffffffffffffffff,%rcx
nopw   0x0(%rax,%rax,1)
cmp    $0xff,%rcx
je     114d <ebt_mac_wormhash_check_integrity+0x4d>
mov    0x8(%rax,%rcx,8),%rdx
cmp    0x10(%rax,%rcx,8),%rdx
jg     1163 <ebt_mac_wormhash_check_integrity+0x63>
test   %rdx,%rdx
js     1169 <ebt_mac_wormhash_check_integrity+0x69>
cmp    0x8(%rdi),%rdx
jg     1175 <ebt_mac_wormhash_check_integrity+0x75>
mov    0x10(%rax,%rcx,8),%rdx
cmp    0x18(%rax,%rcx,8),%rdx
jg     1181 <ebt_mac_wormhash_check_integrity+0x81>
add    $0x2,%rcx
test   %rdx,%rdx
js     116d <ebt_mac_wormhash_check_integrity+0x6d>
cmp    0x8(%rdi),%rdx
jle    1110 <ebt_mac_wormhash_check_integrity+0x10>
jmp    1179 <ebt_mac_wormhash_check_integrity+0x79>
mov    0x800(%rax),%rax
xor    %ecx,%ecx
cmp    0x8(%rdi),%rax
mov    $0xfffff400,%eax
cmovle %ecx,%eax
ret
add    $0x1,%rcx
jmp    1185 <ebt_mac_wormhash_check_integrity+0x85>
add    $0x1,%rcx
mov    $0xfffffe00,%eax
sub    %ecx,%eax
ret
add    $0x1,%rcx
mov    $0xfffffd00,%eax
sub    %ecx,%eax
ret
add    $0x2,%rcx
mov    $0xffffff00,%eax
sub    %ecx,%eax
ret

LLVM IR (-O0):
%struct.ebt_mac_wormhash = type { i64*, i64 }
define i32 @ebt_mac_wormhash_check_integrity(%struct.ebt_mac_wormhash* %0) {
%2 = alloca i32
%3 = alloca %struct.ebt_mac_wormhash*
%4 = alloca i32
store %struct.ebt_mac_wormhash* %0, %struct.ebt_mac_wormhash** %3
store i32 0, i32* %4
br label %5
5: ; preds = %56, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 256
br i1 %7, label %8, label %59
8: ; preds = %5
%9 = load %struct.ebt_mac_wormhash*, %struct.ebt_mac_wormhash** %3
%10 = getelementptr inbounds %struct.ebt_mac_wormhash, %struct.ebt_mac_wormhash* %9, i32 0, i32 0
%11 = load i64*, i64** %10
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i64, i64* %11, i64 %13
%15 = load i64, i64* %14
%16 = load %struct.ebt_mac_wormhash*, %struct.ebt_mac_wormhash** %3
%17 = getelementptr inbounds %struct.ebt_mac_wormhash, %struct.ebt_mac_wormhash* %16, i32 0, i32 0
%18 = load i64*, i64** %17
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i64, i64* %18, i64 %21
%23 = load i64, i64* %22
%24 = icmp sgt i64 %15, %23
br i1 %24, label %25, label %28
25: ; preds = %8
%26 = load i32, i32* %4
%27 = sub nsw i32 -256, %26
store i32 %27, i32* %2
br label %71
28: ; preds = %8
%29 = load %struct.ebt_mac_wormhash*, %struct.ebt_mac_wormhash** %3
%30 = getelementptr inbounds %struct.ebt_mac_wormhash, %struct.ebt_mac_wormhash* %29, i32 0, i32 0
%31 = load i64*, i64** %30
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i64, i64* %31, i64 %33
%35 = load i64, i64* %34
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %28
%38 = load i32, i32* %4
%39 = sub nsw i32 -512, %38
store i32 %39, i32* %2
br label %71
40: ; preds = %28
%41 = load %struct.ebt_mac_wormhash*, %struct.ebt_mac_wormhash** %3
%42 = getelementptr inbounds %struct.ebt_mac_wormhash, %struct.ebt_mac_wormhash* %41, i32 0, i32 0
%43 = load i64*, i64** %42
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i64, i64* %43, i64 %45
%47 = load i64, i64* %46
%48 = load %struct.ebt_mac_wormhash*, %struct.ebt_mac_wormhash** %3
%49 = getelementptr inbounds %struct.ebt_mac_wormhash, %struct.ebt_mac_wormhash* %48, i32 0, i32 1
%50 = load i64, i64* %49
%51 = icmp sgt i64 %47, %50
br i1 %51, label %52, label %55
52: ; preds = %40
%53 = load i32, i32* %4
%54 = sub nsw i32 -768, %53
store i32 %54, i32* %2
br label %71
55: ; preds = %40
br label %56
56: ; preds = %55
%57 = load i32, i32* %4
%58 = add nsw i32 %57, 1
store i32 %58, i32* %4
br label %5
59: ; preds = %5
%60 = load %struct.ebt_mac_wormhash*, %struct.ebt_mac_wormhash** %3
%61 = getelementptr inbounds %struct.ebt_mac_wormhash, %struct.ebt_mac_wormhash* %60, i32 0, i32 0
%62 = load i64*, i64** %61
%63 = getelementptr inbounds i64, i64* %62, i64 256
%64 = load i64, i64* %63
%65 = load %struct.ebt_mac_wormhash*, %struct.ebt_mac_wormhash** %3
%66 = getelementptr inbounds %struct.ebt_mac_wormhash, %struct.ebt_mac_wormhash* %65, i32 0, i32 1
%67 = load i64, i64* %66
%68 = icmp sgt i64 %64, %67
br i1 %68, label %69, label %70
69: ; preds = %59
store i32 -3072, i32* %2
br label %71
70: ; preds = %59
store i32 0, i32* %2
br label %71
71: ; preds = %70, %69, %52, %37, %25
%72 = load i32, i32* %2
ret i32 %72
}

LLVM IR (-O2):
%struct.ebt_mac_wormhash = type { i64*, i64 }
define i32 @ebt_mac_wormhash_check_integrity(%struct.ebt_mac_wormhash* nocapture %0) {
%2 = getelementptr inbounds %struct.ebt_mac_wormhash, %struct.ebt_mac_wormhash* %0, i64 0, i32 0
%3 = load i64*, i64** %2
%4 = getelementptr inbounds %struct.ebt_mac_wormhash, %struct.ebt_mac_wormhash* %0, i64 0, i32 1
br label %5
5: ; preds = %37, %1
%6 = phi i64 [ 0, %1 ], [ %31, %37 ]
%7 = icmp eq i64 %6, 256
br i1 %7, label %44, label %8
8: ; preds = %5
%9 = getelementptr inbounds i64, i64* %3, i64 %6
%10 = load i64, i64* %9
%11 = or i64 %6, 1
%12 = getelementptr inbounds i64, i64* %3, i64 %11
%13 = load i64, i64* %12
%14 = icmp sgt i64 %10, %13
br i1 %14, label %15, label %19
15: ; preds = %28, %8
%16 = phi i64 [ %6, %8 ], [ %11, %28 ]
%17 = trunc i64 %16 to i32
%18 = sub nuw nsw i32 -256, %17
br label %50
19: ; preds = %8
%20 = icmp slt i64 %10, 0
br i1 %20, label %21, label %25
21: ; preds = %35, %19
%22 = phi i64 [ %6, %19 ], [ %11, %35 ]
%23 = trunc i64 %22 to i32
%24 = sub nuw nsw i32 -512, %23
br label %50
25: ; preds = %19
%26 = load i64, i64* %4
%27 = icmp sgt i64 %10, %26
br i1 %27, label %40, label %28
28: ; preds = %25
%29 = getelementptr inbounds i64, i64* %3, i64 %11
%30 = load i64, i64* %29
%31 = add nuw nsw i64 %6, 2
%32 = getelementptr inbounds i64, i64* %3, i64 %31
%33 = load i64, i64* %32
%34 = icmp sgt i64 %30, %33
br i1 %34, label %15, label %35
35: ; preds = %28
%36 = icmp slt i64 %30, 0
br i1 %36, label %21, label %37
37: ; preds = %35
%38 = load i64, i64* %4
%39 = icmp sgt i64 %30, %38
br i1 %39, label %40, label %5
40: ; preds = %37, %25
%41 = phi i64 [ %6, %25 ], [ %11, %37 ]
%42 = trunc i64 %41 to i32
%43 = sub nuw nsw i32 -768, %42
br label %50
44: ; preds = %5
%45 = getelementptr inbounds i64, i64* %3, i64 256
%46 = load i64, i64* %45
%47 = load i64, i64* %4
%48 = icmp sgt i64 %46, %47
%49 = select i1 %48, i32 -3072, i32 0
br label %50
50: ; preds = %44, %40, %21, %15
%51 = phi i32 [ %18, %15 ], [ %24, %21 ], [ %43, %40 ], [ %49, %44 ]
ret i32 %51
}