#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 */

/* Variables and functions */
int /*<<< orphan*/ FreeArrayOfUnits(int **, int);
int **GenerateUnitsArray(int);
int /*<<< orphan*/ printf(char *, ...);
void Validate(int *Board, int sudoku_size) {
  int i, current_block;
  int **array_of_units = GenerateUnitsArray(sudoku_size);
  for (current_block = 0; current_block < 3 * sudoku_size; current_block++) {
    int sum = 0;
    int *array_to_check = array_of_units[current_block];
    for (i = 0; i < sudoku_size; i++) {
      sum += Board[array_to_check[i]];
    }
    printf("Set contains sum of %d\n", sum);
  }
  FreeArrayOfUnits(array_of_units, sudoku_size);
  printf("If every set contains the same sum of values and that is equal to "
         "arithmetic \n");
  printf("progression sum then the sudoku must be correct. \n");
  printf("Validation is also taken into consideration during constraint "
         "propagation \n\n");
}


x86 assembly (clang, -O0):
<Validate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <GenerateUnitsArray@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
imul   $0x3,-0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    11d1 <Validate+0xa1>
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b2 <Validate+0x82>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
movslq -0x10(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117f <Validate+0x4f>
mov    -0x24(%rbp),%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1152 <Validate+0x22>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <FreeArrayOfUnits@plt>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Validate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
call   1030 <GenerateUnitsArray@plt>
mov    %rax,0x10(%rsp)
mov    %rbp,0x8(%rsp)
test   %ebp,%ebp
jle    1225 <Validate+0xe5>
mov    0x8(%rsp),%rcx
lea    (%rcx,%rcx,2),%eax
cmp    $0x2,%eax
mov    $0x1,%r13d
cmovge %eax,%r13d
mov    %ecx,%r12d
lea    -0x1(%r12),%r14
mov    %r12d,%ebp
and    $0x3,%ebp
and    $0xfffffffc,%r12d
xor    %r15d,%r15d
jmp    11b7 <Validate+0x77>
nopl   0x0(%rax,%rax,1)
lea    0xe59(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15
cmp    %r13,%r15
je     1225 <Validate+0xe5>
mov    0x10(%rsp),%rax
mov    (%rax,%r15,8),%rax
xor    %ecx,%ecx
xor    %esi,%esi
cmp    $0x3,%r14
jb     11f8 <Validate+0xb8>
nopw   0x0(%rax,%rax,1)
movslq (%rax,%rcx,4),%rdx
add    (%rbx,%rdx,4),%esi
movslq 0x4(%rax,%rcx,4),%rdx
add    (%rbx,%rdx,4),%esi
movslq 0x8(%rax,%rcx,4),%rdx
add    (%rbx,%rdx,4),%esi
movslq 0xc(%rax,%rcx,4),%rdx
add    (%rbx,%rdx,4),%esi
add    $0x4,%rcx
cmp    %rcx,%r12
jne    11d0 <Validate+0x90>
test   %rbp,%rbp
je     11a0 <Validate+0x60>
lea    (%rax,%rcx,4),%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq (%rax,%rcx,4),%rdx
add    (%rbx,%rdx,4),%esi
add    $0x1,%rcx
cmp    %rcx,%rbp
jne    1210 <Validate+0xd0>
jmp    11a0 <Validate+0x60>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
call   1060 <FreeArrayOfUnits@plt>
lea    0xddd(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe45(%rip),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Set contains sum of %d\0A\00"
@.str.1 = [79 x i8] c"If every set contains the same sum of values and that is equal to arithmetic \0A\00"
@.str.2 = [51 x i8] c"progression sum then the sudoku must be correct. \0A\00"
@.str.3 = [77 x i8] c"Validation is also taken into consideration during constraint propagation \0A\0A\00"
define void @Validate(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32**
%8 = alloca i32
%9 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
%10 = load i32, i32* %4
%11 = call i32** @GenerateUnitsArray(i32 %10)
store i32** %11, i32*** %7
store i32 0, i32* %6
br label %12
12: ; preds = %45, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = mul nsw i32 3, %14
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %48
17: ; preds = %12
store i32 0, i32* %8
%18 = load i32**, i32*** %7
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32*, i32** %18, i64 %20
%22 = load i32*, i32** %21
store i32* %22, i32** %9
store i32 0, i32* %5
br label %23
23: ; preds = %39, %17
%24 = load i32, i32* %5
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %42
27: ; preds = %23
%28 = load i32*, i32** %3
%29 = load i32*, i32** %9
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %28, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %8
%38 = add nsw i32 %37, %36
store i32 %38, i32* %8
br label %39
39: ; preds = %27
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %23
42: ; preds = %23
%43 = load i32, i32* %8
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %42
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
br label %12
48: ; preds = %12
%49 = load i32**, i32*** %7
%50 = load i32, i32* %4
%51 = call i32 @FreeArrayOfUnits(i32** %49, i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.1, i64 0, i64 0))
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Set contains sum of %d\0A\00"
@str = [78 x i8] c"If every set contains the same sum of values and that is equal to arithmetic \00"
@str.4 = [50 x i8] c"progression sum then the sudoku must be correct. \00"
@str.5 = [76 x i8] c"Validation is also taken into consideration during constraint propagation \0A\00"
define void @Validate(i32* nocapture %0, i32 %1) {
%3 = tail call i32** @GenerateUnitsArray(i32 %1)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %75
5: ; preds = %2
%6 = mul i32 %1, 3
%7 = call i32 @llvm.smax.i32(i32 %6, i32 1)
%8 = zext i32 %7 to i64
%9 = zext i32 %1 to i64
%10 = add nsw i64 %9, -1
%11 = and i64 %9, 3
%12 = icmp ult i64 %10, 3
%13 = and i64 %9, 4294967292
%14 = icmp eq i64 %11, 0
br label %15
15: ; preds = %70, %5
%16 = phi i64 [ 0, %5 ], [ %73, %70 ]
%17 = getelementptr inbounds i32*, i32** %3, i64 %16
%18 = load i32*, i32** %17
br i1 %12, label %53, label %19
19: ; preds = %15, %19
%20 = phi i64 [ %50, %19 ], [ 0, %15 ]
%21 = phi i32 [ %49, %19 ], [ 0, %15 ]
%22 = phi i64 [ %51, %19 ], [ 0, %15 ]
%23 = getelementptr inbounds i32, i32* %18, i64 %20
%24 = load i32, i32* %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %0, i64 %25
%27 = load i32, i32* %26
%28 = add nsw i32 %27, %21
%29 = or i64 %20, 1
%30 = getelementptr inbounds i32, i32* %18, i64 %29
%31 = load i32, i32* %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %0, i64 %32
%34 = load i32, i32* %33
%35 = add nsw i32 %34, %28
%36 = or i64 %20, 2
%37 = getelementptr inbounds i32, i32* %18, i64 %36
%38 = load i32, i32* %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %0, i64 %39
%41 = load i32, i32* %40
%42 = add nsw i32 %41, %35
%43 = or i64 %20, 3
%44 = getelementptr inbounds i32, i32* %18, i64 %43
%45 = load i32, i32* %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %0, i64 %46
%48 = load i32, i32* %47
%49 = add nsw i32 %48, %42
%50 = add nuw nsw i64 %20, 4
%51 = add i64 %22, 4
%52 = icmp eq i64 %51, %13
br i1 %52, label %53, label %19
53: ; preds = %19, %15
%54 = phi i32 [ undef, %15 ], [ %49, %19 ]
%55 = phi i64 [ 0, %15 ], [ %50, %19 ]
%56 = phi i32 [ 0, %15 ], [ %49, %19 ]
br i1 %14, label %70, label %57
57: ; preds = %53, %57
%58 = phi i64 [ %67, %57 ], [ %55, %53 ]
%59 = phi i32 [ %66, %57 ], [ %56, %53 ]
%60 = phi i64 [ %68, %57 ], [ 0, %53 ]
%61 = getelementptr inbounds i32, i32* %18, i64 %58
%62 = load i32, i32* %61
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %0, i64 %63
%65 = load i32, i32* %64
%66 = add nsw i32 %65, %59
%67 = add nuw nsw i64 %58, 1
%68 = add i64 %60, 1
%69 = icmp eq i64 %68, %11
br i1 %69, label %70, label %57
70: ; preds = %57, %53
%71 = phi i32 [ %54, %53 ], [ %66, %57 ]
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %71)
%73 = add nuw nsw i64 %16, 1
%74 = icmp eq i64 %73, %8
br i1 %74, label %75, label %15
75: ; preds = %70, %2
%76 = tail call i32 @FreeArrayOfUnits(i32** %3, i32 %1)
%77 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str, i64 0, i64 0))
%78 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.4, i64 0, i64 0))
%79 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @str.5, i64 0, i64 0))
ret void
}