#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 /*<<< orphan*/ EhPrepare(void *, void *);
int EhSolver(void *, int /*<<< orphan*/);
int SolverFunction(void *context, const unsigned char *input,
                   bool (*validBlock)(void *, const unsigned char *),
                   void *validBlockData, bool (*cancelled)(void *),
                   void *cancelledData, int numThreads, int n, int k) {
  int numsolutions, i;
  EhPrepare(context, (void *)input);
  numsolutions = EhSolver(context, *(uint32_t *)(input + 136));
  for (i = 0; i < numsolutions; i++) {
    validBlock(validBlockData, (unsigned char *)(context + 1344 * i));
  }
  return numsolutions;
}


x86 assembly (clang, -O0):
<SolverFunction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <EhPrepare@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x88(%rax),%esi
call   1040 <EhSolver@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11a8 <SolverFunction+0x88>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
imul   $0x540,-0x38(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rsi
call   *%rax
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1173 <SolverFunction+0x53>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SolverFunction>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1030 <EhPrepare@plt>
mov    0x88(%rbp),%esi
mov    %rbx,%rdi
call   1040 <EhSolver@plt>
mov    %eax,%r12d
test   %eax,%eax
jle    1176 <SolverFunction+0x56>
mov    %r12d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   *%r15
add    $0x540,%rbx
add    $0xffffffffffffffff,%rbp
jne    1160 <SolverFunction+0x40>
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @SolverFunction(i8* %0, i8* %1, i32 (i8*, i8*)* %2, i8* %3, i32 (i8*)* %4, i8* %5, i32 %6, i32 %7, i32 %8) {
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32 (i8*, i8*)*
%13 = alloca i8*
%14 = alloca i32 (i8*)*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i8* %0, i8** %10
store i8* %1, i8** %11
store i32 (i8*, i8*)* %2, i32 (i8*, i8*)** %12
store i8* %3, i8** %13
store i32 (i8*)* %4, i32 (i8*)** %14
store i8* %5, i8** %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store i32 %8, i32* %18
%21 = load i8*, i8** %10
%22 = load i8*, i8** %11
%23 = call i32 @EhPrepare(i8* %21, i8* %22)
%24 = load i8*, i8** %10
%25 = load i8*, i8** %11
%26 = getelementptr inbounds i8, i8* %25, i64 136
%27 = bitcast i8* %26 to i32*
%28 = load i32, i32* %27
%29 = call i32 @EhSolver(i8* %24, i32 %28)
store i32 %29, i32* %19
store i32 0, i32* %20
br label %30
30: ; preds = %43, %9
%31 = load i32, i32* %20
%32 = load i32, i32* %19
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %46
34: ; preds = %30
%35 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %12
%36 = load i8*, i8** %13
%37 = load i8*, i8** %10
%38 = load i32, i32* %20
%39 = mul nsw i32 1344, %38
%40 = sext i32 %39 to i64
%41 = getelementptr i8, i8* %37, i64 %40
%42 = call i32 %35(i8* %36, i8* %41)
br label %43
43: ; preds = %34
%44 = load i32, i32* %20
%45 = add nsw i32 %44, 1
store i32 %45, i32* %20
br label %30
46: ; preds = %30
%47 = load i32, i32* %19
ret i32 %47
}

LLVM IR (-O2):
define i32 @SolverFunction(i8* %0, i8* %1, i32 (i8*, i8*)* nocapture %2, i8* %3, i32 (i8*)* nocapture readnone %4, i8* nocapture readnone %5, i32 %6, i32 %7, i32 %8) {
%10 = tail call i32 @EhPrepare(i8* %0, i8* %1)
%11 = getelementptr inbounds i8, i8* %1, i64 136
%12 = bitcast i8* %11 to i32*
%13 = load i32, i32* %12
%14 = tail call i32 @EhSolver(i8* %0, i32 %13)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %9
%17 = zext i32 %14 to i64
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 0, %16 ], [ %23, %18 ]
%20 = mul nuw nsw i64 %19, 1344
%21 = getelementptr i8, i8* %0, i64 %20
%22 = tail call i32 %2(i8* %3, i8* %21)
%23 = add nuw nsw i64 %19, 1
%24 = icmp eq i64 %23, %17
br i1 %24, label %25, label %18
25: ; preds = %18, %9
ret i32 %14
}