; LLVM IR from kostya/crystal-benchmarks-game :: meteor (meteor)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local void @rotate_piece(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @calc_cell_indices(ptr noundef, i32 noundef, i8 noundef signext) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @cells_fit_on_board(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @minimum_of_cells(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @first_empty_cell(ptr noundef, i8 noundef signext) #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @bitmask_from_cells(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @record_piece(i32 noundef, i32 noundef, i8 noundef signext, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @has_island(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @calc_six_rotations(i8 noundef signext %0, i8 noundef signext %1) #1 {
  %3 = alloca i8, align 1
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  %6 = alloca [5 x i8], align 1
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca i64, align 8
  store i8 %0, ptr %3, align 1, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 5, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i8 0, ptr %5, align 1, !tbaa !5
  br label %10

10:                                               ; preds = %56, %2
  %11 = load i8, ptr %5, align 1, !tbaa !5
  %12 = sext i8 %11 to i32
  %13 = icmp slt i32 %12, 6
  br i1 %13, label %14, label %59

14:                                               ; preds = %10
  %15 = load i8, ptr %3, align 1, !tbaa !5
  %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, ptr %5, align 1, !tbaa !5
  %20 = sext i8 %19 to i32
  %21 = icmp slt i32 %20, 3
  br i1 %21, label %22, label %53

22:                                               ; preds = %18, %14
  %23 = getelementptr inbounds [5 x i8], ptr %6, i64 0, i64 0
  %24 = load i8, ptr %3, align 1, !tbaa !5
  %25 = sext i8 %24 to i32
  %26 = load i8, ptr %4, align 1, !tbaa !5
  call void @calc_cell_indices(ptr noundef %23, i32 noundef %25, i8 noundef signext %26)
  %27 = getelementptr inbounds [5 x i8], ptr %6, i64 0, i64 0
  %28 = load i8, ptr %3, align 1, !tbaa !5
  %29 = sext i8 %28 to i32
  %30 = call i32 @cells_fit_on_board(ptr noundef %27, i32 noundef %29)
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %52

32:                                               ; preds = %22
  %33 = getelementptr inbounds [5 x i8], ptr %6, i64 0, i64 0
  %34 = load i8, ptr %3, align 1, !tbaa !5
  %35 = sext i8 %34 to i32
  %36 = call i32 @has_island(ptr noundef %33, i32 noundef %35)
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %52, label %38

38:                                               ; preds = %32
  %39 = getelementptr inbounds [5 x i8], ptr %6, i64 0, i64 0
  %40 = call signext i8 @minimum_of_cells(ptr noundef %39)
  store i8 %40, ptr %7, align 1, !tbaa !5
  %41 = getelementptr inbounds [5 x i8], ptr %6, i64 0, i64 0
  %42 = load i8, ptr %7, align 1, !tbaa !5
  %43 = call signext i8 @first_empty_cell(ptr noundef %41, i8 noundef signext %42)
  store i8 %43, ptr %8, align 1, !tbaa !5
  %44 = getelementptr inbounds [5 x i8], ptr %6, i64 0, i64 0
  %45 = call i64 @bitmask_from_cells(ptr noundef %44)
  store i64 %45, ptr %9, align 8, !tbaa !8
  %46 = load i8, ptr %3, align 1, !tbaa !5
  %47 = sext i8 %46 to i32
  %48 = load i8, ptr %7, align 1, !tbaa !5
  %49 = sext i8 %48 to i32
  %50 = load i8, ptr %8, align 1, !tbaa !5
  %51 = load i64, ptr %9, align 8, !tbaa !8
  call void @record_piece(i32 noundef %47, i32 noundef %49, i8 noundef signext %50, i64 noundef %51)
  br label %52

52:                                               ; preds = %38, %32, %22
  br label %53

53:                                               ; preds = %52, %18
  %54 = load i8, ptr %3, align 1, !tbaa !5
  %55 = sext i8 %54 to i32
  call void @rotate_piece(i32 noundef %55)
  br label %56

56:                                               ; preds = %53
  %57 = load i8, ptr %5, align 1, !tbaa !5
  %58 = add i8 %57, 1
  store i8 %58, ptr %5, align 1, !tbaa !5
  br label %10, !llvm.loop !10

59:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 5, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local void @rotate_piece(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @calc_cell_indices(ptr noundef, i32 noundef, i8 noundef signext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @cells_fit_on_board(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @minimum_of_cells(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @first_empty_cell(ptr noundef, i8 noundef signext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @bitmask_from_cells(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @record_piece(i32 noundef, i32 noundef, i8 noundef signext, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @has_island(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @calc_six_rotations(i8 noundef signext %0, i8 noundef signext %1) local_unnamed_addr #1 {
  %3 = alloca [5 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %3) #2
  %4 = sext i8 %0 to i32
  %.not21 = icmp eq i8 %0, 3
  call void @calc_cell_indices(ptr noundef nonnull %3, i32 noundef %4, i8 noundef signext %1)
  %5 = call i32 @cells_fit_on_board(ptr noundef nonnull %3, i32 noundef %4)
  %.not = icmp eq i32 %5, 0
  br i1 %.not21, label %.split.preheader, label %.split.us.preheader

.split.us.preheader:                              ; preds = %2
  br i1 %.not, label %.split.us.1, label %6

6:                                                ; preds = %.split.us.preheader
  %7 = call i32 @has_island(ptr noundef nonnull %3, i32 noundef %4)
  %.not17.us = icmp eq i32 %7, 0
  br i1 %.not17.us, label %8, label %.split.us.1

8:                                                ; preds = %6
  %9 = call signext i8 @minimum_of_cells(ptr noundef nonnull %3)
  %10 = call signext i8 @first_empty_cell(ptr noundef nonnull %3, i8 noundef signext %9)
  %11 = call i64 @bitmask_from_cells(ptr noundef nonnull %3)
  %12 = sext i8 %9 to i32
  call void @record_piece(i32 noundef %4, i32 noundef %12, i8 noundef signext %10, i64 noundef %11)
  br label %.split.us.1

.split.us.1:                                      ; preds = %8, %6, %.split.us.preheader
  call void @rotate_piece(i32 noundef %4)
  call void @calc_cell_indices(ptr noundef nonnull %3, i32 noundef %4, i8 noundef signext %1)
  %13 = call i32 @cells_fit_on_board(ptr noundef nonnull %3, i32 noundef %4)
  %.not.us.1 = icmp eq i32 %13, 0
  br i1 %.not.us.1, label %.split.us.2, label %14

14:                                               ; preds = %.split.us.1
  %15 = call i32 @has_island(ptr noundef nonnull %3, i32 noundef %4)
  %.not17.us.1 = icmp eq i32 %15, 0
  br i1 %.not17.us.1, label %16, label %.split.us.2

16:                                               ; preds = %14
  %17 = call signext i8 @minimum_of_cells(ptr noundef nonnull %3)
  %18 = call signext i8 @first_empty_cell(ptr noundef nonnull %3, i8 noundef signext %17)
  %19 = call i64 @bitmask_from_cells(ptr noundef nonnull %3)
  %20 = sext i8 %17 to i32
  call void @record_piece(i32 noundef %4, i32 noundef %20, i8 noundef signext %18, i64 noundef %19)
  br label %.split.us.2

.split.us.2:                                      ; preds = %16, %14, %.split.us.1
  call void @rotate_piece(i32 noundef %4)
  call void @calc_cell_indices(ptr noundef nonnull %3, i32 noundef %4, i8 noundef signext %1)
  %21 = call i32 @cells_fit_on_board(ptr noundef nonnull %3, i32 noundef %4)
  %.not.us.2 = icmp eq i32 %21, 0
  br i1 %.not.us.2, label %.split.us.3, label %22

22:                                               ; preds = %.split.us.2
  %23 = call i32 @has_island(ptr noundef nonnull %3, i32 noundef %4)
  %.not17.us.2 = icmp eq i32 %23, 0
  br i1 %.not17.us.2, label %24, label %.split.us.3

24:                                               ; preds = %22
  %25 = call signext i8 @minimum_of_cells(ptr noundef nonnull %3)
  %26 = call signext i8 @first_empty_cell(ptr noundef nonnull %3, i8 noundef signext %25)
  %27 = call i64 @bitmask_from_cells(ptr noundef nonnull %3)
  %28 = sext i8 %25 to i32
  call void @record_piece(i32 noundef %4, i32 noundef %28, i8 noundef signext %26, i64 noundef %27)
  br label %.split.us.3

.split.us.3:                                      ; preds = %24, %22, %.split.us.2
  call void @rotate_piece(i32 noundef %4)
  call void @calc_cell_indices(ptr noundef nonnull %3, i32 noundef %4, i8 noundef signext %1)
  %29 = call i32 @cells_fit_on_board(ptr noundef nonnull %3, i32 noundef %4)
  %.not.us.3 = icmp eq i32 %29, 0
  br i1 %.not.us.3, label %.split.us.4, label %30

30:                                               ; preds = %.split.us.3
  %31 = call i32 @has_island(ptr noundef nonnull %3, i32 noundef %4)
  %.not17.us.3 = icmp eq i32 %31, 0
  br i1 %.not17.us.3, label %32, label %.split.us.4

32:                                               ; preds = %30
  %33 = call signext i8 @minimum_of_cells(ptr noundef nonnull %3)
  %34 = call signext i8 @first_empty_cell(ptr noundef nonnull %3, i8 noundef signext %33)
  %35 = call i64 @bitmask_from_cells(ptr noundef nonnull %3)
  %36 = sext i8 %33 to i32
  call void @record_piece(i32 noundef %4, i32 noundef %36, i8 noundef signext %34, i64 noundef %35)
  br label %.split.us.4

.split.us.4:                                      ; preds = %32, %30, %.split.us.3
  call void @rotate_piece(i32 noundef %4)
  call void @calc_cell_indices(ptr noundef nonnull %3, i32 noundef %4, i8 noundef signext %1)
  %37 = call i32 @cells_fit_on_board(ptr noundef nonnull %3, i32 noundef %4)
  %.not.us.4 = icmp eq i32 %37, 0
  br i1 %.not.us.4, label %.split.us.5, label %38

38:                                               ; preds = %.split.us.4
  %39 = call i32 @has_island(ptr noundef nonnull %3, i32 noundef %4)
  %.not17.us.4 = icmp eq i32 %39, 0
  br i1 %.not17.us.4, label %40, label %.split.us.5

40:                                               ; preds = %38
  %41 = call signext i8 @minimum_of_cells(ptr noundef nonnull %3)
  %42 = call signext i8 @first_empty_cell(ptr noundef nonnull %3, i8 noundef signext %41)
  %43 = call i64 @bitmask_from_cells(ptr noundef nonnull %3)
  %44 = sext i8 %41 to i32
  call void @record_piece(i32 noundef %4, i32 noundef %44, i8 noundef signext %42, i64 noundef %43)
  br label %.split.us.5

.split.us.5:                                      ; preds = %40, %38, %.split.us.4
  call void @rotate_piece(i32 noundef %4)
  call void @calc_cell_indices(ptr noundef nonnull %3, i32 noundef %4, i8 noundef signext %1)
  %45 = call i32 @cells_fit_on_board(ptr noundef nonnull %3, i32 noundef %4)
  %.not.us.5 = icmp eq i32 %45, 0
  br i1 %.not.us.5, label %.split20.us, label %46

46:                                               ; preds = %.split.us.5
  %47 = call i32 @has_island(ptr noundef nonnull %3, i32 noundef %4)
  %.not17.us.5 = icmp eq i32 %47, 0
  br i1 %.not17.us.5, label %48, label %.split20.us

48:                                               ; preds = %46
  %49 = call signext i8 @minimum_of_cells(ptr noundef nonnull %3)
  %50 = call signext i8 @first_empty_cell(ptr noundef nonnull %3, i8 noundef signext %49)
  %51 = call i64 @bitmask_from_cells(ptr noundef nonnull %3)
  %52 = sext i8 %49 to i32
  call void @record_piece(i32 noundef %4, i32 noundef %52, i8 noundef signext %50, i64 noundef %51)
  br label %.split20.us

.split.preheader:                                 ; preds = %2
  br i1 %.not, label %60, label %53

53:                                               ; preds = %.split.preheader
  %54 = call i32 @has_island(ptr noundef nonnull %3, i32 noundef %4)
  %.not17 = icmp eq i32 %54, 0
  br i1 %.not17, label %55, label %60

55:                                               ; preds = %53
  %56 = call signext i8 @minimum_of_cells(ptr noundef nonnull %3)
  %57 = call signext i8 @first_empty_cell(ptr noundef nonnull %3, i8 noundef signext %56)
  %58 = call i64 @bitmask_from_cells(ptr noundef nonnull %3)
  %59 = sext i8 %56 to i32
  call void @record_piece(i32 noundef %4, i32 noundef %59, i8 noundef signext %57, i64 noundef %58)
  br label %60

60:                                               ; preds = %55, %53, %.split.preheader
  call void @rotate_piece(i32 noundef %4)
  call void @calc_cell_indices(ptr noundef nonnull %3, i32 noundef %4, i8 noundef signext %1)
  %61 = call i32 @cells_fit_on_board(ptr noundef nonnull %3, i32 noundef %4)
  %.not.1 = icmp eq i32 %61, 0
  br i1 %.not.1, label %69, label %62

62:                                               ; preds = %60
  %63 = call i32 @has_island(ptr noundef nonnull %3, i32 noundef %4)
  %.not17.1 = icmp eq i32 %63, 0
  br i1 %.not17.1, label %64, label %69

64:                                               ; preds = %62
  %65 = call signext i8 @minimum_of_cells(ptr noundef nonnull %3)
  %66 = call signext i8 @first_empty_cell(ptr noundef nonnull %3, i8 noundef signext %65)
  %67 = call i64 @bitmask_from_cells(ptr noundef nonnull %3)
  %68 = sext i8 %65 to i32
  call void @record_piece(i32 noundef %4, i32 noundef %68, i8 noundef signext %66, i64 noundef %67)
  br label %69

69:                                               ; preds = %60, %62, %64
  call void @rotate_piece(i32 noundef %4)
  call void @calc_cell_indices(ptr noundef nonnull %3, i32 noundef %4, i8 noundef signext %1)
  %70 = call i32 @cells_fit_on_board(ptr noundef nonnull %3, i32 noundef %4)
  %.not.2 = icmp eq i32 %70, 0
  br i1 %.not.2, label %.split20.us.loopexit, label %71

71:                                               ; preds = %69
  %72 = call i32 @has_island(ptr noundef nonnull %3, i32 noundef %4)
  %.not17.2 = icmp eq i32 %72, 0
  br i1 %.not17.2, label %73, label %.split20.us.loopexit

73:                                               ; preds = %71
  %74 = call signext i8 @minimum_of_cells(ptr noundef nonnull %3)
  %75 = call signext i8 @first_empty_cell(ptr noundef nonnull %3, i8 noundef signext %74)
  %76 = call i64 @bitmask_from_cells(ptr noundef nonnull %3)
  %77 = sext i8 %74 to i32
  call void @record_piece(i32 noundef %4, i32 noundef %77, i8 noundef signext %75, i64 noundef %76)
  br label %.split20.us.loopexit

.split20.us.loopexit:                             ; preds = %69, %71, %73
  call void @rotate_piece(i32 noundef %4)
  call void @rotate_piece(i32 noundef %4)
  call void @rotate_piece(i32 noundef %4)
  br label %.split20.us

.split20.us:                                      ; preds = %.split.us.5, %46, %48, %.split20.us.loopexit
  call void @rotate_piece(i32 noundef %4)
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %3) #2
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,SCCPPass,SROAPass,SimplifyCFGPass