; LLVM IR from qc-tum/chemtensor :: src/tensor (su2_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.su2_graph = type { ptr, ptr, i32, i32 }
%struct.su2_graph_edge = type { [2 x i32] }
%struct.su2_graph_node = type { i32, [2 x i32], i32 }

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [35 x i8], align 1
@__PRETTY_FUNCTION__.su2_graph_is_yoga_edge = external hidden unnamed_addr constant [66 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [101 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [101 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @su2_graph_is_yoga_edge(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = icmp sle i32 0, %8
  br i1 %9, label %10, label %17

10:                                               ; preds = %2
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.su2_graph, ptr %12, i32 0, i32 3
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = icmp slt i32 %11, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %10
  br label %18

17:                                               ; preds = %10, %2
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 372, ptr noundef @__PRETTY_FUNCTION__.su2_graph_is_yoga_edge) #3
  unreachable

18:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.su2_graph, ptr %19, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds %struct.su2_graph_edge, ptr %21, i64 %23
  store ptr %24, ptr %6, align 8, !tbaa !5
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.su2_graph_edge, ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds [2 x i32], ptr %26, i64 0, i64 0
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = icmp slt i32 %28, 0
  br i1 %29, label %36, label %30

30:                                               ; preds = %18
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.su2_graph_edge, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds [2 x i32], ptr %32, i64 0, i64 1
  %34 = load i32, ptr %33, align 4, !tbaa !9
  %35 = icmp slt i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %30, %18
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %164

37:                                               ; preds = %30
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.su2_graph, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.su2_graph_edge, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds [2 x i32], ptr %42, i64 0, i64 0
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds %struct.su2_graph_node, ptr %40, i64 %45
  %47 = getelementptr inbounds %struct.su2_graph_node, ptr %46, i32 0, i32 2
  %48 = load i32, ptr %47, align 4, !tbaa !15
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %63, label %50

50:                                               ; preds = %37
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.su2_graph, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !14
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.su2_graph_edge, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds [2 x i32], ptr %55, i64 0, i64 1
  %57 = load i32, ptr %56, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct.su2_graph_node, ptr %53, i64 %58
  %60 = getelementptr inbounds %struct.su2_graph_node, ptr %59, i32 0, i32 2
  %61 = load i32, ptr %60, align 4, !tbaa !15
  %62 = icmp eq i32 %61, 1
  br i1 %62, label %63, label %64

63:                                               ; preds = %50, %37
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %164

64:                                               ; preds = %50
  %65 = load i32, ptr %5, align 4, !tbaa !9
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.su2_graph, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !14
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.su2_graph_edge, ptr %69, i32 0, i32 0
  %71 = getelementptr inbounds [2 x i32], ptr %70, i64 0, i64 0
  %72 = load i32, ptr %71, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds %struct.su2_graph_node, ptr %68, i64 %73
  %75 = getelementptr inbounds %struct.su2_graph_node, ptr %74, i32 0, i32 1
  %76 = getelementptr inbounds [2 x i32], ptr %75, i64 0, i64 0
  %77 = load i32, ptr %76, align 4, !tbaa !9
  %78 = icmp eq i32 %65, %77
  %79 = zext i1 %78 to i32
  %80 = load i32, ptr %5, align 4, !tbaa !9
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.su2_graph, ptr %81, i32 0, i32 0
  %83 = load ptr, ptr %82, align 8, !tbaa !14
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.su2_graph_edge, ptr %84, i32 0, i32 0
  %86 = getelementptr inbounds [2 x i32], ptr %85, i64 0, i64 0
  %87 = load i32, ptr %86, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds %struct.su2_graph_node, ptr %83, i64 %88
  %90 = getelementptr inbounds %struct.su2_graph_node, ptr %89, i32 0, i32 1
  %91 = getelementptr inbounds [2 x i32], ptr %90, i64 0, i64 1
  %92 = load i32, ptr %91, align 4, !tbaa !9
  %93 = icmp eq i32 %80, %92
  %94 = zext i1 %93 to i32
  %95 = icmp ne i32 %79, %94
  br i1 %95, label %96, label %97

96:                                               ; preds = %64
  br label %98

97:                                               ; preds = %64
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 384, ptr noundef @__PRETTY_FUNCTION__.su2_graph_is_yoga_edge) #3
  unreachable

98:                                               ; preds = %96
  %99 = load i32, ptr %5, align 4, !tbaa !9
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.su2_graph, ptr %100, i32 0, i32 0
  %102 = load ptr, ptr %101, align 8, !tbaa !14
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.su2_graph_edge, ptr %103, i32 0, i32 0
  %105 = getelementptr inbounds [2 x i32], ptr %104, i64 0, i64 1
  %106 = load i32, ptr %105, align 4, !tbaa !9
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds %struct.su2_graph_node, ptr %102, i64 %107
  %109 = getelementptr inbounds %struct.su2_graph_node, ptr %108, i32 0, i32 1
  %110 = getelementptr inbounds [2 x i32], ptr %109, i64 0, i64 0
  %111 = load i32, ptr %110, align 4, !tbaa !9
  %112 = icmp eq i32 %99, %111
  %113 = zext i1 %112 to i32
  %114 = load i32, ptr %5, align 4, !tbaa !9
  %115 = load ptr, ptr %4, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.su2_graph, ptr %115, i32 0, i32 0
  %117 = load ptr, ptr %116, align 8, !tbaa !14
  %118 = load ptr, ptr %6, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.su2_graph_edge, ptr %118, i32 0, i32 0
  %120 = getelementptr inbounds [2 x i32], ptr %119, i64 0, i64 1
  %121 = load i32, ptr %120, align 4, !tbaa !9
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds %struct.su2_graph_node, ptr %117, i64 %122
  %124 = getelementptr inbounds %struct.su2_graph_node, ptr %123, i32 0, i32 1
  %125 = getelementptr inbounds [2 x i32], ptr %124, i64 0, i64 1
  %126 = load i32, ptr %125, align 4, !tbaa !9
  %127 = icmp eq i32 %114, %126
  %128 = zext i1 %127 to i32
  %129 = icmp ne i32 %113, %128
  br i1 %129, label %130, label %131

130:                                              ; preds = %98
  br label %132

131:                                              ; preds = %98
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 385, ptr noundef @__PRETTY_FUNCTION__.su2_graph_is_yoga_edge) #3
  unreachable

132:                                              ; preds = %130
  %133 = load i32, ptr %5, align 4, !tbaa !9
  %134 = load ptr, ptr %4, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.su2_graph, ptr %134, i32 0, i32 0
  %136 = load ptr, ptr %135, align 8, !tbaa !14
  %137 = load ptr, ptr %6, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.su2_graph_edge, ptr %137, i32 0, i32 0
  %139 = getelementptr inbounds [2 x i32], ptr %138, i64 0, i64 0
  %140 = load i32, ptr %139, align 4, !tbaa !9
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds %struct.su2_graph_node, ptr %136, i64 %141
  %143 = getelementptr inbounds %struct.su2_graph_node, ptr %142, i32 0, i32 1
  %144 = getelementptr inbounds [2 x i32], ptr %143, i64 0, i64 0
  %145 = load i32, ptr %144, align 4, !tbaa !9
  %146 = icmp eq i32 %133, %145
  %147 = zext i1 %146 to i32
  %148 = load i32, ptr %5, align 4, !tbaa !9
  %149 = load ptr, ptr %4, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.su2_graph, ptr %149, i32 0, i32 0
  %151 = load ptr, ptr %150, align 8, !tbaa !14
  %152 = load ptr, ptr %6, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.su2_graph_edge, ptr %152, i32 0, i32 0
  %154 = getelementptr inbounds [2 x i32], ptr %153, i64 0, i64 1
  %155 = load i32, ptr %154, align 4, !tbaa !9
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds %struct.su2_graph_node, ptr %151, i64 %156
  %158 = getelementptr inbounds %struct.su2_graph_node, ptr %157, i32 0, i32 1
  %159 = getelementptr inbounds [2 x i32], ptr %158, i64 0, i64 1
  %160 = load i32, ptr %159, align 4, !tbaa !9
  %161 = icmp eq i32 %148, %160
  %162 = zext i1 %161 to i32
  %163 = icmp eq i32 %147, %162
  store i1 %163, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %164

164:                                              ; preds = %132, %63, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %165 = load i1, ptr %3, align 1
  ret i1 %165
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { noreturn nounwind }
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 = !{!"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 = !{!12, !10, i64 20}
!12 = !{!"su2_graph", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 0}
!15 = !{!16, !10, i64 12}
!16 = !{!"su2_graph_node", !10, i64 0, !7, i64 4, !10, i64 12}


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

%struct.su2_graph_edge = type { [2 x i32] }
%struct.su2_graph_node = type { i32, [2 x i32], i32 }

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [35 x i8], align 1
@__PRETTY_FUNCTION__.su2_graph_is_yoga_edge = external hidden unnamed_addr constant [66 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [101 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [101 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @su2_graph_is_yoga_edge(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = icmp sgt i32 %1, -1
  br i1 %3, label %4, label %8

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 20
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, %1
  br i1 %7, label %9, label %8

8:                                                ; preds = %4, %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 372, ptr noundef nonnull @__PRETTY_FUNCTION__.su2_graph_is_yoga_edge) #2
  unreachable

9:                                                ; preds = %4
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = zext nneg i32 %1 to i64
  %13 = getelementptr inbounds %struct.su2_graph_edge, ptr %11, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !12
  %15 = icmp slt i32 %14, 0
  br i1 %15, label %52, label %16

16:                                               ; preds = %9
  %17 = getelementptr inbounds i8, ptr %13, i64 4
  %18 = load i32, ptr %17, align 4, !tbaa !12
  %19 = icmp slt i32 %18, 0
  br i1 %19, label %52, label %20

20:                                               ; preds = %16
  %21 = load ptr, ptr %0, align 8, !tbaa !13
  %22 = zext nneg i32 %14 to i64
  %23 = getelementptr inbounds %struct.su2_graph_node, ptr %21, i64 %22
  %24 = getelementptr inbounds i8, ptr %23, i64 12
  %25 = load i32, ptr %24, align 4, !tbaa !14
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %52, label %27

27:                                               ; preds = %20
  %28 = zext nneg i32 %18 to i64
  %29 = getelementptr inbounds %struct.su2_graph_node, ptr %21, i64 %28
  %30 = getelementptr inbounds i8, ptr %29, i64 12
  %31 = load i32, ptr %30, align 4, !tbaa !14
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %52, label %33

33:                                               ; preds = %27
  %34 = getelementptr inbounds i8, ptr %23, i64 4
  %35 = load i32, ptr %34, align 4, !tbaa !12
  %36 = icmp eq i32 %35, %1
  %37 = getelementptr inbounds i8, ptr %23, i64 8
  %38 = load i32, ptr %37, align 4, !tbaa !12
  %39 = icmp ne i32 %38, %1
  %.not = xor i1 %36, %39
  br i1 %.not, label %40, label %41

40:                                               ; preds = %33
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 384, ptr noundef nonnull @__PRETTY_FUNCTION__.su2_graph_is_yoga_edge) #2
  unreachable

41:                                               ; preds = %33
  %42 = getelementptr inbounds i8, ptr %29, i64 4
  %43 = load i32, ptr %42, align 4, !tbaa !12
  %44 = getelementptr inbounds i8, ptr %29, i64 8
  %45 = load i32, ptr %44, align 4, !tbaa !12
  %46 = icmp eq i32 %45, %1
  %47 = icmp ne i32 %43, %1
  %.not34 = xor i1 %47, %46
  br i1 %.not34, label %48, label %49

48:                                               ; preds = %41
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 385, ptr noundef nonnull @__PRETTY_FUNCTION__.su2_graph_is_yoga_edge) #2
  unreachable

49:                                               ; preds = %41
  %50 = xor i1 %36, %46
  %51 = xor i1 %50, true
  br label %52

52:                                               ; preds = %20, %27, %9, %16, %49
  %.0 = phi i1 [ %51, %49 ], [ false, %16 ], [ false, %9 ], [ false, %27 ], [ false, %20 ]
  ret i1 %.0
}

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

!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 20}
!6 = !{!"su2_graph", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20}
!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 = !{!15, !10, i64 12}
!15 = !{!"su2_graph_node", !10, i64 0, !8, i64 4, !10, i64 12}


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