; 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 @flip_piece(i32 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @calc_pieces() #1 {
  %1 = alloca i8, align 1
  %2 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %2) #2
  store i8 0, ptr %1, align 1, !tbaa !5
  br label %3

3:                                                ; preds = %23, %0
  %4 = load i8, ptr %1, align 1, !tbaa !5
  %5 = sext i8 %4 to i32
  %6 = icmp slt i32 %5, 10
  br i1 %6, label %7, label %26

7:                                                ; preds = %3
  store i8 0, ptr %2, align 1, !tbaa !5
  br label %8

8:                                                ; preds = %19, %7
  %9 = load i8, ptr %2, align 1, !tbaa !5
  %10 = sext i8 %9 to i32
  %11 = icmp slt i32 %10, 50
  br i1 %11, label %12, label %22

12:                                               ; preds = %8
  %13 = load i8, ptr %1, align 1, !tbaa !5
  %14 = load i8, ptr %2, align 1, !tbaa !5
  call void @calc_six_rotations(i8 noundef signext %13, i8 noundef signext %14)
  %15 = load i8, ptr %1, align 1, !tbaa !5
  %16 = sext i8 %15 to i32
  call void @flip_piece(i32 noundef %16)
  %17 = load i8, ptr %1, align 1, !tbaa !5
  %18 = load i8, ptr %2, align 1, !tbaa !5
  call void @calc_six_rotations(i8 noundef signext %17, i8 noundef signext %18)
  br label %19

19:                                               ; preds = %12
  %20 = load i8, ptr %2, align 1, !tbaa !5
  %21 = add i8 %20, 1
  store i8 %21, ptr %2, align 1, !tbaa !5
  br label %8, !llvm.loop !8

22:                                               ; preds = %8
  br label %23

23:                                               ; preds = %22
  %24 = load i8, ptr %1, align 1, !tbaa !5
  %25 = add i8 %24, 1
  store i8 %25, ptr %1, align 1, !tbaa !5
  br label %3, !llvm.loop !10

26:                                               ; preds = %3
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %1) #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 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


; 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: nounwind uwtable
declare dso_local void @flip_piece(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @calc_six_rotations(i8 noundef signext, i8 noundef signext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @calc_pieces() local_unnamed_addr #0 {
.preheader:
  br label %0

0:                                                ; preds = %.preheader, %0
  %.011 = phi i8 [ 0, %.preheader ], [ %1, %0 ]
  tail call void @calc_six_rotations(i8 noundef signext 0, i8 noundef signext %.011)
  tail call void @flip_piece(i32 noundef 0)
  tail call void @calc_six_rotations(i8 noundef signext 0, i8 noundef signext %.011)
  %1 = add nuw nsw i8 %.011, 1
  %exitcond.not = icmp eq i8 %1, 50
  br i1 %exitcond.not, label %.preheader.1, label %0, !llvm.loop !5

.preheader.1:                                     ; preds = %0, %.preheader.1
  %.011.1 = phi i8 [ %2, %.preheader.1 ], [ 0, %0 ]
  tail call void @calc_six_rotations(i8 noundef signext 1, i8 noundef signext %.011.1)
  tail call void @flip_piece(i32 noundef 1)
  tail call void @calc_six_rotations(i8 noundef signext 1, i8 noundef signext %.011.1)
  %2 = add nuw nsw i8 %.011.1, 1
  %exitcond.1.not = icmp eq i8 %2, 50
  br i1 %exitcond.1.not, label %.preheader.2, label %.preheader.1, !llvm.loop !5

.preheader.2:                                     ; preds = %.preheader.1, %.preheader.2
  %.011.2 = phi i8 [ %3, %.preheader.2 ], [ 0, %.preheader.1 ]
  tail call void @calc_six_rotations(i8 noundef signext 2, i8 noundef signext %.011.2)
  tail call void @flip_piece(i32 noundef 2)
  tail call void @calc_six_rotations(i8 noundef signext 2, i8 noundef signext %.011.2)
  %3 = add nuw nsw i8 %.011.2, 1
  %exitcond.2.not = icmp eq i8 %3, 50
  br i1 %exitcond.2.not, label %.preheader.3, label %.preheader.2, !llvm.loop !5

.preheader.3:                                     ; preds = %.preheader.2, %.preheader.3
  %.011.3 = phi i8 [ %4, %.preheader.3 ], [ 0, %.preheader.2 ]
  tail call void @calc_six_rotations(i8 noundef signext 3, i8 noundef signext %.011.3)
  tail call void @flip_piece(i32 noundef 3)
  tail call void @calc_six_rotations(i8 noundef signext 3, i8 noundef signext %.011.3)
  %4 = add nuw nsw i8 %.011.3, 1
  %exitcond.3.not = icmp eq i8 %4, 50
  br i1 %exitcond.3.not, label %.preheader.4, label %.preheader.3, !llvm.loop !5

.preheader.4:                                     ; preds = %.preheader.3, %.preheader.4
  %.011.4 = phi i8 [ %5, %.preheader.4 ], [ 0, %.preheader.3 ]
  tail call void @calc_six_rotations(i8 noundef signext 4, i8 noundef signext %.011.4)
  tail call void @flip_piece(i32 noundef 4)
  tail call void @calc_six_rotations(i8 noundef signext 4, i8 noundef signext %.011.4)
  %5 = add nuw nsw i8 %.011.4, 1
  %exitcond.4.not = icmp eq i8 %5, 50
  br i1 %exitcond.4.not, label %.preheader.5, label %.preheader.4, !llvm.loop !5

.preheader.5:                                     ; preds = %.preheader.4, %.preheader.5
  %.011.5 = phi i8 [ %6, %.preheader.5 ], [ 0, %.preheader.4 ]
  tail call void @calc_six_rotations(i8 noundef signext 5, i8 noundef signext %.011.5)
  tail call void @flip_piece(i32 noundef 5)
  tail call void @calc_six_rotations(i8 noundef signext 5, i8 noundef signext %.011.5)
  %6 = add nuw nsw i8 %.011.5, 1
  %exitcond.5.not = icmp eq i8 %6, 50
  br i1 %exitcond.5.not, label %.preheader.6, label %.preheader.5, !llvm.loop !5

.preheader.6:                                     ; preds = %.preheader.5, %.preheader.6
  %.011.6 = phi i8 [ %7, %.preheader.6 ], [ 0, %.preheader.5 ]
  tail call void @calc_six_rotations(i8 noundef signext 6, i8 noundef signext %.011.6)
  tail call void @flip_piece(i32 noundef 6)
  tail call void @calc_six_rotations(i8 noundef signext 6, i8 noundef signext %.011.6)
  %7 = add nuw nsw i8 %.011.6, 1
  %exitcond.6.not = icmp eq i8 %7, 50
  br i1 %exitcond.6.not, label %.preheader.7, label %.preheader.6, !llvm.loop !5

.preheader.7:                                     ; preds = %.preheader.6, %.preheader.7
  %.011.7 = phi i8 [ %8, %.preheader.7 ], [ 0, %.preheader.6 ]
  tail call void @calc_six_rotations(i8 noundef signext 7, i8 noundef signext %.011.7)
  tail call void @flip_piece(i32 noundef 7)
  tail call void @calc_six_rotations(i8 noundef signext 7, i8 noundef signext %.011.7)
  %8 = add nuw nsw i8 %.011.7, 1
  %exitcond.7.not = icmp eq i8 %8, 50
  br i1 %exitcond.7.not, label %.preheader.8, label %.preheader.7, !llvm.loop !5

.preheader.8:                                     ; preds = %.preheader.7, %.preheader.8
  %.011.8 = phi i8 [ %9, %.preheader.8 ], [ 0, %.preheader.7 ]
  tail call void @calc_six_rotations(i8 noundef signext 8, i8 noundef signext %.011.8)
  tail call void @flip_piece(i32 noundef 8)
  tail call void @calc_six_rotations(i8 noundef signext 8, i8 noundef signext %.011.8)
  %9 = add nuw nsw i8 %.011.8, 1
  %exitcond.8.not = icmp eq i8 %9, 50
  br i1 %exitcond.8.not, label %.preheader.9, label %.preheader.8, !llvm.loop !5

.preheader.9:                                     ; preds = %.preheader.8, %.preheader.9
  %.011.9 = phi i8 [ %10, %.preheader.9 ], [ 0, %.preheader.8 ]
  tail call void @calc_six_rotations(i8 noundef signext 9, i8 noundef signext %.011.9)
  tail call void @flip_piece(i32 noundef 9)
  tail call void @calc_six_rotations(i8 noundef signext 9, i8 noundef signext %.011.9)
  %10 = add nuw nsw i8 %.011.9, 1
  %exitcond.9.not = icmp eq i8 %10, 50
  br i1 %exitcond.9.not, label %11, label %.preheader.9, !llvm.loop !5

11:                                               ; preds = %.preheader.9
  ret void
}

attributes #0 = { 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" }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass