#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 */
unsigned long long bitmask_from_cells(char *);
int /*<<< orphan*/ calc_cell_indices(char *, char, char);
scalar_t__ cells_fit_on_board(char *, char);
char first_empty_cell(char *, char);
int /*<<< orphan*/ has_island(char *, char);
char minimum_of_cells(char *);
int /*<<< orphan*/ record_piece(char, char, char, unsigned long long);
int /*<<< orphan*/ rotate_piece(char);
void calc_six_rotations(char piece, char index) {
  char rotation, cell[5];
  char minimum, first_empty;
  unsigned long long piece_mask;
  for (rotation = 0; rotation < 6; rotation++) {
    if (piece != 3 || rotation < 3) {
      calc_cell_indices(cell, piece, index);
      if (cells_fit_on_board(cell, piece) && !has_island(cell, piece)) {
        minimum = minimum_of_cells(cell);
        first_empty = first_empty_cell(cell, minimum);
        piece_mask = bitmask_from_cells(cell);
        record_piece(piece, minimum, first_empty, piece_mask);
      }
    }
    rotate_piece(piece);
  }
}


x86 assembly (clang, -O0):
<calc_six_rotations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movb   $0x0,-0x3(%rbp)
movsbl -0x3(%rbp),%eax
cmp    $0x6,%eax
jge    1260 <calc_six_rotations+0xe0>
movsbl -0x1(%rbp),%eax
cmp    $0x3,%eax
jne    11bf <calc_six_rotations+0x3f>
movsbl -0x3(%rbp),%eax
cmp    $0x3,%eax
jge    124a <calc_six_rotations+0xca>
lea    -0x8(%rbp),%rdi
mov    -0x1(%rbp),%al
movsbl %al,%esi
movsbl -0x2(%rbp),%edx
call   1050 <calc_cell_indices@plt>
lea    -0x8(%rbp),%rdi
movsbl -0x1(%rbp),%esi
call   1070 <cells_fit_on_board@plt>
cmp    $0x0,%rax
je     1245 <calc_six_rotations+0xc5>
lea    -0x8(%rbp),%rdi
movsbl -0x1(%rbp),%esi
call   1040 <has_island@plt>
cmp    $0x0,%eax
jne    1245 <calc_six_rotations+0xc5>
lea    -0x8(%rbp),%rdi
call   1080 <minimum_of_cells@plt>
mov    %al,-0x9(%rbp)
lea    -0x8(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1090 <first_empty_cell@plt>
mov    %al,-0xa(%rbp)
lea    -0x8(%rbp),%rdi
call   10a0 <bitmask_from_cells@plt>
mov    %rax,-0x18(%rbp)
mov    -0x1(%rbp),%sil
mov    -0x9(%rbp),%dl
mov    -0xa(%rbp),%al
mov    -0x18(%rbp),%rcx
movsbl %sil,%edi
movsbl %dl,%esi
movsbl %al,%edx
call   1060 <record_piece@plt>
jmp    124a <calc_six_rotations+0xca>
movsbl -0x1(%rbp),%edi
call   1030 <rotate_piece@plt>
mov    -0x3(%rbp),%al
add    $0x1,%al
mov    %al,-0x3(%rbp)
jmp    1198 <calc_six_rotations+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_six_rotations>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
xor    %r14d,%r14d
movsbl %bl,%ebp
movsbl %sil,%r12d
lea    0x13(%rsp),%r15
mov    %r12d,0xc(%rsp)
jmp    11c1 <calc_six_rotations+0x41>
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <rotate_piece@plt>
add    $0x1,%r14b
cmp    $0x6,%r14b
je     1230 <calc_six_rotations+0xb0>
cmp    $0x3,%bl
jne    11cc <calc_six_rotations+0x4c>
cmp    $0x2,%r14b
ja     11b0 <calc_six_rotations+0x30>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
call   1050 <calc_cell_indices@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1070 <cells_fit_on_board@plt>
test   %rax,%rax
je     11b0 <calc_six_rotations+0x30>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <has_island@plt>
test   %eax,%eax
jne    11b0 <calc_six_rotations+0x30>
mov    %r15,%rdi
call   1080 <minimum_of_cells@plt>
movsbl %al,%r12d
mov    %r15,%rdi
mov    %r12d,%esi
call   1090 <first_empty_cell@plt>
mov    %eax,%r13d
mov    %r15,%rdi
call   10a0 <bitmask_from_cells@plt>
movsbl %r13b,%edx
mov    %ebp,%edi
mov    %r12d,%esi
mov    0xc(%rsp),%r12d
mov    %rax,%rcx
call   1060 <record_piece@plt>
jmp    11b0 <calc_six_rotations+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @calc_six_rotations(i8 signext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca [5 x i8]
%7 = alloca i8
%8 = alloca i8
%9 = alloca i64
store i8 %0, i8* %3
store i8 %1, i8* %4
store i8 0, i8* %5
br label %10
10: ; preds = %53, %2
%11 = load i8, i8* %5
%12 = sext i8 %11 to i32
%13 = icmp slt i32 %12, 6
br i1 %13, label %14, label %56
14: ; preds = %10
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 3
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = load i8, i8* %5
%20 = sext i8 %19 to i32
%21 = icmp slt i32 %20, 3
br i1 %21, label %22, label %50
22: ; preds = %18, %14
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%24 = load i8, i8* %3
%25 = load i8, i8* %4
%26 = call i32 @calc_cell_indices(i8* %23, i8 signext %24, i8 signext %25)
%27 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%28 = load i8, i8* %3
%29 = call i64 @cells_fit_on_board(i8* %27, i8 signext %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %49
31: ; preds = %22
%32 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%33 = load i8, i8* %3
%34 = call i32 @has_island(i8* %32, i8 signext %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %49, label %36
36: ; preds = %31
%37 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%38 = call signext i8 @minimum_of_cells(i8* %37)
store i8 %38, i8* %7
%39 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%40 = load i8, i8* %7
%41 = call signext i8 @first_empty_cell(i8* %39, i8 signext %40)
store i8 %41, i8* %8
%42 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%43 = call i64 @bitmask_from_cells(i8* %42)
store i64 %43, i64* %9
%44 = load i8, i8* %3
%45 = load i8, i8* %7
%46 = load i8, i8* %8
%47 = load i64, i64* %9
%48 = call i32 @record_piece(i8 signext %44, i8 signext %45, i8 signext %46, i64 %47)
br label %49
49: ; preds = %36, %31, %22
br label %50
50: ; preds = %49, %18
%51 = load i8, i8* %3
%52 = call i32 @rotate_piece(i8 signext %51)
br label %53
53: ; preds = %50
%54 = load i8, i8* %5
%55 = add i8 %54, 1
store i8 %55, i8* %5
br label %10
56: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @calc_six_rotations(i8 signext %0, i8 signext %1) {
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%5 = icmp ne i8 %0, 3
br label %6
6: ; preds = %2, %22
%7 = phi i8 [ 0, %2 ], [ %24, %22 ]
%8 = icmp ult i8 %7, 3
%9 = select i1 %5, i1 true, i1 %8
br i1 %9, label %10, label %22
10: ; preds = %6
%11 = call i32 @calc_cell_indices(i8* %4, i8 signext %0, i8 signext %1)
%12 = call i64 @cells_fit_on_board(i8* %4, i8 signext %0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %10
%15 = call i32 @has_island(i8* %4, i8 signext %0)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = call signext i8 @minimum_of_cells(i8* %4)
%19 = call signext i8 @first_empty_cell(i8* %4, i8 signext %18)
%20 = call i64 @bitmask_from_cells(i8* %4)
%21 = call i32 @record_piece(i8 signext %0, i8 signext %18, i8 signext %19, i64 %20)
br label %22
22: ; preds = %10, %14, %17, %6
%23 = call i32 @rotate_piece(i8 signext %0)
%24 = add nuw nsw i8 %7, 1
%25 = icmp eq i8 %24, 6
br i1 %25, label %26, label %6
26: ; preds = %22
ret void
}