; 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
define dso_local signext i8 @first_empty_cell(ptr noundef %0, i8 noundef signext %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  %6 = load i8, ptr %4, align 1, !tbaa !9
  store i8 %6, ptr %5, align 1, !tbaa !9
  br label %7

7:                                                ; preds = %49, %2
  %8 = load i8, ptr %5, align 1, !tbaa !9
  %9 = sext i8 %8 to i32
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 0
  %12 = load i8, ptr %11, align 1, !tbaa !9
  %13 = sext i8 %12 to i32
  %14 = icmp eq i32 %9, %13
  br i1 %14, label %47, label %15

15:                                               ; preds = %7
  %16 = load i8, ptr %5, align 1, !tbaa !9
  %17 = sext i8 %16 to i32
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 1
  %20 = load i8, ptr %19, align 1, !tbaa !9
  %21 = sext i8 %20 to i32
  %22 = icmp eq i32 %17, %21
  br i1 %22, label %47, label %23

23:                                               ; preds = %15
  %24 = load i8, ptr %5, align 1, !tbaa !9
  %25 = sext i8 %24 to i32
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i64 2
  %28 = load i8, ptr %27, align 1, !tbaa !9
  %29 = sext i8 %28 to i32
  %30 = icmp eq i32 %25, %29
  br i1 %30, label %47, label %31

31:                                               ; preds = %23
  %32 = load i8, ptr %5, align 1, !tbaa !9
  %33 = sext i8 %32 to i32
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 3
  %36 = load i8, ptr %35, align 1, !tbaa !9
  %37 = sext i8 %36 to i32
  %38 = icmp eq i32 %33, %37
  br i1 %38, label %47, label %39

39:                                               ; preds = %31
  %40 = load i8, ptr %5, align 1, !tbaa !9
  %41 = sext i8 %40 to i32
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %42, i64 4
  %44 = load i8, ptr %43, align 1, !tbaa !9
  %45 = sext i8 %44 to i32
  %46 = icmp eq i32 %41, %45
  br label %47

47:                                               ; preds = %39, %31, %23, %15, %7
  %48 = phi i1 [ true, %31 ], [ true, %23 ], [ true, %15 ], [ true, %7 ], [ %46, %39 ]
  br i1 %48, label %49, label %52

49:                                               ; preds = %47
  %50 = load i8, ptr %5, align 1, !tbaa !9
  %51 = add i8 %50, 1
  store i8 %51, ptr %5, align 1, !tbaa !9
  br label %7, !llvm.loop !10

52:                                               ; preds = %47
  %53 = load i8, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  ret i8 %53
}

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 = !{!7, !7, 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: nofree norecurse nosync nounwind memory(argmem: read) uwtable
define dso_local signext i8 @first_empty_cell(ptr nocapture noundef readonly %0, i8 noundef signext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  %4 = load i8, ptr %0, align 1, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 1
  %6 = getelementptr inbounds i8, ptr %0, i64 2
  %7 = getelementptr inbounds i8, ptr %0, i64 3
  br label %8

8:                                                ; preds = %.critedge, %2
  %.0 = phi i8 [ %1, %2 ], [ %22, %.critedge ]
  %9 = icmp eq i8 %.0, %4
  br i1 %9, label %.critedge, label %10

10:                                               ; preds = %8
  %11 = load i8, ptr %5, align 1, !tbaa !5
  %12 = icmp eq i8 %.0, %11
  br i1 %12, label %.critedge, label %13

13:                                               ; preds = %10
  %14 = load i8, ptr %6, align 1, !tbaa !5
  %15 = icmp eq i8 %.0, %14
  br i1 %15, label %.critedge, label %16

16:                                               ; preds = %13
  %17 = load i8, ptr %7, align 1, !tbaa !5
  %18 = icmp eq i8 %.0, %17
  br i1 %18, label %.critedge, label %19

19:                                               ; preds = %16
  %20 = load i8, ptr %3, align 1, !tbaa !5
  %21 = icmp eq i8 %.0, %20
  br i1 %21, label %.critedge, label %23

.critedge:                                        ; preds = %16, %13, %10, %8, %19
  %22 = add i8 %.0, 1
  br label %8, !llvm.loop !8

23:                                               ; preds = %19
  ret i8 %.0
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: read) 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 = !{!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: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass