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

/* Variables and functions */
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_import(int /*<<< orphan*/, size_t, int, int, int,
                              int /*<<< orphan*/, scalar_t__ *);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ number_checks(int /*<<< orphan*/, size_t, size_t);
int find_numbers(uint8_t *data, size_t len, size_t bits, uint8_t align,
                 uint8_t endian_flags) {
  mpz_t n;
  size_t i;
  mpz_init(n);
  for (i = 0; i <= (len - bits / 8); i += align) {
    mpz_import(n, bits / 8, 1, 1, 1, 0, data + i);
    number_checks(n, bits, i);
    mpz_import(n, bits / 8, -1, 1, 1, 0, data + i);
    number_checks(n, bits, i);
  }
  mpz_clear(n);
  return 0;
}


x86 assembly (clang, -O0):
<find_numbers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
call   1040 <mpz_init@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rdx
shr    $0x3,%rdx
sub    %rdx,%rcx
cmp    %rcx,%rax
ja     121f <find_numbers+0xdf>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
shr    $0x3,%rsi
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    $0x1,%r8d
xor    %r9d,%r9d
mov    %r8d,%edx
mov    %r8d,%ecx
mov    %rax,(%rsp)
call   1060 <mpz_import@plt>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1030 <number_checks@plt>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
shr    $0x3,%rsi
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    $0xffffffff,%edx
mov    $0x1,%r8d
xor    %r9d,%r9d
mov    %r8d,%ecx
mov    %rax,(%rsp)
call   1060 <mpz_import@plt>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1030 <number_checks@plt>
mov    -0x20(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    116c <find_numbers+0x2c>
mov    -0x2c(%rbp),%edi
call   1050 <mpz_clear@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_numbers>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1040 <mpz_init@plt>
mov    %r12,%r13
shr    $0x3,%r13
sub    %r13,%rbp
mov    %rbp,0x10(%rsp)
mov    %r14,%r15
lea    0x0(,%r14,8),%r14
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %rbx,(%rsp)
mov    %r13,%rsi
mov    $0x1,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
xor    %r9d,%r9d
call   1060 <mpz_import@plt>
mov    %r12,%rsi
mov    %rbp,%rdx
call   1030 <number_checks@plt>
mov    %rbx,(%rsp)
mov    %r13,%rsi
mov    $0xffffffff,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
xor    %r9d,%r9d
call   1060 <mpz_import@plt>
mov    %r12,%rsi
mov    %rbp,%rdx
call   1030 <number_checks@plt>
add    %r15,%rbp
add    %r14,%rbx
cmp    0x10(%rsp),%rbp
jbe    1180 <find_numbers+0x40>
call   1050 <mpz_clear@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @find_numbers(i64* %0, i64 %1, i64 %2, i64 %3, i64 %4) {
%6 = tail call i32 @mpz_init(i32 undef)
%7 = lshr i64 %2, 3
%8 = sub i64 %1, %7
br label %9
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %16, %9 ]
%11 = getelementptr inbounds i64, i64* %0, i64 %10
%12 = tail call i32 @mpz_import(i32 undef, i64 %7, i32 1, i32 1, i32 1, i32 0, i64* %11)
%13 = tail call i32 @number_checks(i32 undef, i64 %2, i64 %10)
%14 = tail call i32 @mpz_import(i32 undef, i64 %7, i32 -1, i32 1, i32 1, i32 0, i64* %11)
%15 = tail call i32 @number_checks(i32 undef, i64 %2, i64 %10)
%16 = add i64 %10, %3
%17 = icmp ugt i64 %16, %8
br i1 %17, label %18, label %9
18: ; preds = %9
%19 = tail call i32 @mpz_clear(i32 undef)
ret i32 0
}