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

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

10:                                               ; preds = %17, %2
  %11 = load i32, ptr %8, align 4, !tbaa !9
  %12 = icmp slt i32 %11, 50
  br i1 %12, label %13, label %20

13:                                               ; preds = %10
  %14 = load i32, ptr %8, align 4, !tbaa !9
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [50 x i8], ptr %6, i64 0, i64 %15
  store i8 0, ptr %16, align 1, !tbaa !11
  br label %17

17:                                               ; preds = %13
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %8, align 4, !tbaa !9
  br label %10, !llvm.loop !12

20:                                               ; preds = %10
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %33, %20
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = icmp slt i32 %22, 5
  br i1 %23, label %24, label %36

24:                                               ; preds = %21
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i8, ptr %25, i64 %27
  %29 = load i8, ptr %28, align 1, !tbaa !11
  %30 = sext i8 %29 to i32
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [50 x i8], ptr %6, i64 0, i64 %31
  store i8 1, ptr %32, align 1, !tbaa !11
  br label %33

33:                                               ; preds = %24
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %8, align 4, !tbaa !9
  br label %21, !llvm.loop !14

36:                                               ; preds = %21
  store i32 49, ptr %8, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %44, %36
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [50 x i8], ptr %6, i64 0, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !11
  %42 = sext i8 %41 to i32
  %43 = icmp eq i32 %42, 1
  br i1 %43, label %44, label %47

44:                                               ; preds = %37
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = add nsw i32 %45, -1
  store i32 %46, ptr %8, align 4, !tbaa !9
  br label %37, !llvm.loop !15

47:                                               ; preds = %37
  %48 = getelementptr inbounds [50 x i8], ptr %6, i64 0, i64 0
  %49 = load i32, ptr %8, align 4, !tbaa !9
  call void @fill_contiguous_space(ptr noundef %48, i32 noundef %49)
  store i8 0, ptr %7, align 1, !tbaa !11
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %64, %47
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = icmp slt i32 %51, 50
  br i1 %52, label %53, label %67

53:                                               ; preds = %50
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [50 x i8], ptr %6, i64 0, i64 %55
  %57 = load i8, ptr %56, align 1, !tbaa !11
  %58 = sext i8 %57 to i32
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %63

60:                                               ; preds = %53
  %61 = load i8, ptr %7, align 1, !tbaa !11
  %62 = add i8 %61, 1
  store i8 %62, ptr %7, align 1, !tbaa !11
  br label %63

63:                                               ; preds = %60, %53
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %8, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %8, align 4, !tbaa !9
  br label %50, !llvm.loop !16

67:                                               ; preds = %50
  %68 = load i8, ptr %7, align 1, !tbaa !11
  %69 = sext i8 %68 to i32
  %70 = icmp eq i32 %69, 0
  br i1 %70, label %93, label %71

71:                                               ; preds = %67
  %72 = load i8, ptr %7, align 1, !tbaa !11
  %73 = sext i8 %72 to i32
  %74 = icmp eq i32 %73, 5
  br i1 %74, label %75, label %78

75:                                               ; preds = %71
  %76 = load i32, ptr %5, align 4, !tbaa !9
  %77 = icmp eq i32 %76, 8
  br i1 %77, label %93, label %78

78:                                               ; preds = %75, %71
  %79 = load i8, ptr %7, align 1, !tbaa !11
  %80 = sext i8 %79 to i32
  %81 = icmp eq i32 %80, 40
  br i1 %81, label %82, label %85

82:                                               ; preds = %78
  %83 = load i32, ptr %5, align 4, !tbaa !9
  %84 = icmp eq i32 %83, 8
  br i1 %84, label %93, label %85

85:                                               ; preds = %82, %78
  %86 = load i8, ptr %7, align 1, !tbaa !11
  %87 = sext i8 %86 to i32
  %88 = srem i32 %87, 5
  %89 = icmp eq i32 %88, 0
  br i1 %89, label %90, label %94

90:                                               ; preds = %85
  %91 = load i32, ptr %5, align 4, !tbaa !9
  %92 = icmp eq i32 %91, 0
  br i1 %92, label %93, label %94

93:                                               ; preds = %90, %82, %75, %67
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %95

94:                                               ; preds = %90, %85
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %95

95:                                               ; preds = %94, %93
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 50, ptr %6) #2
  %96 = load i32, ptr %3, align 4
  ret i32 %96
}

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}


; 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 @fill_contiguous_space(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @has_island(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #1 {
.preheader33.preheader:
  %2 = alloca [50 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 50, ptr nonnull %2) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(50) %2, i8 0, i64 50, i1 false), !tbaa !5
  %3 = load i8, ptr %0, align 1, !tbaa !5
  %4 = sext i8 %3 to i64
  %5 = getelementptr inbounds [50 x i8], ptr %2, i64 0, i64 %4
  store i8 1, ptr %5, align 1, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 1
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = sext i8 %7 to i64
  %9 = getelementptr inbounds [50 x i8], ptr %2, i64 0, i64 %8
  store i8 1, ptr %9, align 1, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 2
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = sext i8 %11 to i64
  %13 = getelementptr inbounds [50 x i8], ptr %2, i64 0, i64 %12
  store i8 1, ptr %13, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 3
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = sext i8 %15 to i64
  %17 = getelementptr inbounds [50 x i8], ptr %2, i64 0, i64 %16
  store i8 1, ptr %17, align 1, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %0, i64 4
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = sext i8 %19 to i64
  %21 = getelementptr inbounds [50 x i8], ptr %2, i64 0, i64 %20
  store i8 1, ptr %21, align 1, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %.preheader33.preheader, %.preheader
  %indvars.iv = phi i64 [ 49, %.preheader33.preheader ], [ %indvars.iv.next, %.preheader ]
  %22 = getelementptr inbounds [50 x i8], ptr %2, i64 0, i64 %indvars.iv
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %24 = icmp eq i8 %23, 1
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  br i1 %24, label %.preheader, label %25, !llvm.loop !8

25:                                               ; preds = %.preheader
  %26 = trunc nsw i64 %indvars.iv to i32
  call void @fill_contiguous_space(ptr noundef nonnull %2, i32 noundef %26)
  %27 = load <32 x i8>, ptr %2, align 16, !tbaa !5
  %28 = icmp eq <32 x i8> %27, zeroinitializer
  %29 = getelementptr inbounds i8, ptr %2, i64 32
  %30 = load <16 x i8>, ptr %29, align 16, !tbaa !5
  %31 = icmp eq <16 x i8> %30, zeroinitializer
  %32 = getelementptr inbounds i8, ptr %2, i64 48
  %33 = load i8, ptr %32, align 16, !tbaa !5
  %34 = icmp eq i8 %33, 0
  %35 = zext i1 %34 to i8
  %36 = getelementptr inbounds i8, ptr %2, i64 49
  %37 = load i8, ptr %36, align 1, !tbaa !5
  %38 = icmp eq i8 %37, 0
  %39 = zext i1 %38 to i8
  %40 = bitcast <32 x i1> %28 to i32
  %41 = call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 %40)
  %42 = trunc nuw nsw i32 %41 to i8
  %43 = bitcast <16 x i1> %31 to i16
  %44 = call range(i16 0, 17) i16 @llvm.ctpop.i16(i16 %43)
  %45 = trunc nuw nsw i16 %44 to i8
  %op.rdx = add nuw nsw i8 %42, %45
  %op.rdx43 = add nuw i8 %op.rdx, %35
  %op.rdx44 = add i8 %op.rdx43, %39
  %46 = icmp eq i8 %op.rdx44, 0
  br i1 %46, label %54, label %47

47:                                               ; preds = %25
  %48 = icmp eq i8 %op.rdx44, 5
  %49 = icmp eq i32 %1, 8
  %50 = icmp eq i8 %op.rdx44, 40
  %or.cond32 = or i1 %48, %50
  %or.cond30 = and i1 %49, %or.cond32
  br i1 %or.cond30, label %54, label %51

51:                                               ; preds = %47
  %52 = urem i8 %op.rdx44, 5
  %.sext = zext nneg i8 %52 to i32
  %53 = or i32 %.sext, %1
  %or.cond5 = icmp ne i32 %53, 0
  %spec.select31 = zext i1 %or.cond5 to i32
  br label %54

54:                                               ; preds = %51, %25, %47
  %.028 = phi i32 [ 0, %47 ], [ 0, %25 ], [ %spec.select31, %51 ]
  call void @llvm.lifetime.end.p0(i64 50, ptr nonnull %2) #4
  ret i32 %.028
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.ctpop.i32(i32) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i16 @llvm.ctpop.i16(i16) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass