; LLVM IR from mackorone/mms :: old/v2/src/maze/tomasz (TomaszMazeGenerator)

; 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"

%"class.tomasz::TomaszMazeGenerator" = type { %class.IMazeAlgorithm, double, double, i32, i32, %"class.std::vector.55", %"class.std::stack", i32, i32, i32, ptr }
%class.IMazeAlgorithm = type { ptr }
%"class.std::vector.55" = type { %"struct.std::_Vector_base.56" }
%"struct.std::_Vector_base.56" = type { %"struct.std::_Vector_base<std::vector<tomasz::TomaszMazeGenerator::TomMazeGenTile>, std::allocator<std::vector<tomasz::TomaszMazeGenerator::TomMazeGenTile>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<tomasz::TomaszMazeGenerator::TomMazeGenTile>, std::allocator<std::vector<tomasz::TomaszMazeGenerator::TomMazeGenTile>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<tomasz::TomaszMazeGenerator::TomMazeGenTile>, std::allocator<std::vector<tomasz::TomaszMazeGenerator::TomMazeGenTile>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<tomasz::TomaszMazeGenerator::TomMazeGenTile>, std::allocator<std::vector<tomasz::TomaszMazeGenerator::TomMazeGenTile>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<tomasz::TomaszMazeGenerator::TomMazeGenTile *, std::allocator<tomasz::TomaszMazeGenerator::TomMazeGenTile *>>::_Deque_impl" }
%"struct.std::_Deque_base<tomasz::TomaszMazeGenerator::TomMazeGenTile *, std::allocator<tomasz::TomaszMazeGenerator::TomMazeGenTile *>>::_Deque_impl" = type { %"struct.std::_Deque_base<tomasz::TomaszMazeGenerator::TomMazeGenTile *, std::allocator<tomasz::TomaszMazeGenerator::TomMazeGenTile *>>::_Deque_impl_data" }
%"struct.std::_Deque_base<tomasz::TomaszMazeGenerator::TomMazeGenTile *, std::allocator<tomasz::TomaszMazeGenerator::TomMazeGenTile *>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"struct.tomasz::TomaszMazeGenerator::TomMazeGenTile" = type { i32, i32, i32, i8, i8, %"class.std::map.64" }
%"class.std::map.64" = type { %"class.std::_Rb_tree.65" }
%"class.std::_Rb_tree.65" = type { %"struct.std::_Rb_tree<tomasz::Direction, std::pair<const tomasz::Direction, bool>, std::_Select1st<std::pair<const tomasz::Direction, bool>>, std::less<tomasz::Direction>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<tomasz::Direction, std::pair<const tomasz::Direction, bool>, std::_Select1st<std::pair<const tomasz::Direction, bool>>, std::less<tomasz::Direction>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN6tomasz19TomaszMazeGenerator7getTileEiiNS_9DirectionE(ptr noundef nonnull align 8 dereferenceable(160), i32 noundef, i32 noundef, i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6tomasz19TomaszMazeGenerator19isValidExploredTileEiiNS_9DirectionE(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 align 2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !11
  %10 = load ptr, ptr %6, align 8
  %11 = load i32, ptr %9, align 4, !tbaa !11
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %16

13:                                               ; preds = %4
  %14 = load i32, ptr %8, align 4, !tbaa !9
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %8, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %13, %4
  %17 = load i32, ptr %9, align 4, !tbaa !11
  %18 = icmp eq i32 %17, 1
  br i1 %18, label %19, label %22

19:                                               ; preds = %16
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %7, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %19, %16
  %23 = load i32, ptr %9, align 4, !tbaa !11
  %24 = icmp eq i32 %23, 2
  br i1 %24, label %25, label %28

25:                                               ; preds = %22
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = add nsw i32 %26, -1
  store i32 %27, ptr %8, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %25, %22
  %29 = load i32, ptr %9, align 4, !tbaa !11
  %30 = icmp eq i32 %29, 3
  br i1 %30, label %31, label %34

31:                                               ; preds = %28
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = add nsw i32 %32, -1
  store i32 %33, ptr %7, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %31, %28
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = icmp sge i32 %35, 0
  br i1 %36, label %37, label %83

37:                                               ; preds = %34
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = icmp sge i32 %38, 0
  br i1 %39, label %40, label %83

40:                                               ; preds = %37
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = getelementptr inbounds %"class.tomasz::TomaszMazeGenerator", ptr %10, i32 0, i32 7
  %43 = load i32, ptr %42, align 8, !tbaa !13
  %44 = icmp slt i32 %41, %43
  br i1 %44, label %45, label %83

45:                                               ; preds = %40
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = getelementptr inbounds %"class.tomasz::TomaszMazeGenerator", ptr %10, i32 0, i32 8
  %48 = load i32, ptr %47, align 4, !tbaa !28
  %49 = icmp slt i32 %46, %48
  br i1 %49, label %50, label %83

50:                                               ; preds = %45
  %51 = load i32, ptr %7, align 4, !tbaa !9
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = call noundef ptr @_ZN6tomasz19TomaszMazeGenerator7getTileEiiNS_9DirectionE(ptr noundef nonnull align 8 dereferenceable(160) %10, i32 noundef %51, i32 noundef %52, i32 noundef 4)
  %54 = getelementptr inbounds %"struct.tomasz::TomaszMazeGenerator::TomMazeGenTile", ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 8, !tbaa !29
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %64, label %57

57:                                               ; preds = %50
  %58 = load i32, ptr %7, align 4, !tbaa !9
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = call noundef ptr @_ZN6tomasz19TomaszMazeGenerator7getTileEiiNS_9DirectionE(ptr noundef nonnull align 8 dereferenceable(160) %10, i32 noundef %58, i32 noundef %59, i32 noundef 4)
  %61 = getelementptr inbounds %"struct.tomasz::TomaszMazeGenerator::TomMazeGenTile", ptr %60, i32 0, i32 1
  %62 = load i32, ptr %61, align 4, !tbaa !40
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %83

64:                                               ; preds = %57, %50
  %65 = load i32, ptr %7, align 4, !tbaa !9
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = call noundef ptr @_ZN6tomasz19TomaszMazeGenerator7getTileEiiNS_9DirectionE(ptr noundef nonnull align 8 dereferenceable(160) %10, i32 noundef %65, i32 noundef %66, i32 noundef 4)
  %68 = getelementptr inbounds %"struct.tomasz::TomaszMazeGenerator::TomMazeGenTile", ptr %67, i32 0, i32 3
  %69 = load i8, ptr %68, align 4, !tbaa !41, !range !42, !noundef !43
  %70 = trunc i8 %69 to i1
  %71 = zext i1 %70 to i32
  %72 = icmp eq i32 %71, 1
  br i1 %72, label %73, label %83

73:                                               ; preds = %64
  %74 = load i32, ptr %7, align 4, !tbaa !9
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = call noundef ptr @_ZN6tomasz19TomaszMazeGenerator7getTileEiiNS_9DirectionE(ptr noundef nonnull align 8 dereferenceable(160) %10, i32 noundef %74, i32 noundef %75, i32 noundef 4)
  %77 = getelementptr inbounds %"struct.tomasz::TomaszMazeGenerator::TomMazeGenTile", ptr %76, i32 0, i32 4
  %78 = load i8, ptr %77, align 1, !tbaa !44, !range !42, !noundef !43
  %79 = trunc i8 %78 to i1
  %80 = zext i1 %79 to i32
  %81 = icmp eq i32 %80, 0
  br i1 %81, label %82, label %83

82:                                               ; preds = %73
  store i1 true, ptr %5, align 1
  br label %84

83:                                               ; preds = %73, %64, %57, %45, %40, %37, %34
  store i1 false, ptr %5, align 1
  br label %84

84:                                               ; preds = %83, %82
  %85 = load i1, ptr %5, align 1
  ret i1 %85
}

attributes #0 = { mustprogress 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTSN6tomasz9DirectionE", !7, i64 0}
!13 = !{!14, !10, i64 136}
!14 = !{!"_ZTSN6tomasz19TomaszMazeGeneratorE", !15, i64 0, !16, i64 8, !16, i64 16, !10, i64 24, !10, i64 28, !17, i64 32, !21, i64 56, !10, i64 136, !10, i64 140, !12, i64 144, !6, i64 152}
!15 = !{!"_ZTS14IMazeAlgorithm"}
!16 = !{!"double", !7, i64 0}
!17 = !{!"_ZTSSt6vectorIS_IN6tomasz19TomaszMazeGenerator14TomMazeGenTileESaIS2_EESaIS4_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseISt6vectorIN6tomasz19TomaszMazeGenerator14TomMazeGenTileESaIS3_EESaIS5_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseISt6vectorIN6tomasz19TomaszMazeGenerator14TomMazeGenTileESaIS3_EESaIS5_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseISt6vectorIN6tomasz19TomaszMazeGenerator14TomMazeGenTileESaIS3_EESaIS5_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!"_ZTSSt5stackIPN6tomasz19TomaszMazeGenerator14TomMazeGenTileESt5dequeIS3_SaIS3_EEE", !22, i64 0}
!22 = !{!"_ZTSSt5dequeIPN6tomasz19TomaszMazeGenerator14TomMazeGenTileESaIS3_EE", !23, i64 0}
!23 = !{!"_ZTSSt11_Deque_baseIPN6tomasz19TomaszMazeGenerator14TomMazeGenTileESaIS3_EE", !24, i64 0}
!24 = !{!"_ZTSNSt11_Deque_baseIPN6tomasz19TomaszMazeGenerator14TomMazeGenTileESaIS3_EE11_Deque_implE", !25, i64 0}
!25 = !{!"_ZTSNSt11_Deque_baseIPN6tomasz19TomaszMazeGenerator14TomMazeGenTileESaIS3_EE16_Deque_impl_dataE", !6, i64 0, !26, i64 8, !27, i64 16, !27, i64 48}
!26 = !{!"long", !7, i64 0}
!27 = !{!"_ZTSSt15_Deque_iteratorIPN6tomasz19TomaszMazeGenerator14TomMazeGenTileERS3_PS3_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!28 = !{!14, !10, i64 140}
!29 = !{!30, !10, i64 0}
!30 = !{!"_ZTSN6tomasz19TomaszMazeGenerator14TomMazeGenTileE", !10, i64 0, !10, i64 4, !10, i64 8, !31, i64 12, !31, i64 13, !32, i64 16}
!31 = !{!"bool", !7, i64 0}
!32 = !{!"_ZTSSt3mapIN6tomasz9DirectionEbSt4lessIS1_ESaISt4pairIKS1_bEEE", !33, i64 0}
!33 = !{!"_ZTSSt8_Rb_treeIN6tomasz9DirectionESt4pairIKS1_bESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE", !34, i64 0}
!34 = !{!"_ZTSNSt8_Rb_treeIN6tomasz9DirectionESt4pairIKS1_bESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE13_Rb_tree_implIS8_Lb1EEE", !35, i64 0, !37, i64 8}
!35 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIN6tomasz9DirectionEEE", !36, i64 0}
!36 = !{!"_ZTSSt4lessIN6tomasz9DirectionEE"}
!37 = !{!"_ZTSSt15_Rb_tree_header", !38, i64 0, !26, i64 32}
!38 = !{!"_ZTSSt18_Rb_tree_node_base", !39, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!39 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!40 = !{!30, !10, i64 4}
!41 = !{!30, !31, i64 12}
!42 = !{i8 0, i8 2}
!43 = !{}
!44 = !{!30, !31, i64 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 uwtable
declare dso_local noundef ptr @_ZN6tomasz19TomaszMazeGenerator7getTileEiiNS_9DirectionE(ptr noundef nonnull align 8 dereferenceable(160), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6tomasz19TomaszMazeGenerator19isValidExploredTileEiiNS_9DirectionE(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 align 2 {
  %5 = icmp eq i32 %3, 0
  %6 = zext i1 %5 to i32
  %spec.select = add nsw i32 %6, %2
  %7 = icmp eq i32 %3, 1
  %8 = zext i1 %7 to i32
  %.023 = add nsw i32 %8, %1
  %9 = icmp eq i32 %3, 2
  %10 = sext i1 %9 to i32
  %.1 = add nsw i32 %spec.select, %10
  %11 = icmp eq i32 %3, 3
  %12 = sext i1 %11 to i32
  %.124 = add nsw i32 %.023, %12
  %13 = icmp sgt i32 %.124, -1
  %14 = icmp sgt i32 %.1, -1
  %or.cond = select i1 %13, i1 %14, i1 false
  %15 = getelementptr inbounds i8, ptr %0, i64 136
  %16 = load i32, ptr %15, align 8
  %17 = icmp slt i32 %.124, %16
  %or.cond28 = select i1 %or.cond, i1 %17, i1 false
  %18 = getelementptr inbounds i8, ptr %0, i64 140
  %19 = load i32, ptr %18, align 4
  %20 = icmp slt i32 %.1, %19
  %or.cond31 = select i1 %or.cond28, i1 %20, i1 false
  br i1 %or.cond31, label %21, label %38

21:                                               ; preds = %4
  %22 = tail call noundef ptr @_ZN6tomasz19TomaszMazeGenerator7getTileEiiNS_9DirectionE(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef %.124, i32 noundef %.1, i32 noundef 4)
  %23 = load i32, ptr %22, align 8, !tbaa !5
  %.not = icmp eq i32 %23, 0
  br i1 %.not, label %24, label %28

24:                                               ; preds = %21
  %25 = tail call noundef ptr @_ZN6tomasz19TomaszMazeGenerator7getTileEiiNS_9DirectionE(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef %.124, i32 noundef %.1, i32 noundef 4)
  %26 = getelementptr inbounds i8, ptr %25, i64 4
  %27 = load i32, ptr %26, align 4, !tbaa !21
  %.not25 = icmp eq i32 %27, 0
  br i1 %.not25, label %38, label %28

28:                                               ; preds = %24, %21
  %29 = tail call noundef ptr @_ZN6tomasz19TomaszMazeGenerator7getTileEiiNS_9DirectionE(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef %.124, i32 noundef %.1, i32 noundef 4)
  %30 = getelementptr inbounds i8, ptr %29, i64 12
  %31 = load i8, ptr %30, align 4, !tbaa !22, !range !23, !noundef !24
  %32 = trunc nuw i8 %31 to i1
  br i1 %32, label %33, label %38

33:                                               ; preds = %28
  %34 = tail call noundef ptr @_ZN6tomasz19TomaszMazeGenerator7getTileEiiNS_9DirectionE(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef %.124, i32 noundef %.1, i32 noundef 4)
  %35 = getelementptr inbounds i8, ptr %34, i64 13
  %36 = load i8, ptr %35, align 1, !tbaa !25, !range !23, !noundef !24
  %37 = icmp eq i8 %36, 0
  br i1 %37, label %39, label %38

38:                                               ; preds = %33, %28, %24, %4
  br label %39

39:                                               ; preds = %33, %38
  %.0 = phi i1 [ false, %38 ], [ true, %33 ]
  ret i1 %.0
}

attributes #0 = { mustprogress 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, !7, i64 0}
!6 = !{!"_ZTSN6tomasz19TomaszMazeGenerator14TomMazeGenTileE", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !10, i64 13, !11, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSSt3mapIN6tomasz9DirectionEbSt4lessIS1_ESaISt4pairIKS1_bEEE", !12, i64 0}
!12 = !{!"_ZTSSt8_Rb_treeIN6tomasz9DirectionESt4pairIKS1_bESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE", !13, i64 0}
!13 = !{!"_ZTSNSt8_Rb_treeIN6tomasz9DirectionESt4pairIKS1_bESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE13_Rb_tree_implIS8_Lb1EEE", !14, i64 0, !16, i64 8}
!14 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIN6tomasz9DirectionEEE", !15, i64 0}
!15 = !{!"_ZTSSt4lessIN6tomasz9DirectionEE"}
!16 = !{!"_ZTSSt15_Rb_tree_header", !17, i64 0, !20, i64 32}
!17 = !{!"_ZTSSt18_Rb_tree_node_base", !18, i64 0, !19, i64 8, !19, i64 16, !19, i64 24}
!18 = !{!"_ZTSSt14_Rb_tree_color", !8, i64 0}
!19 = !{!"any pointer", !8, i64 0}
!20 = !{!"long", !8, i64 0}
!21 = !{!6, !7, i64 4}
!22 = !{!6, !10, i64 12}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = !{!6, !10, i64 13}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass