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

; 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.Stream = type { ptr, i8 }

@streams = external hidden global [16 x %struct.Stream], align 16
@is_initialized = external hidden global 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 i32 @geometric_core_validate_stream(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %10

9:                                                ; preds = %1
  store i32 -1, ptr %2, align 4
  br label %46

10:                                               ; preds = %1
  %11 = load i8, ptr @is_initialized, align 1, !tbaa !9, !range !11, !noundef !12
  %12 = trunc i8 %11 to i1
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  store i32 -4, ptr %2, align 4
  br label %46

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #2
  store i8 0, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !13
  br label %15

15:                                               ; preds = %36, %14
  %16 = load i32, ptr %5, align 4, !tbaa !13
  %17 = icmp slt i32 %16, 16
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  store i32 2, ptr %6, align 4
  br label %39

19:                                               ; preds = %15
  %20 = load i32, ptr %5, align 4, !tbaa !13
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [16 x %struct.Stream], ptr @streams, i64 0, i64 %21
  %23 = getelementptr inbounds %struct.Stream, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 16, !tbaa !15
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = icmp eq ptr %24, %25
  br i1 %26, label %27, label %35

27:                                               ; preds = %19
  %28 = load i32, ptr %5, align 4, !tbaa !13
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [16 x %struct.Stream], ptr @streams, i64 0, i64 %29
  %31 = getelementptr inbounds %struct.Stream, ptr %30, i32 0, i32 1
  %32 = load i8, ptr %31, align 8, !tbaa !17, !range !11, !noundef !12
  %33 = trunc i8 %32 to i1
  br i1 %33, label %34, label %35

34:                                               ; preds = %27
  store i8 1, ptr %4, align 1, !tbaa !9
  store i32 2, ptr %6, align 4
  br label %39

35:                                               ; preds = %27, %19
  br label %36

36:                                               ; preds = %35
  %37 = load i32, ptr %5, align 4, !tbaa !13
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %5, align 4, !tbaa !13
  br label %15, !llvm.loop !18

39:                                               ; preds = %34, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %40

40:                                               ; preds = %39
  %41 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %42 = trunc i8 %41 to i1
  br i1 %42, label %44, label %43

43:                                               ; preds = %40
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %45

44:                                               ; preds = %40
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %45

45:                                               ; preds = %44, %43
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #2
  br label %46

46:                                               ; preds = %45, %13, %9
  %47 = load i32, ptr %2, align 4
  ret i32 %47
}

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 = { 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 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"Stream", !6, i64 0, !10, i64 8}
!17 = !{!16, !10, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; 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.Stream = type { ptr, i8 }

@streams = external hidden local_unnamed_addr global [16 x %struct.Stream], align 16
@is_initialized = external hidden local_unnamed_addr global i8, align 1

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local range(i32 -4, 1) i32 @geometric_core_validate_stream(ptr noundef readnone %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %87, label %3

3:                                                ; preds = %1
  %4 = load i8, ptr @is_initialized, align 1, !tbaa !5, !range !9, !noundef !10
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %.preheader.preheader, label %87

.preheader.preheader:                             ; preds = %3
  %6 = load ptr, ptr @streams, align 16, !tbaa !11
  %7 = icmp eq ptr %6, %0
  br i1 %7, label %8, label %.preheader.1

8:                                                ; preds = %.preheader.preheader
  %9 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 8), align 8, !tbaa !14, !range !9, !noundef !10
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %87, label %.preheader.1

.preheader.1:                                     ; preds = %.preheader.preheader, %8
  %11 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 16), align 16, !tbaa !11
  %12 = icmp eq ptr %11, %0
  br i1 %12, label %13, label %.preheader.2

13:                                               ; preds = %.preheader.1
  %14 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 24), align 8, !tbaa !14, !range !9, !noundef !10
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %87, label %.preheader.2

.preheader.2:                                     ; preds = %13, %.preheader.1
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 32), align 16, !tbaa !11
  %17 = icmp eq ptr %16, %0
  br i1 %17, label %18, label %.preheader.3

18:                                               ; preds = %.preheader.2
  %19 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 40), align 8, !tbaa !14, !range !9, !noundef !10
  %20 = trunc nuw i8 %19 to i1
  br i1 %20, label %87, label %.preheader.3

.preheader.3:                                     ; preds = %18, %.preheader.2
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 48), align 16, !tbaa !11
  %22 = icmp eq ptr %21, %0
  br i1 %22, label %23, label %.preheader.4

23:                                               ; preds = %.preheader.3
  %24 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 56), align 8, !tbaa !14, !range !9, !noundef !10
  %25 = trunc nuw i8 %24 to i1
  br i1 %25, label %87, label %.preheader.4

.preheader.4:                                     ; preds = %23, %.preheader.3
  %26 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 64), align 16, !tbaa !11
  %27 = icmp eq ptr %26, %0
  br i1 %27, label %28, label %.preheader.5

28:                                               ; preds = %.preheader.4
  %29 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 72), align 8, !tbaa !14, !range !9, !noundef !10
  %30 = trunc nuw i8 %29 to i1
  br i1 %30, label %87, label %.preheader.5

.preheader.5:                                     ; preds = %28, %.preheader.4
  %31 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 80), align 16, !tbaa !11
  %32 = icmp eq ptr %31, %0
  br i1 %32, label %33, label %.preheader.6

33:                                               ; preds = %.preheader.5
  %34 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 88), align 8, !tbaa !14, !range !9, !noundef !10
  %35 = trunc nuw i8 %34 to i1
  br i1 %35, label %87, label %.preheader.6

.preheader.6:                                     ; preds = %33, %.preheader.5
  %36 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 96), align 16, !tbaa !11
  %37 = icmp eq ptr %36, %0
  br i1 %37, label %38, label %.preheader.7

38:                                               ; preds = %.preheader.6
  %39 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 104), align 8, !tbaa !14, !range !9, !noundef !10
  %40 = trunc nuw i8 %39 to i1
  br i1 %40, label %87, label %.preheader.7

.preheader.7:                                     ; preds = %38, %.preheader.6
  %41 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 112), align 16, !tbaa !11
  %42 = icmp eq ptr %41, %0
  br i1 %42, label %43, label %.preheader.8

43:                                               ; preds = %.preheader.7
  %44 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 120), align 8, !tbaa !14, !range !9, !noundef !10
  %45 = trunc nuw i8 %44 to i1
  br i1 %45, label %87, label %.preheader.8

.preheader.8:                                     ; preds = %43, %.preheader.7
  %46 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 128), align 16, !tbaa !11
  %47 = icmp eq ptr %46, %0
  br i1 %47, label %48, label %.preheader.9

48:                                               ; preds = %.preheader.8
  %49 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 136), align 8, !tbaa !14, !range !9, !noundef !10
  %50 = trunc nuw i8 %49 to i1
  br i1 %50, label %87, label %.preheader.9

.preheader.9:                                     ; preds = %48, %.preheader.8
  %51 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 144), align 16, !tbaa !11
  %52 = icmp eq ptr %51, %0
  br i1 %52, label %53, label %.preheader.10

53:                                               ; preds = %.preheader.9
  %54 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 152), align 8, !tbaa !14, !range !9, !noundef !10
  %55 = trunc nuw i8 %54 to i1
  br i1 %55, label %87, label %.preheader.10

.preheader.10:                                    ; preds = %53, %.preheader.9
  %56 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 160), align 16, !tbaa !11
  %57 = icmp eq ptr %56, %0
  br i1 %57, label %58, label %.preheader.11

58:                                               ; preds = %.preheader.10
  %59 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 168), align 8, !tbaa !14, !range !9, !noundef !10
  %60 = trunc nuw i8 %59 to i1
  br i1 %60, label %87, label %.preheader.11

.preheader.11:                                    ; preds = %58, %.preheader.10
  %61 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 176), align 16, !tbaa !11
  %62 = icmp eq ptr %61, %0
  br i1 %62, label %63, label %.preheader.12

63:                                               ; preds = %.preheader.11
  %64 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 184), align 8, !tbaa !14, !range !9, !noundef !10
  %65 = trunc nuw i8 %64 to i1
  br i1 %65, label %87, label %.preheader.12

.preheader.12:                                    ; preds = %63, %.preheader.11
  %66 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 192), align 16, !tbaa !11
  %67 = icmp eq ptr %66, %0
  br i1 %67, label %68, label %.preheader.13

68:                                               ; preds = %.preheader.12
  %69 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 200), align 8, !tbaa !14, !range !9, !noundef !10
  %70 = trunc nuw i8 %69 to i1
  br i1 %70, label %87, label %.preheader.13

.preheader.13:                                    ; preds = %68, %.preheader.12
  %71 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 208), align 16, !tbaa !11
  %72 = icmp eq ptr %71, %0
  br i1 %72, label %73, label %.preheader.14

73:                                               ; preds = %.preheader.13
  %74 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 216), align 8, !tbaa !14, !range !9, !noundef !10
  %75 = trunc nuw i8 %74 to i1
  br i1 %75, label %87, label %.preheader.14

.preheader.14:                                    ; preds = %73, %.preheader.13
  %76 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 224), align 16, !tbaa !11
  %77 = icmp eq ptr %76, %0
  br i1 %77, label %78, label %.preheader.15

78:                                               ; preds = %.preheader.14
  %79 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 232), align 8, !tbaa !14, !range !9, !noundef !10
  %80 = trunc nuw i8 %79 to i1
  br i1 %80, label %87, label %.preheader.15

.preheader.15:                                    ; preds = %78, %.preheader.14
  %81 = load ptr, ptr getelementptr inbounds (i8, ptr @streams, i64 240), align 16, !tbaa !11
  %82 = icmp eq ptr %81, %0
  br i1 %82, label %83, label %86

83:                                               ; preds = %.preheader.15
  %84 = load i8, ptr getelementptr inbounds (i8, ptr @streams, i64 248), align 8, !tbaa !14, !range !9, !noundef !10
  %85 = trunc nuw i8 %84 to i1
  br i1 %85, label %87, label %86

86:                                               ; preds = %83, %.preheader.15
  br label %87

87:                                               ; preds = %8, %13, %18, %23, %28, %33, %38, %43, %48, %53, %58, %63, %68, %73, %78, %83, %86, %3, %1
  %.1 = phi i32 [ -1, %1 ], [ -4, %3 ], [ 0, %8 ], [ 0, %13 ], [ 0, %18 ], [ 0, %23 ], [ 0, %28 ], [ 0, %33 ], [ 0, %38 ], [ 0, %43 ], [ 0, %48 ], [ 0, %53 ], [ 0, %58 ], [ 0, %63 ], [ 0, %68 ], [ 0, %73 ], [ 0, %78 ], [ 0, %83 ], [ -1, %86 ]
  ret i32 %.1
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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" }

!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, !13, i64 0}
!12 = !{!"Stream", !13, i64 0, !6, i64 8}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!12, !6, i64 8}


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