; 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_fuse_split_tree = type { ptr, ptr, i32 }
%struct.su2_tree_node = type { i32, [2 x ptr] }
%struct.su2_graph_edge = type { [2 x i32] }

@.str = external hidden unnamed_addr constant [48 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@__PRETTY_FUNCTION__.su2_graph_from_fuse_split_tree = external hidden unnamed_addr constant [92 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @ct_malloc(i64 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local void @su2_graph_from_fuse_split_tree(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.su2_graph, ptr %6, i32 0, i32 2
  store i32 0, ptr %7, align 8, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.su2_fuse_split_tree, ptr %8, i32 0, i32 2
  %10 = load i32, ptr %9, align 8, !tbaa !12
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.su2_graph, ptr %11, i32 0, i32 3
  store i32 %10, ptr %12, align 4, !tbaa !14
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.su2_graph, ptr %13, i32 0, i32 3
  %15 = load i32, ptr %14, align 4, !tbaa !14
  %16 = sext i32 %15 to i64
  %17 = mul i64 %16, 16
  %18 = call ptr @ct_malloc(i64 noundef %17)
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.su2_graph, ptr %19, i32 0, i32 0
  store ptr %18, ptr %20, align 8, !tbaa !15
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.su2_graph, ptr %21, i32 0, i32 3
  %23 = load i32, ptr %22, align 4, !tbaa !14
  %24 = sext i32 %23 to i64
  %25 = mul i64 %24, 8
  %26 = call ptr @ct_malloc(i64 noundef %25)
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.su2_graph, ptr %27, i32 0, i32 1
  store ptr %26, ptr %28, align 8, !tbaa !16
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.su2_fuse_split_tree, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !17
  %32 = getelementptr inbounds %struct.su2_tree_node, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !18
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.su2_fuse_split_tree, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !20
  %37 = getelementptr inbounds %struct.su2_tree_node, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !18
  %39 = icmp eq i32 %33, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %2
  br label %42

41:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 211, ptr noundef @__PRETTY_FUNCTION__.su2_graph_from_fuse_split_tree) #4
  unreachable

42:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.su2_graph, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !16
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.su2_fuse_split_tree, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  %49 = getelementptr inbounds %struct.su2_tree_node, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 8, !tbaa !18
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds %struct.su2_graph_edge, ptr %45, i64 %51
  store ptr %52, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.su2_fuse_split_tree, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = call i32 @su2_subgraph_from_tree(ptr noundef %55, i32 noundef 0, ptr noundef %56)
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.su2_graph_edge, ptr %58, i32 0, i32 0
  %60 = getelementptr inbounds [2 x i32], ptr %59, i64 0, i64 0
  store i32 %57, ptr %60, align 4, !tbaa !21
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.su2_fuse_split_tree, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !20
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = call i32 @su2_subgraph_from_tree(ptr noundef %63, i32 noundef 1, ptr noundef %64)
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.su2_graph_edge, ptr %66, i32 0, i32 0
  %68 = getelementptr inbounds [2 x i32], ptr %67, i64 0, i64 1
  store i32 %65, ptr %68, align 4, !tbaa !21
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.su2_graph, ptr %69, i32 0, i32 2
  %71 = load i32, ptr %70, align 8, !tbaa !9
  %72 = icmp sgt i32 %71, 0
  br i1 %72, label %73, label %74

73:                                               ; preds = %42
  br label %75

74:                                               ; preds = %42
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 216, ptr noundef @__PRETTY_FUNCTION__.su2_graph_from_fuse_split_tree) #4
  unreachable

75:                                               ; preds = %73
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.su2_graph, ptr %76, i32 0, i32 2
  %78 = load i32, ptr %77, align 8, !tbaa !9
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.su2_graph, ptr %79, i32 0, i32 3
  %81 = load i32, ptr %80, align 4, !tbaa !14
  %82 = icmp sle i32 %78, %81
  br i1 %82, label %83, label %84

83:                                               ; preds = %75
  br label %85

84:                                               ; preds = %75
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 217, ptr noundef @__PRETTY_FUNCTION__.su2_graph_from_fuse_split_tree) #4
  unreachable

85:                                               ; preds = %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @su2_subgraph_from_tree(ptr noundef, i32 noundef, ptr noundef) #2

attributes #0 = { inlinehint 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 #4 = { noreturn nounwind }
attributes #5 = { 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 = !{!"su2_graph", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 16}
!13 = !{!"su2_fuse_split_tree", !6, i64 0, !6, i64 8, !11, i64 16}
!14 = !{!10, !11, i64 20}
!15 = !{!10, !6, i64 0}
!16 = !{!10, !6, i64 8}
!17 = !{!13, !6, i64 0}
!18 = !{!19, !11, i64 0}
!19 = !{!"su2_tree_node", !11, i64 0, !7, i64 8}
!20 = !{!13, !6, i64 8}
!21 = !{!11, !11, i64 0}


; 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] }

@.str = external hidden unnamed_addr constant [48 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@__PRETTY_FUNCTION__.su2_graph_from_fuse_split_tree = external hidden unnamed_addr constant [92 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @ct_malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @su2_graph_from_fuse_split_tree(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 0, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load i32, ptr %4, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %1, i64 20
  store i32 %5, ptr %6, align 4, !tbaa !13
  %7 = sext i32 %5 to i64
  %8 = shl nsw i64 %7, 4
  %9 = tail call ptr @ct_malloc(i64 noundef %8)
  store ptr %9, ptr %1, align 8, !tbaa !14
  %10 = load i32, ptr %6, align 4, !tbaa !13
  %11 = sext i32 %10 to i64
  %12 = shl nsw i64 %11, 3
  %13 = tail call ptr @ct_malloc(i64 noundef %12)
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr %13, ptr %14, align 8, !tbaa !15
  %15 = load ptr, ptr %0, align 8, !tbaa !16
  %16 = load i32, ptr %15, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !19
  %19 = load i32, ptr %18, align 8, !tbaa !17
  %20 = icmp eq i32 %16, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 211, ptr noundef nonnull @__PRETTY_FUNCTION__.su2_graph_from_fuse_split_tree) #3
  unreachable

22:                                               ; preds = %2
  %23 = sext i32 %16 to i64
  %24 = getelementptr inbounds %struct.su2_graph_edge, ptr %13, i64 %23
  %25 = tail call i32 @su2_subgraph_from_tree(ptr noundef nonnull %15, i32 noundef 0, ptr noundef nonnull %1)
  store i32 %25, ptr %24, align 4, !tbaa !20
  %26 = load ptr, ptr %17, align 8, !tbaa !19
  %27 = tail call i32 @su2_subgraph_from_tree(ptr noundef %26, i32 noundef 1, ptr noundef nonnull %1)
  %28 = getelementptr inbounds i8, ptr %24, i64 4
  store i32 %27, ptr %28, align 4, !tbaa !20
  %29 = load i32, ptr %3, align 8, !tbaa !5
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %32, label %31

31:                                               ; preds = %22
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 216, ptr noundef nonnull @__PRETTY_FUNCTION__.su2_graph_from_fuse_split_tree) #3
  unreachable

32:                                               ; preds = %22
  %33 = load i32, ptr %6, align 4, !tbaa !13
  %.not = icmp sgt i32 %29, %33
  br i1 %.not, label %34, label %35

34:                                               ; preds = %32
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 217, ptr noundef nonnull @__PRETTY_FUNCTION__.su2_graph_from_fuse_split_tree) #3
  unreachable

35:                                               ; preds = %32
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @su2_subgraph_from_tree(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { inlinehint 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 = { 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 = { 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 = !{!"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 = !{!12, !10, i64 16}
!12 = !{!"su2_fuse_split_tree", !7, i64 0, !7, i64 8, !10, i64 16}
!13 = !{!6, !10, i64 20}
!14 = !{!6, !7, i64 0}
!15 = !{!6, !7, i64 8}
!16 = !{!12, !7, i64 0}
!17 = !{!18, !10, i64 0}
!18 = !{!"su2_tree_node", !10, i64 0, !8, i64 8}
!19 = !{!12, !7, i64 8}
!20 = !{!10, !10, i64 0}


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