; LLVM IR from qc-tum/chemtensor :: src/util (abstract_graph)

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

%struct.abstract_graph = type { ptr, ptr, i32 }

@.str = external hidden unnamed_addr constant [60 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [77 x i8], align 1
@__PRETTY_FUNCTION__.abstract_graph_equal = external hidden unnamed_addr constant [105 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [60 x i8], align 1

; 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 zeroext i1 @abstract_graph_equal(ptr noalias noundef %0, ptr noalias noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.abstract_graph, ptr %9, i32 0, i32 2
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.abstract_graph, ptr %12, i32 0, i32 2
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = icmp ne i32 %11, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %150

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !12
  br label %18

18:                                               ; preds = %144, %17
  %19 = load i32, ptr %6, align 4, !tbaa !12
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.abstract_graph, ptr %20, i32 0, i32 2
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %23 = icmp slt i32 %19, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %18
  store i32 2, ptr %7, align 4
  br label %147

25:                                               ; preds = %18
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.abstract_graph, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !13
  %29 = load i32, ptr %6, align 4, !tbaa !12
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i32, ptr %28, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !12
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.abstract_graph, ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  %36 = load i32, ptr %6, align 4, !tbaa !12
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i32, ptr %35, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !12
  %40 = icmp ne i32 %32, %39
  br i1 %40, label %41, label %42

41:                                               ; preds = %25
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %147

42:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !12
  br label %43

43:                                               ; preds = %138, %42
  %44 = load i32, ptr %8, align 4, !tbaa !12
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.abstract_graph, ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  %48 = load i32, ptr %6, align 4, !tbaa !12
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i32, ptr %47, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !12
  %52 = icmp slt i32 %44, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %43
  store i32 5, ptr %7, align 4
  br label %141

54:                                               ; preds = %43
  %55 = load i32, ptr %8, align 4, !tbaa !12
  %56 = icmp sgt i32 %55, 0
  br i1 %56, label %57, label %112

57:                                               ; preds = %54
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.abstract_graph, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !14
  %61 = load i32, ptr %6, align 4, !tbaa !12
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds ptr, ptr %60, i64 %62
  %64 = load ptr, ptr %63, align 8, !tbaa !5
  %65 = load i32, ptr %8, align 4, !tbaa !12
  %66 = sub nsw i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds i32, ptr %64, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !12
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.abstract_graph, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !14
  %73 = load i32, ptr %6, align 4, !tbaa !12
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds ptr, ptr %72, i64 %74
  %76 = load ptr, ptr %75, align 8, !tbaa !5
  %77 = load i32, ptr %8, align 4, !tbaa !12
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds i32, ptr %76, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !12
  %81 = icmp slt i32 %69, %80
  br i1 %81, label %82, label %83

82:                                               ; preds = %57
  br label %84

83:                                               ; preds = %57
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 119, ptr noundef @__PRETTY_FUNCTION__.abstract_graph_equal) #4
  unreachable

84:                                               ; preds = %82
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.abstract_graph, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !14
  %88 = load i32, ptr %6, align 4, !tbaa !12
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds ptr, ptr %87, i64 %89
  %91 = load ptr, ptr %90, align 8, !tbaa !5
  %92 = load i32, ptr %8, align 4, !tbaa !12
  %93 = sub nsw i32 %92, 1
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds i32, ptr %91, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !12
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.abstract_graph, ptr %97, i32 0, i32 0
  %99 = load ptr, ptr %98, align 8, !tbaa !14
  %100 = load i32, ptr %6, align 4, !tbaa !12
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds ptr, ptr %99, i64 %101
  %103 = load ptr, ptr %102, align 8, !tbaa !5
  %104 = load i32, ptr %8, align 4, !tbaa !12
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds i32, ptr %103, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !12
  %108 = icmp slt i32 %96, %107
  br i1 %108, label %109, label %110

109:                                              ; preds = %84
  br label %111

110:                                              ; preds = %84
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 120, ptr noundef @__PRETTY_FUNCTION__.abstract_graph_equal) #4
  unreachable

111:                                              ; preds = %109
  br label %112

112:                                              ; preds = %111, %54
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.abstract_graph, ptr %113, i32 0, i32 0
  %115 = load ptr, ptr %114, align 8, !tbaa !14
  %116 = load i32, ptr %6, align 4, !tbaa !12
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds ptr, ptr %115, i64 %117
  %119 = load ptr, ptr %118, align 8, !tbaa !5
  %120 = load i32, ptr %8, align 4, !tbaa !12
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds i32, ptr %119, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !12
  %124 = load ptr, ptr %5, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.abstract_graph, ptr %124, i32 0, i32 0
  %126 = load ptr, ptr %125, align 8, !tbaa !14
  %127 = load i32, ptr %6, align 4, !tbaa !12
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds ptr, ptr %126, i64 %128
  %130 = load ptr, ptr %129, align 8, !tbaa !5
  %131 = load i32, ptr %8, align 4, !tbaa !12
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds i32, ptr %130, i64 %132
  %134 = load i32, ptr %133, align 4, !tbaa !12
  %135 = icmp ne i32 %123, %134
  br i1 %135, label %136, label %137

136:                                              ; preds = %112
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %141

137:                                              ; preds = %112
  br label %138

138:                                              ; preds = %137
  %139 = load i32, ptr %8, align 4, !tbaa !12
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %8, align 4, !tbaa !12
  br label %43, !llvm.loop !15

141:                                              ; preds = %136, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %142 = load i32, ptr %7, align 4
  switch i32 %142, label %147 [
    i32 5, label %143
  ]

143:                                              ; preds = %141
  br label %144

144:                                              ; preds = %143
  %145 = load i32, ptr %6, align 4, !tbaa !12
  %146 = add nsw i32 %145, 1
  store i32 %146, ptr %6, align 4, !tbaa !12
  br label %18, !llvm.loop !17

147:                                              ; preds = %141, %41, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %148 = load i32, ptr %7, align 4
  switch i32 %148, label %152 [
    i32 2, label %149
    i32 1, label %150
  ]

149:                                              ; preds = %147
  store i1 true, ptr %3, align 1
  br label %150

150:                                              ; preds = %149, %147, %16
  %151 = load i1, ptr %3, align 1
  ret i1 %151

152:                                              ; preds = %147
  unreachable
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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 = { noreturn nounwind "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 #3 = { nounwind }
attributes #4 = { noreturn 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, !11, i64 16}
!10 = !{!"abstract_graph", !6, i64 0, !6, i64 8, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !6, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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

@.str = external hidden unnamed_addr constant [60 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [77 x i8], align 1
@__PRETTY_FUNCTION__.abstract_graph_equal = external hidden unnamed_addr constant [105 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [60 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @abstract_graph_equal(ptr noalias nocapture noundef readonly %0, ptr noalias nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %.not = icmp eq i32 %4, %6
  br i1 %.not, label %.preheader43, label %.thread

.preheader43:                                     ; preds = %2
  %7 = icmp slt i32 %4, 1
  br i1 %7, label %.thread, label %.lr.ph48

.lr.ph48:                                         ; preds = %.preheader43
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = zext nneg i32 %4 to i64
  %wide.trip.count61 = zext nneg i32 %4 to i64
  br label %13

13:                                               ; preds = %.lr.ph48, %._crit_edge
  %indvars.iv58 = phi i64 [ 0, %.lr.ph48 ], [ %indvars.iv.next59, %._crit_edge ]
  %14 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv58
  %15 = load i32, ptr %14, align 4, !tbaa !12
  %16 = getelementptr inbounds i32, ptr %11, i64 %indvars.iv58
  %17 = load i32, ptr %16, align 4, !tbaa !12
  %.not38 = icmp eq i32 %15, %17
  br i1 %.not38, label %.preheader, label %.thread

.preheader:                                       ; preds = %13
  %.not4145 = icmp sgt i32 %15, 0
  br i1 %.not4145, label %18, label %._crit_edge

18:                                               ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %15 to i64
  %.pre = load ptr, ptr %0, align 8, !tbaa !13
  %.phi.trans.insert = getelementptr inbounds ptr, ptr %.pre, i64 %indvars.iv58
  %.pre64 = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !14
  %.pre65 = load ptr, ptr %1, align 8, !tbaa !13
  %.phi.trans.insert66 = getelementptr inbounds ptr, ptr %.pre65, i64 %indvars.iv58
  %.pre67 = load ptr, ptr %.phi.trans.insert66, align 8, !tbaa !14
  %19 = load i32, ptr %.pre64, align 4, !tbaa !12
  %20 = load i32, ptr %.pre67, align 4, !tbaa !12
  %.not40.peel = icmp eq i32 %19, %20
  br i1 %.not40.peel, label %21, label %.thread

21:                                               ; preds = %18
  %exitcond.peel.not = icmp eq i32 %15, 1
  br i1 %exitcond.peel.not, label %._crit_edge, label %.lr.ph.peel.next

22:                                               ; preds = %35
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph.peel.next, !llvm.loop !15

.lr.ph.peel.next:                                 ; preds = %21, %22
  %indvars.iv = phi i64 [ %indvars.iv.next, %22 ], [ 1, %21 ]
  %23 = add nsw i64 %indvars.iv, -1
  %24 = getelementptr inbounds i32, ptr %.pre64, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !12
  %26 = getelementptr inbounds i32, ptr %.pre64, i64 %indvars.iv
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = icmp slt i32 %25, %27
  br i1 %28, label %29, label %.loopexit

.loopexit:                                        ; preds = %.lr.ph.peel.next
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 119, ptr noundef nonnull @__PRETTY_FUNCTION__.abstract_graph_equal) #2
  unreachable

29:                                               ; preds = %.lr.ph.peel.next
  %30 = getelementptr inbounds i32, ptr %.pre67, i64 %23
  %31 = load i32, ptr %30, align 4, !tbaa !12
  %32 = getelementptr inbounds i32, ptr %.pre67, i64 %indvars.iv
  %33 = load i32, ptr %32, align 4, !tbaa !12
  %34 = icmp slt i32 %31, %33
  br i1 %34, label %35, label %.loopexit54

.loopexit54:                                      ; preds = %29
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 120, ptr noundef nonnull @__PRETTY_FUNCTION__.abstract_graph_equal) #2
  unreachable

35:                                               ; preds = %29
  %36 = getelementptr inbounds i32, ptr %.pre64, i64 %indvars.iv
  %37 = load i32, ptr %36, align 4, !tbaa !12
  %38 = getelementptr inbounds i32, ptr %.pre67, i64 %indvars.iv
  %39 = load i32, ptr %38, align 4, !tbaa !12
  %.not40 = icmp eq i32 %37, %39
  br i1 %.not40, label %22, label %.thread

._crit_edge:                                      ; preds = %22, %21, %.preheader
  %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1
  %exitcond62 = icmp eq i64 %indvars.iv.next59, %wide.trip.count61
  br i1 %exitcond62, label %.thread.loopexit68.split.loop.exit69, label %13, !llvm.loop !18

.thread.loopexit68.split.loop.exit69:             ; preds = %._crit_edge
  %40 = icmp uge i64 %indvars.iv.next59, %12
  br label %.thread

.thread:                                          ; preds = %18, %13, %35, %.thread.loopexit68.split.loop.exit69, %.preheader43, %2
  %.3 = phi i1 [ false, %2 ], [ true, %.preheader43 ], [ %40, %.thread.loopexit68.split.loop.exit69 ], [ false, %35 ], [ false, %13 ], [ false, %18 ]
  ret i1 %.3
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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" }
attributes #1 = { noreturn nounwind "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 = { noreturn 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, !10, i64 16}
!6 = !{!"abstract_graph", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!10, !10, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16, !17}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!"llvm.loop.peeled.count", i32 1}
!18 = distinct !{!18, !16}


; Effective O3 passes: BDCEPass,ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopFullUnrollPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass