; LLVM IR from tsotchke/quantum_geometric_tensor :: tests (test_quantum_geometric_minimal)

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

@.str = external hidden unnamed_addr constant [37 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [106 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [15 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [68 x i8], align 1
@__const.main.params = external hidden unnamed_addr constant [1 x double], align 8
@.str.7 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.numerical_config_t, align 8
  %3 = alloca i8, align 1
  %4 = alloca ptr, align 8
  %5 = alloca [1 x i64], align 8
  %6 = alloca [1 x double], align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.ComplexFloat, align 4
  store i32 0, ptr %1, align 4
  %9 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 40, ptr %2) #6
  call void @llvm.memset.p0.i64(ptr align 8 %2, i8 0, i64 40, i1 false)
  %10 = getelementptr inbounds %struct.numerical_config_t, ptr %2, i32 0, i32 1
  store i64 1, ptr %10, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #6
  %11 = call zeroext i1 @initialize_numerical_backend(ptr noundef %2)
  %12 = zext i1 %11 to i8
  store i8 %12, ptr %3, align 1, !tbaa !5
  %13 = load i8, ptr %3, align 1, !tbaa !5, !range !9, !noundef !10
  %14 = trunc i8 %13 to i1
  br i1 %14, label %15, label %17

15:                                               ; preds = %0
  br i1 true, label %16, label %17

16:                                               ; preds = %15
  br label %18

17:                                               ; preds = %15, %0
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.3, i32 noundef 20, ptr noundef @__PRETTY_FUNCTION__.main) #7
  unreachable

18:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %19 = call ptr @create_quantum_geometric_tensor_network(i64 noundef 2, i64 noundef 1, i1 noundef zeroext false, i1 noundef zeroext false)
  store ptr %19, ptr %4, align 8, !tbaa !11
  %20 = load ptr, ptr %4, align 8, !tbaa !11
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %24

22:                                               ; preds = %18
  br i1 true, label %23, label %24

23:                                               ; preds = %22
  br label %25

24:                                               ; preds = %22, %18
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.3, i32 noundef 26, ptr noundef @__PRETTY_FUNCTION__.main) #7
  unreachable

25:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.memset.p0.i64(ptr align 8 %5, i8 0, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 @__const.main.params, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %26 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %27 = getelementptr inbounds [1 x double], ptr %6, i64 0, i64 0
  %28 = call ptr @create_quantum_gate(i32 noundef 7, ptr noundef %26, i64 noundef 1, ptr noundef %27, i64 noundef 1)
  store ptr %28, ptr %7, align 8, !tbaa !11
  %29 = load ptr, ptr %7, align 8, !tbaa !11
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %33

31:                                               ; preds = %25
  br i1 true, label %32, label %33

32:                                               ; preds = %31
  br label %34

33:                                               ; preds = %31, %25
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.3, i32 noundef 32, ptr noundef @__PRETTY_FUNCTION__.main) #7
  unreachable

34:                                               ; preds = %32
  %35 = load ptr, ptr %4, align 8, !tbaa !11
  %36 = load ptr, ptr %7, align 8, !tbaa !11
  %37 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %38 = call zeroext i1 @apply_quantum_gate(ptr noundef %35, ptr noundef %36, ptr noundef %37, i64 noundef 1)
  %39 = zext i1 %38 to i8
  store i8 %39, ptr %3, align 1, !tbaa !5
  %40 = load i8, ptr %3, align 1, !tbaa !5, !range !9, !noundef !10
  %41 = trunc i8 %40 to i1
  br i1 %41, label %42, label %44

42:                                               ; preds = %34
  br i1 true, label %43, label %44

43:                                               ; preds = %42
  br label %45

44:                                               ; preds = %42, %34
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.3, i32 noundef 36, ptr noundef @__PRETTY_FUNCTION__.main) #7
  unreachable

45:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %46 = load ptr, ptr %4, align 8, !tbaa !11
  %47 = call zeroext i1 @compute_quantum_geometric_tensor(ptr noundef %46, i64 noundef 0, i64 noundef 0, ptr noundef %8)
  %48 = zext i1 %47 to i8
  store i8 %48, ptr %3, align 1, !tbaa !5
  %49 = load i8, ptr %3, align 1, !tbaa !5, !range !9, !noundef !10
  %50 = trunc i8 %49 to i1
  br i1 %50, label %51, label %53

51:                                               ; preds = %45
  br i1 true, label %52, label %53

52:                                               ; preds = %51
  br label %54

53:                                               ; preds = %51, %45
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.3, i32 noundef 41, ptr noundef @__PRETTY_FUNCTION__.main) #7
  unreachable

54:                                               ; preds = %52
  %55 = getelementptr inbounds %struct.ComplexFloat, ptr %8, i32 0, i32 0
  %56 = load float, ptr %55, align 4, !tbaa !13
  %57 = fpext float %56 to double
  %58 = getelementptr inbounds %struct.ComplexFloat, ptr %8, i32 0, i32 1
  %59 = load float, ptr %58, align 4, !tbaa !16
  %60 = fpext float %59 to double
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, double noundef %57, double noundef %60)
  %62 = load ptr, ptr %7, align 8, !tbaa !11
  call void @destroy_quantum_gate(ptr noundef %62)
  %63 = load ptr, ptr %4, align 8, !tbaa !11
  call void @destroy_quantum_geometric_tensor_network(ptr noundef %63)
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %2) #6
  ret i32 0
}

declare i32 @printf(ptr noundef, ...) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare zeroext i1 @initialize_numerical_backend(ptr noundef) #1

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

declare ptr @create_quantum_geometric_tensor_network(i64 noundef, i64 noundef, i1 noundef zeroext, i1 noundef zeroext) #1

; 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 ptr @create_quantum_gate(i32 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) #1

declare zeroext i1 @apply_quantum_gate(ptr noundef, ptr noundef, ptr noundef, i64 noundef) #1

declare zeroext i1 @compute_quantum_geometric_tensor(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #1

declare void @destroy_quantum_gate(ptr noundef) #1

declare void @destroy_quantum_geometric_tensor_network(ptr noundef) #1

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

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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { 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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"", !15, i64 0, !15, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!14, !15, i64 4}


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

@.str = external hidden unnamed_addr constant [37 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [106 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [15 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [68 x i8], align 1
@__const.main.params = external hidden unnamed_addr constant [1 x double], align 8
@.str.7 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.numerical_config_t, align 8
  %2 = alloca [1 x i64], align 8
  %3 = alloca [1 x double], align 8
  %4 = alloca %struct.ComplexFloat, align 4
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %1) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %1, i8 0, i64 40, i1 false)
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 1, ptr %6, align 8
  %7 = call zeroext i1 @initialize_numerical_backend(ptr noundef nonnull %1) #6
  br i1 %7, label %9, label %8

8:                                                ; preds = %0
  call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, i32 noundef 20, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #7
  unreachable

9:                                                ; preds = %0
  %10 = call ptr @create_quantum_geometric_tensor_network(i64 noundef 2, i64 noundef 1, i1 noundef zeroext false, i1 noundef zeroext false) #6
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %11, label %12

11:                                               ; preds = %9
  call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.3, i32 noundef 26, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #7
  unreachable

12:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  store i64 0, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %13 = load i64, ptr @__const.main.params, align 8
  store i64 %13, ptr %3, align 8
  %14 = call ptr @create_quantum_gate(i32 noundef 7, ptr noundef nonnull %2, i64 noundef 1, ptr noundef nonnull %3, i64 noundef 1) #6
  %.not10 = icmp eq ptr %14, null
  br i1 %.not10, label %15, label %16

15:                                               ; preds = %12
  call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.3, i32 noundef 32, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #7
  unreachable

16:                                               ; preds = %12
  %17 = call zeroext i1 @apply_quantum_gate(ptr noundef nonnull %10, ptr noundef nonnull %14, ptr noundef nonnull %2, i64 noundef 1) #6
  br i1 %17, label %19, label %18

18:                                               ; preds = %16
  call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.3, i32 noundef 36, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #7
  unreachable

19:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %20 = call zeroext i1 @compute_quantum_geometric_tensor(ptr noundef nonnull %10, i64 noundef 0, i64 noundef 0, ptr noundef nonnull %4) #6
  br i1 %20, label %22, label %21

21:                                               ; preds = %19
  call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.3, i32 noundef 41, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #7
  unreachable

22:                                               ; preds = %19
  %23 = load float, ptr %4, align 4, !tbaa !5
  %24 = fpext float %23 to double
  %25 = getelementptr inbounds i8, ptr %4, i64 4
  %26 = load float, ptr %25, align 4, !tbaa !10
  %27 = fpext float %26 to double
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, double noundef %24, double noundef %27)
  call void @destroy_quantum_gate(ptr noundef nonnull %14) #6
  call void @destroy_quantum_geometric_tensor_network(ptr noundef nonnull %10) #6
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %1) #6
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare zeroext i1 @initialize_numerical_backend(ptr noundef) local_unnamed_addr #4

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

declare ptr @create_quantum_geometric_tensor_network(i64 noundef, i64 noundef, i1 noundef zeroext, i1 noundef zeroext) local_unnamed_addr #4

declare ptr @create_quantum_gate(i32 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

declare zeroext i1 @apply_quantum_gate(ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

declare zeroext i1 @compute_quantum_geometric_tensor(ptr noundef, i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #4

declare void @destroy_quantum_gate(ptr noundef) local_unnamed_addr #4

declare void @destroy_quantum_geometric_tensor_network(ptr noundef) local_unnamed_addr #4

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

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 = { nofree 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { "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 = { 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 #6 = { nounwind }
attributes #7 = { 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}


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