#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*/ grouping_algorithm(int, int, char *);
scalar_t__ new_puzzle(char *);
int /*<<< orphan*/ print_target_grid_valid_values(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
char *grouping_algorithm_test() {
  char *test_puzzle = "test/resources/grouping_algorithm.puzzle";
  if (new_puzzle(test_puzzle)) {
    print_target_grid_valid_values(test_puzzle);
    for (int choice = 1; choice <= 3; ++choice) {
      puts("=-=-=-Choice=-=-=-");
      char *choice_array[] = {"Row", "Column", "Chamber"};
      int choice_index = choice - 1;
      printf("Choice: %s\n", choice_array[choice_index]);
      for (int choice_index = 0; choice_index < 9; ++choice_index) {
        printf("Choice_index: %i\n", choice_index);
        grouping_algorithm(choice, choice_index, test_puzzle);
      }
    }
    print_target_grid_valid_values(test_puzzle);
  }
  return 0;
}


x86 assembly (clang, -O0):
<grouping_algorithm_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xea1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <new_puzzle@plt>
cmp    $0x0,%rax
je     1238 <grouping_algorithm_test+0xe8>
mov    -0x8(%rbp),%rdi
call   1070 <print_target_grid_valid_values@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jg     122f <grouping_algorithm_test+0xdf>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
mov    0x2c5d(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c5a(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2c57(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x38(%rbp)
cmpl   $0x9,-0x38(%rbp)
jge    121c <grouping_algorithm_test+0xcc>
mov    -0x38(%rbp),%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0x38(%rbp),%esi
mov    -0x8(%rbp),%rdx
call   1040 <grouping_algorithm@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11e4 <grouping_algorithm_test+0x94>
jmp    1221 <grouping_algorithm_test+0xd1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1186 <grouping_algorithm_test+0x36>
mov    -0x8(%rbp),%rdi
call   1070 <print_target_grid_valid_values@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grouping_algorithm_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%rdi
call   1060 <new_puzzle@plt>
test   %rax,%rax
je     12e2 <grouping_algorithm_test+0x192>
lea    0xe89(%rip),%r12
mov    %r12,%rdi
call   1070 <print_target_grid_valid_values@plt>
mov    $0x1,%ebp
lea    0xee5(%rip),%r13
lea    0xebd(%rip),%r15
lea    0xec2(%rip),%rbx
xor    %r14d,%r14d
nopl   0x0(%rax)
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
movslq (%r14,%r13,1),%rsi
add    %r13,%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
xor    %esi,%esi
mov    %r12,%rdx
call   1040 <grouping_algorithm@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    $0x1,%esi
mov    %r12,%rdx
call   1040 <grouping_algorithm@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    $0x2,%esi
mov    %r12,%rdx
call   1040 <grouping_algorithm@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    $0x3,%esi
mov    %r12,%rdx
call   1040 <grouping_algorithm@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    $0x4,%esi
mov    %r12,%rdx
call   1040 <grouping_algorithm@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    $0x5,%esi
mov    %r12,%rdx
call   1040 <grouping_algorithm@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    $0x6,%esi
mov    %r12,%rdx
call   1040 <grouping_algorithm@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    $0x7,%esi
mov    %r12,%rdx
call   1040 <grouping_algorithm@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    $0x8,%esi
mov    %r12,%rdx
call   1040 <grouping_algorithm@plt>
add    $0x1,%ebp
add    $0x4,%r14
cmp    $0xc,%r14
jne    11a0 <grouping_algorithm_test+0x50>
lea    0xd23(%rip),%rdi
call   1070 <print_target_grid_valid_values@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"test/resources/grouping_algorithm.puzzle\00"
@.str.1 = [19 x i8] c"=-=-=-Choice=-=-=-\00"
@.str.2 = [4 x i8] c"Row\00"
@.str.3 = [7 x i8] c"Column\00"
@.str.4 = [8 x i8] c"Chamber\00"
@__const.grouping_algorithm_test.choice_array = [3 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0)]
@.str.5 = [12 x i8] c"Choice: %s\0A\00"
@.str.6 = [18 x i8] c"Choice_index: %i\0A\00"
define i8* @grouping_algorithm_test() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca [3 x i8*]
%4 = alloca i32
%5 = alloca i32
store i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8** %1
%6 = load i8*, i8** %1
%7 = call i64 @new_puzzle(i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %45
9: ; preds = %0
%10 = load i8*, i8** %1
%11 = call i32 @print_target_grid_valid_values(i8* %10)
store i32 1, i32* %2
br label %12
12: ; preds = %39, %9
%13 = load i32, i32* %2
%14 = icmp sle i32 %13, 3
br i1 %14, label %15, label %42
15: ; preds = %12
%16 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%17 = bitcast [3 x i8*]* %3 to i8*
%18 = load i32, i32* %2
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %23)
store i32 0, i32* %5
br label %25
25: ; preds = %35, %15
%26 = load i32, i32* %5
%27 = icmp slt i32 %26, 9
br i1 %27, label %28, label %38
28: ; preds = %25
%29 = load i32, i32* %5
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %2
%32 = load i32, i32* %5
%33 = load i8*, i8** %1
%34 = call i32 @grouping_algorithm(i32 %31, i32 %32, i8* %33)
br label %35
35: ; preds = %28
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %25
38: ; preds = %25
br label %39
39: ; preds = %38
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %12
42: ; preds = %12
%43 = load i8*, i8** %1
%44 = call i32 @print_target_grid_valid_values(i8* %43)
br label %45
45: ; preds = %42, %0
ret i8* null
}

LLVM IR (-O2):
@.str = [41 x i8] c"test/resources/grouping_algorithm.puzzle\00"
@.str.1 = [19 x i8] c"=-=-=-Choice=-=-=-\00"
@.str.2 = [4 x i8] c"Row\00"
@.str.3 = [7 x i8] c"Column\00"
@.str.4 = [8 x i8] c"Chamber\00"
@reltable.grouping_algorithm_test = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.grouping_algorithm_test to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.grouping_algorithm_test to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.4 to i64), i64 ptrtoint ([3 x i32]* @reltable.grouping_algorithm_test to i64)) to i32)]
@.str.5 = [12 x i8] c"Choice: %s\0A\00"
@.str.6 = [18 x i8] c"Choice_index: %i\0A\00"
define noalias i8* @grouping_algorithm_test() {
%1 = tail call i64 @new_puzzle(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i64 %1, 0
br i1 %2, label %35, label %3
3: ; preds = %0
%4 = tail call i32 @print_target_grid_valid_values(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %7
5: ; preds = %7
%6 = tail call i32 @print_target_grid_valid_values(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %35
7: ; preds = %3, %7
%8 = phi i64 [ 1, %3 ], [ %33, %7 ]
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%10 = add nsw i64 %8, -1
%11 = shl i64 %10, 2
%12 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.grouping_algorithm_test to i8*), i64 %11)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 0)
%15 = trunc i64 %8 to i32
%16 = tail call i32 @grouping_algorithm(i32 %15, i32 0, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 1)
%18 = tail call i32 @grouping_algorithm(i32 %15, i32 1, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 2)
%20 = tail call i32 @grouping_algorithm(i32 %15, i32 2, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 3)
%22 = tail call i32 @grouping_algorithm(i32 %15, i32 3, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 4)
%24 = tail call i32 @grouping_algorithm(i32 %15, i32 4, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 5)
%26 = tail call i32 @grouping_algorithm(i32 %15, i32 5, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 6)
%28 = tail call i32 @grouping_algorithm(i32 %15, i32 6, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 7)
%30 = tail call i32 @grouping_algorithm(i32 %15, i32 7, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 8)
%32 = tail call i32 @grouping_algorithm(i32 %15, i32 8, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%33 = add nuw nsw i64 %8, 1
%34 = icmp eq i64 %33, 4
br i1 %34, label %5, label %7
35: ; preds = %5, %0
ret i8* null
}