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

@events = external hidden global [32 x %struct.Event], 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

declare void @geometric_free(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @geometric_core_destroy_event(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %10

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

10:                                               ; preds = %7, %1
  br label %47

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !13
  br label %12

12:                                               ; preds = %43, %11
  %13 = load i32, ptr %3, align 4, !tbaa !13
  %14 = icmp slt i32 %13, 32
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  store i32 2, ptr %4, align 4
  br label %46

16:                                               ; preds = %12
  %17 = load i32, ptr %3, align 4, !tbaa !13
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [32 x %struct.Event], ptr @events, i64 0, i64 %18
  %20 = getelementptr inbounds %struct.Event, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = icmp eq ptr %21, %22
  br i1 %23, label %24, label %42

24:                                               ; preds = %16
  %25 = load i32, ptr %3, align 4, !tbaa !13
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [32 x %struct.Event], ptr @events, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.Event, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  call void @geometric_free(ptr noundef %29)
  %30 = load i32, ptr %3, align 4, !tbaa !13
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [32 x %struct.Event], ptr @events, i64 0, i64 %31
  %33 = getelementptr inbounds %struct.Event, ptr %32, i32 0, i32 0
  store ptr null, ptr %33, align 8, !tbaa !15
  %34 = load i32, ptr %3, align 4, !tbaa !13
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [32 x %struct.Event], ptr @events, i64 0, i64 %35
  %37 = getelementptr inbounds %struct.Event, ptr %36, i32 0, i32 1
  store i8 0, ptr %37, align 8, !tbaa !17
  %38 = load i32, ptr %3, align 4, !tbaa !13
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [32 x %struct.Event], ptr @events, i64 0, i64 %39
  %41 = getelementptr inbounds %struct.Event, ptr %40, i32 0, i32 2
  store ptr null, ptr %41, align 8, !tbaa !18
  store i32 2, ptr %4, align 4
  br label %46

42:                                               ; preds = %16
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %3, align 4, !tbaa !13
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %3, align 4, !tbaa !13
  br label %12, !llvm.loop !19

46:                                               ; preds = %24, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %47

47:                                               ; preds = %46, %10
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 = !{!"Event", !6, i64 0, !10, i64 8, !6, i64 16}
!17 = !{!16, !10, i64 8}
!18 = !{!16, !6, i64 16}
!19 = distinct !{!19, !20}
!20 = !{!"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.Event = type { ptr, i8, ptr }

@events = external hidden local_unnamed_addr global [32 x %struct.Event], align 16
@is_initialized = external hidden local_unnamed_addr global i8, align 1

declare void @geometric_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @geometric_core_destroy_event(ptr noundef readnone %0) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.loopexit, label %2

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

.preheader.preheader:                             ; preds = %2
  %5 = load ptr, ptr @events, align 16, !tbaa !11
  %6 = icmp eq ptr %5, %0
  br i1 %6, label %69, label %.preheader.1

.preheader.1:                                     ; preds = %.preheader.preheader
  %7 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 24), align 8, !tbaa !11
  %8 = icmp eq ptr %7, %0
  br i1 %8, label %69, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %9 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 48), align 16, !tbaa !11
  %10 = icmp eq ptr %9, %0
  br i1 %10, label %69, label %.preheader.3

.preheader.3:                                     ; preds = %.preheader.2
  %11 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 72), align 8, !tbaa !11
  %12 = icmp eq ptr %11, %0
  br i1 %12, label %69, label %.preheader.4

.preheader.4:                                     ; preds = %.preheader.3
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 96), align 16, !tbaa !11
  %14 = icmp eq ptr %13, %0
  br i1 %14, label %69, label %.preheader.5

.preheader.5:                                     ; preds = %.preheader.4
  %15 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 120), align 8, !tbaa !11
  %16 = icmp eq ptr %15, %0
  br i1 %16, label %69, label %.preheader.6

.preheader.6:                                     ; preds = %.preheader.5
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 144), align 16, !tbaa !11
  %18 = icmp eq ptr %17, %0
  br i1 %18, label %69, label %.preheader.7

.preheader.7:                                     ; preds = %.preheader.6
  %19 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 168), align 8, !tbaa !11
  %20 = icmp eq ptr %19, %0
  br i1 %20, label %69, label %.preheader.8

.preheader.8:                                     ; preds = %.preheader.7
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 192), align 16, !tbaa !11
  %22 = icmp eq ptr %21, %0
  br i1 %22, label %69, label %.preheader.9

.preheader.9:                                     ; preds = %.preheader.8
  %23 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 216), align 8, !tbaa !11
  %24 = icmp eq ptr %23, %0
  br i1 %24, label %69, label %.preheader.10

.preheader.10:                                    ; preds = %.preheader.9
  %25 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 240), align 16, !tbaa !11
  %26 = icmp eq ptr %25, %0
  br i1 %26, label %69, label %.preheader.11

.preheader.11:                                    ; preds = %.preheader.10
  %27 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 264), align 8, !tbaa !11
  %28 = icmp eq ptr %27, %0
  br i1 %28, label %69, label %.preheader.12

.preheader.12:                                    ; preds = %.preheader.11
  %29 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 288), align 16, !tbaa !11
  %30 = icmp eq ptr %29, %0
  br i1 %30, label %69, label %.preheader.13

.preheader.13:                                    ; preds = %.preheader.12
  %31 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 312), align 8, !tbaa !11
  %32 = icmp eq ptr %31, %0
  br i1 %32, label %69, label %.preheader.14

.preheader.14:                                    ; preds = %.preheader.13
  %33 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 336), align 16, !tbaa !11
  %34 = icmp eq ptr %33, %0
  br i1 %34, label %69, label %.preheader.15

.preheader.15:                                    ; preds = %.preheader.14
  %35 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 360), align 8, !tbaa !11
  %36 = icmp eq ptr %35, %0
  br i1 %36, label %69, label %.preheader.16

.preheader.16:                                    ; preds = %.preheader.15
  %37 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 384), align 16, !tbaa !11
  %38 = icmp eq ptr %37, %0
  br i1 %38, label %69, label %.preheader.17

.preheader.17:                                    ; preds = %.preheader.16
  %39 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 408), align 8, !tbaa !11
  %40 = icmp eq ptr %39, %0
  br i1 %40, label %69, label %.preheader.18

.preheader.18:                                    ; preds = %.preheader.17
  %41 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 432), align 16, !tbaa !11
  %42 = icmp eq ptr %41, %0
  br i1 %42, label %69, label %.preheader.19

.preheader.19:                                    ; preds = %.preheader.18
  %43 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 456), align 8, !tbaa !11
  %44 = icmp eq ptr %43, %0
  br i1 %44, label %69, label %.preheader.20

.preheader.20:                                    ; preds = %.preheader.19
  %45 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 480), align 16, !tbaa !11
  %46 = icmp eq ptr %45, %0
  br i1 %46, label %69, label %.preheader.21

.preheader.21:                                    ; preds = %.preheader.20
  %47 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 504), align 8, !tbaa !11
  %48 = icmp eq ptr %47, %0
  br i1 %48, label %69, label %.preheader.22

.preheader.22:                                    ; preds = %.preheader.21
  %49 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 528), align 16, !tbaa !11
  %50 = icmp eq ptr %49, %0
  br i1 %50, label %69, label %.preheader.23

.preheader.23:                                    ; preds = %.preheader.22
  %51 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 552), align 8, !tbaa !11
  %52 = icmp eq ptr %51, %0
  br i1 %52, label %69, label %.preheader.24

.preheader.24:                                    ; preds = %.preheader.23
  %53 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 576), align 16, !tbaa !11
  %54 = icmp eq ptr %53, %0
  br i1 %54, label %69, label %.preheader.25

.preheader.25:                                    ; preds = %.preheader.24
  %55 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 600), align 8, !tbaa !11
  %56 = icmp eq ptr %55, %0
  br i1 %56, label %69, label %.preheader.26

.preheader.26:                                    ; preds = %.preheader.25
  %57 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 624), align 16, !tbaa !11
  %58 = icmp eq ptr %57, %0
  br i1 %58, label %69, label %.preheader.27

.preheader.27:                                    ; preds = %.preheader.26
  %59 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 648), align 8, !tbaa !11
  %60 = icmp eq ptr %59, %0
  br i1 %60, label %69, label %.preheader.28

.preheader.28:                                    ; preds = %.preheader.27
  %61 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 672), align 16, !tbaa !11
  %62 = icmp eq ptr %61, %0
  br i1 %62, label %69, label %.preheader.29

.preheader.29:                                    ; preds = %.preheader.28
  %63 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 696), align 8, !tbaa !11
  %64 = icmp eq ptr %63, %0
  br i1 %64, label %69, label %.preheader.30

.preheader.30:                                    ; preds = %.preheader.29
  %65 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 720), align 16, !tbaa !11
  %66 = icmp eq ptr %65, %0
  br i1 %66, label %69, label %.preheader.31

.preheader.31:                                    ; preds = %.preheader.30
  %67 = load ptr, ptr getelementptr inbounds (i8, ptr @events, i64 744), align 8, !tbaa !11
  %68 = icmp eq ptr %67, %0
  br i1 %68, label %69, label %.loopexit

69:                                               ; preds = %.preheader.31, %.preheader.30, %.preheader.29, %.preheader.28, %.preheader.27, %.preheader.26, %.preheader.25, %.preheader.24, %.preheader.23, %.preheader.22, %.preheader.21, %.preheader.20, %.preheader.19, %.preheader.18, %.preheader.17, %.preheader.16, %.preheader.15, %.preheader.14, %.preheader.13, %.preheader.12, %.preheader.11, %.preheader.10, %.preheader.9, %.preheader.8, %.preheader.7, %.preheader.6, %.preheader.5, %.preheader.4, %.preheader.3, %.preheader.2, %.preheader.1, %.preheader.preheader
  %.lcssa13 = phi ptr [ @events, %.preheader.preheader ], [ getelementptr inbounds (i8, ptr @events, i64 24), %.preheader.1 ], [ getelementptr inbounds (i8, ptr @events, i64 48), %.preheader.2 ], [ getelementptr inbounds (i8, ptr @events, i64 72), %.preheader.3 ], [ getelementptr inbounds (i8, ptr @events, i64 96), %.preheader.4 ], [ getelementptr inbounds (i8, ptr @events, i64 120), %.preheader.5 ], [ getelementptr inbounds (i8, ptr @events, i64 144), %.preheader.6 ], [ getelementptr inbounds (i8, ptr @events, i64 168), %.preheader.7 ], [ getelementptr inbounds (i8, ptr @events, i64 192), %.preheader.8 ], [ getelementptr inbounds (i8, ptr @events, i64 216), %.preheader.9 ], [ getelementptr inbounds (i8, ptr @events, i64 240), %.preheader.10 ], [ getelementptr inbounds (i8, ptr @events, i64 264), %.preheader.11 ], [ getelementptr inbounds (i8, ptr @events, i64 288), %.preheader.12 ], [ getelementptr inbounds (i8, ptr @events, i64 312), %.preheader.13 ], [ getelementptr inbounds (i8, ptr @events, i64 336), %.preheader.14 ], [ getelementptr inbounds (i8, ptr @events, i64 360), %.preheader.15 ], [ getelementptr inbounds (i8, ptr @events, i64 384), %.preheader.16 ], [ getelementptr inbounds (i8, ptr @events, i64 408), %.preheader.17 ], [ getelementptr inbounds (i8, ptr @events, i64 432), %.preheader.18 ], [ getelementptr inbounds (i8, ptr @events, i64 456), %.preheader.19 ], [ getelementptr inbounds (i8, ptr @events, i64 480), %.preheader.20 ], [ getelementptr inbounds (i8, ptr @events, i64 504), %.preheader.21 ], [ getelementptr inbounds (i8, ptr @events, i64 528), %.preheader.22 ], [ getelementptr inbounds (i8, ptr @events, i64 552), %.preheader.23 ], [ getelementptr inbounds (i8, ptr @events, i64 576), %.preheader.24 ], [ getelementptr inbounds (i8, ptr @events, i64 600), %.preheader.25 ], [ getelementptr inbounds (i8, ptr @events, i64 624), %.preheader.26 ], [ getelementptr inbounds (i8, ptr @events, i64 648), %.preheader.27 ], [ getelementptr inbounds (i8, ptr @events, i64 672), %.preheader.28 ], [ getelementptr inbounds (i8, ptr @events, i64 696), %.preheader.29 ], [ getelementptr inbounds (i8, ptr @events, i64 720), %.preheader.30 ], [ getelementptr inbounds (i8, ptr @events, i64 744), %.preheader.31 ]
  %.lcssa = phi ptr [ %5, %.preheader.preheader ], [ %7, %.preheader.1 ], [ %9, %.preheader.2 ], [ %11, %.preheader.3 ], [ %13, %.preheader.4 ], [ %15, %.preheader.5 ], [ %17, %.preheader.6 ], [ %19, %.preheader.7 ], [ %21, %.preheader.8 ], [ %23, %.preheader.9 ], [ %25, %.preheader.10 ], [ %27, %.preheader.11 ], [ %29, %.preheader.12 ], [ %31, %.preheader.13 ], [ %33, %.preheader.14 ], [ %35, %.preheader.15 ], [ %37, %.preheader.16 ], [ %39, %.preheader.17 ], [ %41, %.preheader.18 ], [ %43, %.preheader.19 ], [ %45, %.preheader.20 ], [ %47, %.preheader.21 ], [ %49, %.preheader.22 ], [ %51, %.preheader.23 ], [ %53, %.preheader.24 ], [ %55, %.preheader.25 ], [ %57, %.preheader.26 ], [ %59, %.preheader.27 ], [ %61, %.preheader.28 ], [ %63, %.preheader.29 ], [ %65, %.preheader.30 ], [ %67, %.preheader.31 ]
  tail call void @geometric_free(ptr noundef %.lcssa) #2
  store ptr null, ptr %.lcssa13, align 8, !tbaa !11
  %70 = getelementptr inbounds i8, ptr %.lcssa13, i64 8
  store i8 0, ptr %70, align 8, !tbaa !14
  %71 = getelementptr inbounds i8, ptr %.lcssa13, i64 16
  store ptr null, ptr %71, align 8, !tbaa !15
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.31, %69, %1, %2
  ret void
}

attributes #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 = { 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, !13, i64 0}
!12 = !{!"Event", !13, i64 0, !6, i64 8, !13, i64 16}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !13, i64 16}


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