; LLVM IR from tsotchke/quantum_geometric_tensor :: src/quantum_geometric/core (quantum_geometric_tensor_network)

; 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.ComplexFloat = type { float, float }
%struct.quantum_geometric_tensor_network = type { ptr, ptr, i64, i64, i8, i8 }
%struct.quantum_circuit_t = type { ptr, i64, i64, i8 }

@.str.1 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1
@__const.create_quantum_geometric_tensor_network.zero_state = external hidden unnamed_addr constant [2 x %struct.ComplexFloat], align 16
@.str.3 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @create_quantum_geometric_tensor_network(i64 noundef %0, i64 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca [2 x %struct.ComplexFloat], align 16
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  store i64 %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !5
  %17 = zext i1 %2 to i8
  store i8 %17, ptr %8, align 1, !tbaa !9
  %18 = zext i1 %3 to i8
  store i8 %18, ptr %9, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %19 = call noalias ptr @malloc(i64 noundef 40) #7
  store ptr %19, ptr %10, align 8, !tbaa !11
  %20 = load ptr, ptr %10, align 8, !tbaa !11
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %4
  call void @set_error(ptr noundef @.str.1)
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %144

23:                                               ; preds = %4
  %24 = call ptr @create_tensor_network()
  %25 = load ptr, ptr %10, align 8, !tbaa !11
  %26 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %25, i32 0, i32 0
  store ptr %24, ptr %26, align 8, !tbaa !13
  %27 = load ptr, ptr %10, align 8, !tbaa !11
  %28 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = icmp ne ptr %29, null
  br i1 %30, label %33, label %31

31:                                               ; preds = %23
  %32 = load ptr, ptr %10, align 8, !tbaa !11
  call void @free(ptr noundef %32) #6
  call void @set_error(ptr noundef @.str.2)
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %144

33:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %12, ptr align 16 @__const.create_quantum_geometric_tensor_network.zero_state, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store i64 2, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  store i64 0, ptr %14, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %54, %33
  %35 = load i64, ptr %14, align 8, !tbaa !5
  %36 = load i64, ptr %6, align 8, !tbaa !5
  %37 = icmp ult i64 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  store i32 2, ptr %11, align 4
  br label %57

39:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %40 = load ptr, ptr %10, align 8, !tbaa !11
  %41 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = getelementptr inbounds [2 x %struct.ComplexFloat], ptr %12, i64 0, i64 0
  %44 = call zeroext i1 @add_tensor_node(ptr noundef %42, ptr noundef %43, ptr noundef %13, i64 noundef 1, ptr noundef %15)
  br i1 %44, label %50, label %45

45:                                               ; preds = %39
  %46 = load ptr, ptr %10, align 8, !tbaa !11
  %47 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  call void @destroy_tensor_network(ptr noundef %48)
  %49 = load ptr, ptr %10, align 8, !tbaa !11
  call void @free(ptr noundef %49) #6
  call void @set_error(ptr noundef @.str.3)
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %51

50:                                               ; preds = %39
  store i32 0, ptr %11, align 4
  br label %51

51:                                               ; preds = %50, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  %52 = load i32, ptr %11, align 4
  switch i32 %52, label %57 [
    i32 0, label %53
  ]

53:                                               ; preds = %51
  br label %54

54:                                               ; preds = %53
  %55 = load i64, ptr %14, align 8, !tbaa !5
  %56 = add i64 %55, 1
  store i64 %56, ptr %14, align 8, !tbaa !5
  br label %34, !llvm.loop !15

57:                                               ; preds = %51, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  %58 = load i32, ptr %11, align 4
  switch i32 %58, label %143 [
    i32 2, label %59
  ]

59:                                               ; preds = %57
  %60 = call noalias ptr @malloc(i64 noundef 32) #7
  %61 = load ptr, ptr %10, align 8, !tbaa !11
  %62 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %61, i32 0, i32 1
  store ptr %60, ptr %62, align 8, !tbaa !17
  %63 = load ptr, ptr %10, align 8, !tbaa !11
  %64 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %63, i32 0, i32 1
  %65 = load ptr, ptr %64, align 8, !tbaa !17
  %66 = icmp ne ptr %65, null
  br i1 %66, label %72, label %67

67:                                               ; preds = %59
  %68 = load ptr, ptr %10, align 8, !tbaa !11
  %69 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !13
  call void @destroy_tensor_network(ptr noundef %70)
  %71 = load ptr, ptr %10, align 8, !tbaa !11
  call void @free(ptr noundef %71) #6
  call void @set_error(ptr noundef @.str.4)
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %143

72:                                               ; preds = %59
  %73 = load i64, ptr %7, align 8, !tbaa !5
  %74 = mul i64 %73, 8
  %75 = call noalias ptr @malloc(i64 noundef %74) #7
  %76 = load ptr, ptr %10, align 8, !tbaa !11
  %77 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %76, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !17
  %79 = getelementptr inbounds %struct.quantum_circuit_t, ptr %78, i32 0, i32 0
  store ptr %75, ptr %79, align 8, !tbaa !18
  %80 = load ptr, ptr %10, align 8, !tbaa !11
  %81 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %80, i32 0, i32 1
  %82 = load ptr, ptr %81, align 8, !tbaa !17
  %83 = getelementptr inbounds %struct.quantum_circuit_t, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !18
  %85 = icmp ne ptr %84, null
  br i1 %85, label %94, label %86

86:                                               ; preds = %72
  %87 = load ptr, ptr %10, align 8, !tbaa !11
  %88 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %87, i32 0, i32 1
  %89 = load ptr, ptr %88, align 8, !tbaa !17
  call void @free(ptr noundef %89) #6
  %90 = load ptr, ptr %10, align 8, !tbaa !11
  %91 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !13
  call void @destroy_tensor_network(ptr noundef %92)
  %93 = load ptr, ptr %10, align 8, !tbaa !11
  call void @free(ptr noundef %93) #6
  call void @set_error(ptr noundef @.str.5)
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %143

94:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  store i64 0, ptr %16, align 8, !tbaa !5
  br label %95

95:                                               ; preds = %108, %94
  %96 = load i64, ptr %16, align 8, !tbaa !5
  %97 = load i64, ptr %7, align 8, !tbaa !5
  %98 = icmp ult i64 %96, %97
  br i1 %98, label %100, label %99

99:                                               ; preds = %95
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  br label %111

100:                                              ; preds = %95
  %101 = load ptr, ptr %10, align 8, !tbaa !11
  %102 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %101, i32 0, i32 1
  %103 = load ptr, ptr %102, align 8, !tbaa !17
  %104 = getelementptr inbounds %struct.quantum_circuit_t, ptr %103, i32 0, i32 0
  %105 = load ptr, ptr %104, align 8, !tbaa !18
  %106 = load i64, ptr %16, align 8, !tbaa !5
  %107 = getelementptr inbounds ptr, ptr %105, i64 %106
  store ptr null, ptr %107, align 8, !tbaa !11
  br label %108

108:                                              ; preds = %100
  %109 = load i64, ptr %16, align 8, !tbaa !5
  %110 = add i64 %109, 1
  store i64 %110, ptr %16, align 8, !tbaa !5
  br label %95, !llvm.loop !20

111:                                              ; preds = %99
  %112 = load i64, ptr %7, align 8, !tbaa !5
  %113 = load ptr, ptr %10, align 8, !tbaa !11
  %114 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %113, i32 0, i32 1
  %115 = load ptr, ptr %114, align 8, !tbaa !17
  %116 = getelementptr inbounds %struct.quantum_circuit_t, ptr %115, i32 0, i32 1
  store i64 %112, ptr %116, align 8, !tbaa !21
  %117 = load i64, ptr %6, align 8, !tbaa !5
  %118 = load ptr, ptr %10, align 8, !tbaa !11
  %119 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %118, i32 0, i32 1
  %120 = load ptr, ptr %119, align 8, !tbaa !17
  %121 = getelementptr inbounds %struct.quantum_circuit_t, ptr %120, i32 0, i32 2
  store i64 %117, ptr %121, align 8, !tbaa !22
  %122 = load ptr, ptr %10, align 8, !tbaa !11
  %123 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %122, i32 0, i32 1
  %124 = load ptr, ptr %123, align 8, !tbaa !17
  %125 = getelementptr inbounds %struct.quantum_circuit_t, ptr %124, i32 0, i32 3
  store i8 0, ptr %125, align 8, !tbaa !23
  %126 = load i64, ptr %6, align 8, !tbaa !5
  %127 = load ptr, ptr %10, align 8, !tbaa !11
  %128 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %127, i32 0, i32 2
  store i64 %126, ptr %128, align 8, !tbaa !24
  %129 = load i64, ptr %7, align 8, !tbaa !5
  %130 = load ptr, ptr %10, align 8, !tbaa !11
  %131 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %130, i32 0, i32 3
  store i64 %129, ptr %131, align 8, !tbaa !25
  %132 = load i8, ptr %8, align 1, !tbaa !9, !range !26, !noundef !27
  %133 = trunc i8 %132 to i1
  %134 = load ptr, ptr %10, align 8, !tbaa !11
  %135 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %134, i32 0, i32 4
  %136 = zext i1 %133 to i8
  store i8 %136, ptr %135, align 8, !tbaa !28
  %137 = load i8, ptr %9, align 1, !tbaa !9, !range !26, !noundef !27
  %138 = trunc i8 %137 to i1
  %139 = load ptr, ptr %10, align 8, !tbaa !11
  %140 = getelementptr inbounds %struct.quantum_geometric_tensor_network, ptr %139, i32 0, i32 5
  %141 = zext i1 %138 to i8
  store i8 %141, ptr %140, align 1, !tbaa !29
  %142 = load ptr, ptr %10, align 8, !tbaa !11
  store ptr %142, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %143

143:                                              ; preds = %111, %86, %67, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #6
  br label %144

144:                                              ; preds = %143, %31, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  %145 = load ptr, ptr %5, align 8
  ret ptr %145
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @set_error(ptr noundef) #0

declare ptr @create_tensor_network() #3

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

declare zeroext i1 @add_tensor_node(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) #3

declare void @destroy_tensor_network(ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind allocsize(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 = { "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 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"quantum_geometric_tensor_network", !12, i64 0, !12, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 33}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!14, !12, i64 8}
!18 = !{!19, !12, i64 0}
!19 = !{!"quantum_circuit_t", !12, i64 0, !6, i64 8, !6, i64 16, !10, i64 24}
!20 = distinct !{!20, !16}
!21 = !{!19, !6, i64 8}
!22 = !{!19, !6, i64 16}
!23 = !{!19, !10, i64 24}
!24 = !{!14, !6, i64 16}
!25 = !{!14, !6, i64 24}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{!14, !10, i64 32}
!29 = !{!14, !10, i64 33}


; 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.ComplexFloat = type { float, float }

@.str.1 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1
@__const.create_quantum_geometric_tensor_network.zero_state = external hidden unnamed_addr constant [2 x %struct.ComplexFloat], align 16
@.str.3 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @create_quantum_geometric_tensor_network(i64 noundef %0, i64 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = alloca [2 x %struct.ComplexFloat], align 16
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = zext i1 %2 to i8
  %9 = zext i1 %3 to i8
  %10 = tail call noalias dereferenceable_or_null(40) ptr @malloc(i64 noundef 40) #6
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %11, label %12

11:                                               ; preds = %4
  tail call void @set_error(ptr noundef nonnull @.str.1)
  br label %50

12:                                               ; preds = %4
  %13 = tail call ptr @create_tensor_network() #7
  store ptr %13, ptr %10, align 8, !tbaa !5
  %.not48 = icmp eq ptr %13, null
  br i1 %.not48, label %14, label %15

14:                                               ; preds = %12
  tail call void @free(ptr noundef nonnull %10) #7
  tail call void @set_error(ptr noundef nonnull @.str.2)
  br label %50

15:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %5, ptr noundef nonnull align 16 dereferenceable(16) @__const.create_quantum_geometric_tensor_network.zero_state, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  store i64 2, ptr %6, align 8, !tbaa !12
  %.not4954.not = icmp eq i64 %0, 0
  br i1 %.not4954.not, label %.critedge53, label %.lr.ph

.lr.ph:                                           ; preds = %15, %.critedge
  %.04255 = phi i64 [ %18, %.critedge ], [ 0, %15 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #7
  %16 = call zeroext i1 @add_tensor_node(ptr noundef nonnull %13, ptr noundef nonnull %5, ptr noundef nonnull %6, i64 noundef 1, ptr noundef nonnull %7) #7
  br i1 %16, label %.critedge, label %17

17:                                               ; preds = %.lr.ph
  call void @destroy_tensor_network(ptr noundef nonnull %13) #7
  call void @free(ptr noundef %10) #7
  call void @set_error(ptr noundef nonnull @.str.3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #7
  br label %49

.critedge:                                        ; preds = %.lr.ph
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #7
  %18 = add nuw i64 %.04255, 1
  %exitcond.not = icmp eq i64 %18, %0
  br i1 %exitcond.not, label %.critedge53, label %.lr.ph, !llvm.loop !13

.critedge53:                                      ; preds = %.critedge, %15
  %19 = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #6
  %20 = getelementptr inbounds i8, ptr %10, i64 8
  store ptr %19, ptr %20, align 8, !tbaa !15
  %.not50 = icmp eq ptr %19, null
  br i1 %.not50, label %21, label %22

21:                                               ; preds = %.critedge53
  call void @destroy_tensor_network(ptr noundef nonnull %13) #7
  call void @free(ptr noundef nonnull %10) #7
  call void @set_error(ptr noundef nonnull @.str.4)
  br label %49

22:                                               ; preds = %.critedge53
  %23 = shl i64 %1, 3
  %24 = call noalias ptr @malloc(i64 noundef %23) #6
  store ptr %24, ptr %19, align 8, !tbaa !16
  %.not51 = icmp eq ptr %24, null
  br i1 %.not51, label %26, label %.preheader

.preheader:                                       ; preds = %22
  %.not58 = icmp eq i64 %1, 0
  br i1 %.not58, label %._crit_edge, label %.lr.ph57.preheader

.lr.ph57.preheader:                               ; preds = %.preheader
  %xtraiter = and i64 %1, 3
  %25 = icmp ult i64 %1, 4
  br i1 %25, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph57.preheader.new

.lr.ph57.preheader.new:                           ; preds = %.lr.ph57.preheader
  %unroll_iter = and i64 %1, -4
  br label %.lr.ph57

26:                                               ; preds = %22
  call void @free(ptr noundef nonnull %19) #7
  call void @destroy_tensor_network(ptr noundef nonnull %13) #7
  call void @free(ptr noundef nonnull %10) #7
  call void @set_error(ptr noundef nonnull @.str.5)
  br label %49

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph57, %.lr.ph57.preheader
  %.056.unr = phi i64 [ 0, %.lr.ph57.preheader ], [ %48, %.lr.ph57 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph57.epil

.lr.ph57.epil:                                    ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph57.epil
  %.056.epil = phi i64 [ %29, %.lr.ph57.epil ], [ %.056.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph57.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %27 = load ptr, ptr %19, align 8, !tbaa !16
  %28 = getelementptr inbounds ptr, ptr %27, i64 %.056.epil
  store ptr null, ptr %28, align 8, !tbaa !18
  %29 = add nuw i64 %.056.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph57.epil, !llvm.loop !19

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph57.epil, %.preheader
  %30 = getelementptr inbounds i8, ptr %19, i64 8
  store i64 %1, ptr %30, align 8, !tbaa !21
  %31 = getelementptr inbounds i8, ptr %19, i64 16
  store i64 %0, ptr %31, align 8, !tbaa !22
  %32 = getelementptr inbounds i8, ptr %19, i64 24
  store i8 0, ptr %32, align 8, !tbaa !23
  %33 = getelementptr inbounds i8, ptr %10, i64 16
  store i64 %0, ptr %33, align 8, !tbaa !24
  %34 = getelementptr inbounds i8, ptr %10, i64 24
  store i64 %1, ptr %34, align 8, !tbaa !25
  %35 = getelementptr inbounds i8, ptr %10, i64 32
  store i8 %8, ptr %35, align 8, !tbaa !26
  %36 = getelementptr inbounds i8, ptr %10, i64 33
  store i8 %9, ptr %36, align 1, !tbaa !27
  br label %49

.lr.ph57:                                         ; preds = %.lr.ph57, %.lr.ph57.preheader.new
  %.056 = phi i64 [ 0, %.lr.ph57.preheader.new ], [ %48, %.lr.ph57 ]
  %niter = phi i64 [ 0, %.lr.ph57.preheader.new ], [ %niter.next.3, %.lr.ph57 ]
  %37 = load ptr, ptr %19, align 8, !tbaa !16
  %38 = getelementptr inbounds ptr, ptr %37, i64 %.056
  store ptr null, ptr %38, align 8, !tbaa !18
  %39 = or disjoint i64 %.056, 1
  %40 = load ptr, ptr %19, align 8, !tbaa !16
  %41 = getelementptr inbounds ptr, ptr %40, i64 %39
  store ptr null, ptr %41, align 8, !tbaa !18
  %42 = or disjoint i64 %.056, 2
  %43 = load ptr, ptr %19, align 8, !tbaa !16
  %44 = getelementptr inbounds ptr, ptr %43, i64 %42
  store ptr null, ptr %44, align 8, !tbaa !18
  %45 = or disjoint i64 %.056, 3
  %46 = load ptr, ptr %19, align 8, !tbaa !16
  %47 = getelementptr inbounds ptr, ptr %46, i64 %45
  store ptr null, ptr %47, align 8, !tbaa !18
  %48 = add nuw i64 %.056, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph57, !llvm.loop !28

49:                                               ; preds = %17, %._crit_edge, %26, %21
  %.3 = phi ptr [ %10, %._crit_edge ], [ null, %26 ], [ null, %21 ], [ null, %17 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #7
  br label %50

50:                                               ; preds = %49, %14, %11
  %.4 = phi ptr [ %.3, %49 ], [ null, %14 ], [ null, %11 ]
  ret ptr %.4
}

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @set_error(ptr noundef) local_unnamed_addr #0

declare ptr @create_tensor_network() local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

declare zeroext i1 @add_tensor_node(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #3

declare void @destroy_tensor_network(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { 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, !7, i64 0}
!6 = !{!"quantum_geometric_tensor_network", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !11, i64 32, !11, i64 33}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!10, !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!6, !7, i64 8}
!16 = !{!17, !7, i64 0}
!17 = !{!"quantum_circuit_t", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.unroll.disable"}
!21 = !{!17, !10, i64 8}
!22 = !{!17, !10, i64 16}
!23 = !{!17, !11, i64 24}
!24 = !{!6, !10, i64 16}
!25 = !{!6, !10, i64 24}
!26 = !{!6, !11, i64 32}
!27 = !{!6, !11, i64 33}
!28 = distinct !{!28, !14}


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