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

; 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.anon = type { [1024 x ptr], %struct.quantum_cache_t, i64, i64, i8, i32, ptr }
%struct.quantum_cache_t = type { i32, ptr, ptr, i64, %struct.quantum_protection_t }
%struct.quantum_protection_t = type { ptr, i64, float, i8 }
%struct.ComplexFloat = type { float, float }
%struct.cache_entry = type { ptr, i64, i64, i8, i8, i64, %struct.quantum_protection_t, ptr }

@cache_state = external hidden global %struct.anon, align 8

; 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

; 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) #3

declare i32 @geometric_execute_hardware(ptr noundef, ptr noundef, ptr noundef, i64 noundef) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @qg_cache_optimize() #5 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %struct.ComplexFloat, align 4
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = load i8, ptr getelementptr inbounds (%struct.anon, ptr @cache_state, i32 0, i32 4), align 8, !tbaa !5, !range !16, !noundef !17
  %15 = trunc i8 %14 to i1
  br i1 %15, label %17, label %16

16:                                               ; preds = %0
  store i32 -3, ptr %1, align 4
  br label %153

17:                                               ; preds = %0
  %18 = load i8, ptr getelementptr inbounds (%struct.quantum_protection_t, ptr getelementptr inbounds (%struct.quantum_cache_t, ptr getelementptr inbounds (%struct.anon, ptr @cache_state, i32 0, i32 1), i32 0, i32 4), i32 0, i32 3), align 4, !tbaa !18, !range !16, !noundef !17
  %19 = trunc i8 %18 to i1
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  store i32 0, ptr %1, align 4
  br label %153

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  store i64 0, ptr %2, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  store i64 0, ptr %3, align 8, !tbaa !19
  br label %22

22:                                               ; preds = %40, %21
  %23 = load i64, ptr %3, align 8, !tbaa !19
  %24 = icmp ult i64 %23, 1024
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %43

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  %27 = load i64, ptr %3, align 8, !tbaa !19
  %28 = getelementptr inbounds [1024 x ptr], ptr @cache_state, i64 0, i64 %27
  %29 = load ptr, ptr %28, align 8, !tbaa !20
  store ptr %29, ptr %4, align 8, !tbaa !20
  br label %30

30:                                               ; preds = %33, %26
  %31 = load ptr, ptr %4, align 8, !tbaa !20
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %39

33:                                               ; preds = %30
  %34 = load i64, ptr %2, align 8, !tbaa !19
  %35 = add i64 %34, 1
  store i64 %35, ptr %2, align 8, !tbaa !19
  %36 = load ptr, ptr %4, align 8, !tbaa !20
  %37 = getelementptr inbounds %struct.cache_entry, ptr %36, i32 0, i32 7
  %38 = load ptr, ptr %37, align 8, !tbaa !21
  store ptr %38, ptr %4, align 8, !tbaa !20
  br label %30, !llvm.loop !23

39:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  br label %40

40:                                               ; preds = %39
  %41 = load i64, ptr %3, align 8, !tbaa !19
  %42 = add i64 %41, 1
  store i64 %42, ptr %3, align 8, !tbaa !19
  br label %22, !llvm.loop !25

43:                                               ; preds = %25
  %44 = load i64, ptr %2, align 8, !tbaa !19
  %45 = icmp eq i64 %44, 0
  br i1 %45, label %46, label %47

46:                                               ; preds = %43
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %152

47:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %48 = load i64, ptr %2, align 8, !tbaa !19
  %49 = mul i64 8, %48
  %50 = call noalias ptr @malloc(i64 noundef %49) #8
  store ptr %50, ptr %6, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %51 = load i64, ptr %2, align 8, !tbaa !19
  %52 = mul i64 8, %51
  %53 = call noalias ptr @malloc(i64 noundef %52) #8
  store ptr %53, ptr %7, align 8, !tbaa !20
  %54 = load ptr, ptr %6, align 8, !tbaa !20
  %55 = icmp ne ptr %54, null
  br i1 %55, label %56, label %59

56:                                               ; preds = %47
  %57 = load ptr, ptr %7, align 8, !tbaa !20
  %58 = icmp ne ptr %57, null
  br i1 %58, label %62, label %59

59:                                               ; preds = %56, %47
  %60 = load ptr, ptr %6, align 8, !tbaa !20
  call void @free(ptr noundef %60) #7
  %61 = load ptr, ptr %7, align 8, !tbaa !20
  call void @free(ptr noundef %61) #7
  store i32 -5, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %151

62:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  store i64 0, ptr %8, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store i64 0, ptr %9, align 8, !tbaa !19
  br label %63

63:                                               ; preds = %92, %62
  %64 = load i64, ptr %9, align 8, !tbaa !19
  %65 = icmp ult i64 %64, 1024
  br i1 %65, label %67, label %66

66:                                               ; preds = %63
  store i32 7, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %95

67:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %68 = load i64, ptr %9, align 8, !tbaa !19
  %69 = getelementptr inbounds [1024 x ptr], ptr @cache_state, i64 0, i64 %68
  %70 = load ptr, ptr %69, align 8, !tbaa !20
  store ptr %70, ptr %10, align 8, !tbaa !20
  br label %71

71:                                               ; preds = %74, %67
  %72 = load ptr, ptr %10, align 8, !tbaa !20
  %73 = icmp ne ptr %72, null
  br i1 %73, label %74, label %91

74:                                               ; preds = %71
  %75 = load ptr, ptr %6, align 8, !tbaa !20
  %76 = load i64, ptr %8, align 8, !tbaa !19
  %77 = getelementptr inbounds %struct.ComplexFloat, ptr %75, i64 %76
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %78 = load ptr, ptr %10, align 8, !tbaa !20
  %79 = getelementptr inbounds %struct.cache_entry, ptr %78, i32 0, i32 5
  %80 = load i64, ptr %79, align 8, !tbaa !26
  %81 = uitofp i64 %80 to float
  %82 = load i64, ptr %2, align 8, !tbaa !19
  %83 = uitofp i64 %82 to float
  %84 = fdiv float %81, %83
  %85 = call <2 x float> @complex_float_create(float noundef %84, float noundef 0.000000e+00)
  store <2 x float> %85, ptr %11, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %77, ptr align 4 %11, i64 8, i1 false), !tbaa.struct !27
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  %86 = load i64, ptr %8, align 8, !tbaa !19
  %87 = add i64 %86, 1
  store i64 %87, ptr %8, align 8, !tbaa !19
  %88 = load ptr, ptr %10, align 8, !tbaa !20
  %89 = getelementptr inbounds %struct.cache_entry, ptr %88, i32 0, i32 7
  %90 = load ptr, ptr %89, align 8, !tbaa !21
  store ptr %90, ptr %10, align 8, !tbaa !20
  br label %71, !llvm.loop !29

91:                                               ; preds = %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %92

92:                                               ; preds = %91
  %93 = load i64, ptr %9, align 8, !tbaa !19
  %94 = add i64 %93, 1
  store i64 %94, ptr %9, align 8, !tbaa !19
  br label %63, !llvm.loop !30

95:                                               ; preds = %66
  %96 = load i32, ptr getelementptr inbounds (%struct.anon, ptr @cache_state, i32 0, i32 5), align 4, !tbaa !31
  switch i32 %96, label %108 [
    i32 0, label %97
    i32 1, label %97
    i32 2, label %97
    i32 3, label %97
    i32 4, label %97
  ]

97:                                               ; preds = %95, %95, %95, %95, %95
  %98 = load ptr, ptr getelementptr inbounds (%struct.anon, ptr @cache_state, i32 0, i32 6), align 8, !tbaa !32
  %99 = load ptr, ptr %6, align 8, !tbaa !20
  %100 = load ptr, ptr %7, align 8, !tbaa !20
  %101 = load i64, ptr %2, align 8, !tbaa !19
  %102 = call i32 @geometric_execute_hardware(ptr noundef %98, ptr noundef %99, ptr noundef %100, i64 noundef %101)
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %104, label %107

104:                                              ; preds = %97
  %105 = load ptr, ptr %6, align 8, !tbaa !20
  call void @free(ptr noundef %105) #7
  %106 = load ptr, ptr %7, align 8, !tbaa !20
  call void @free(ptr noundef %106) #7
  store i32 -2, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %150

107:                                              ; preds = %97
  br label %111

108:                                              ; preds = %95
  %109 = load ptr, ptr %6, align 8, !tbaa !20
  call void @free(ptr noundef %109) #7
  %110 = load ptr, ptr %7, align 8, !tbaa !20
  call void @free(ptr noundef %110) #7
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %150

111:                                              ; preds = %107
  store i64 0, ptr %8, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  store i64 0, ptr %12, align 8, !tbaa !19
  br label %112

112:                                              ; preds = %144, %111
  %113 = load i64, ptr %12, align 8, !tbaa !19
  %114 = icmp ult i64 %113, 1024
  br i1 %114, label %116, label %115

115:                                              ; preds = %112
  store i32 13, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %147

116:                                              ; preds = %112
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %117 = load i64, ptr %12, align 8, !tbaa !19
  %118 = getelementptr inbounds [1024 x ptr], ptr @cache_state, i64 0, i64 %117
  %119 = load ptr, ptr %118, align 8, !tbaa !20
  store ptr %119, ptr %13, align 8, !tbaa !20
  br label %120

120:                                              ; preds = %137, %116
  %121 = load ptr, ptr %13, align 8, !tbaa !20
  %122 = icmp ne ptr %121, null
  br i1 %122, label %123, label %143

123:                                              ; preds = %120
  %124 = load i8, ptr getelementptr inbounds (%struct.quantum_protection_t, ptr getelementptr inbounds (%struct.quantum_cache_t, ptr getelementptr inbounds (%struct.anon, ptr @cache_state, i32 0, i32 1), i32 0, i32 4), i32 0, i32 3), align 4, !tbaa !18, !range !16, !noundef !17
  %125 = trunc i8 %124 to i1
  br i1 %125, label %126, label %137

126:                                              ; preds = %123
  %127 = load ptr, ptr %7, align 8, !tbaa !20
  %128 = load i64, ptr %8, align 8, !tbaa !19
  %129 = getelementptr inbounds %struct.ComplexFloat, ptr %127, i64 %128
  %130 = load <2 x float>, ptr %129, align 4
  %131 = call float @complex_float_abs(<2 x float> %130)
  %132 = load float, ptr getelementptr inbounds (%struct.quantum_protection_t, ptr getelementptr inbounds (%struct.quantum_cache_t, ptr getelementptr inbounds (%struct.anon, ptr @cache_state, i32 0, i32 1), i32 0, i32 4), i32 0, i32 2), align 8, !tbaa !33
  %133 = fmul float %131, %132
  %134 = load ptr, ptr %13, align 8, !tbaa !20
  %135 = getelementptr inbounds %struct.cache_entry, ptr %134, i32 0, i32 6
  %136 = getelementptr inbounds %struct.quantum_protection_t, ptr %135, i32 0, i32 2
  store float %133, ptr %136, align 8, !tbaa !34
  br label %137

137:                                              ; preds = %126, %123
  %138 = load i64, ptr %8, align 8, !tbaa !19
  %139 = add i64 %138, 1
  store i64 %139, ptr %8, align 8, !tbaa !19
  %140 = load ptr, ptr %13, align 8, !tbaa !20
  %141 = getelementptr inbounds %struct.cache_entry, ptr %140, i32 0, i32 7
  %142 = load ptr, ptr %141, align 8, !tbaa !21
  store ptr %142, ptr %13, align 8, !tbaa !20
  br label %120, !llvm.loop !35

143:                                              ; preds = %120
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %144

144:                                              ; preds = %143
  %145 = load i64, ptr %12, align 8, !tbaa !19
  %146 = add i64 %145, 1
  store i64 %146, ptr %12, align 8, !tbaa !19
  br label %112, !llvm.loop !36

147:                                              ; preds = %115
  %148 = load ptr, ptr %6, align 8, !tbaa !20
  call void @free(ptr noundef %148) #7
  %149 = load ptr, ptr %7, align 8, !tbaa !20
  call void @free(ptr noundef %149) #7
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %150

150:                                              ; preds = %147, %108, %104
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %151

151:                                              ; preds = %150, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %152

152:                                              ; preds = %151, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  br label %153

153:                                              ; preds = %152, %20, %16
  %154 = load i32, ptr %1, align 4
  ret i32 %154
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @complex_float_create(float noundef, float noundef) #6

; Function Attrs: inlinehint nounwind uwtable
declare hidden float @complex_float_abs(<2 x float>) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { inlinehint nounwind uwtable "min-legal-vector-width"="64" "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 #7 = { nounwind }
attributes #8 = { 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, !15, i64 8264}
!6 = !{!"", !7, i64 0, !9, i64 8192, !12, i64 8248, !12, i64 8256, !15, i64 8264, !10, i64 8268, !11, i64 8272}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"", !10, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !13, i64 32}
!10 = !{!"int", !7, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"", !11, i64 0, !12, i64 8, !14, i64 16, !15, i64 20}
!14 = !{!"float", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!6, !15, i64 8244}
!19 = !{!12, !12, i64 0}
!20 = !{!11, !11, i64 0}
!21 = !{!22, !11, i64 64}
!22 = !{!"cache_entry", !11, i64 0, !12, i64 8, !12, i64 16, !15, i64 24, !15, i64 25, !12, i64 32, !13, i64 40, !11, i64 64}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = !{!22, !12, i64 32}
!27 = !{i64 0, i64 4, !28, i64 4, i64 4, !28}
!28 = !{!14, !14, i64 0}
!29 = distinct !{!29, !24}
!30 = distinct !{!30, !24}
!31 = !{!6, !10, i64 8268}
!32 = !{!6, !11, i64 8272}
!33 = !{!6, !14, i64 8240}
!34 = !{!22, !14, i64 56}
!35 = distinct !{!35, !24}
!36 = distinct !{!36, !24}


; 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.anon = type { [1024 x ptr], %struct.quantum_cache_t, i64, i64, i8, i32, ptr }
%struct.quantum_cache_t = type { i32, ptr, ptr, i64, %struct.quantum_protection_t }
%struct.quantum_protection_t = type { ptr, i64, float, i8 }
%struct.ComplexFloat = type { float, float }

@cache_state = external hidden local_unnamed_addr global %struct.anon, align 8

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

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

declare i32 @geometric_execute_hardware(ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @qg_cache_optimize() local_unnamed_addr #3 {
  %1 = load i8, ptr getelementptr inbounds (i8, ptr @cache_state, i64 8264), align 8, !tbaa !5, !range !16, !noundef !17
  %2 = trunc nuw i8 %1 to i1
  br i1 %2, label %3, label %58

3:                                                ; preds = %0
  %4 = load i8, ptr getelementptr inbounds (i8, ptr @cache_state, i64 8244), align 4, !tbaa !18, !range !16, !noundef !17
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %.preheader60, label %58

6:                                                ; preds = %._crit_edge.1
  %7 = icmp eq i64 %.151.lcssa.1, 0
  br i1 %7, label %58, label %16

.preheader60:                                     ; preds = %3, %._crit_edge.1
  %.05066 = phi i64 [ %.151.lcssa.1, %._crit_edge.1 ], [ 0, %3 ]
  %.05265 = phi i64 [ %15, %._crit_edge.1 ], [ 0, %3 ]
  %8 = getelementptr inbounds [1024 x ptr], ptr @cache_state, i64 0, i64 %.05265
  %.05361 = load ptr, ptr %8, align 8, !tbaa !19
  %.not5862 = icmp eq ptr %.05361, null
  br i1 %.not5862, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader60, %.lr.ph
  %.05364 = phi ptr [ %.053, %.lr.ph ], [ %.05361, %.preheader60 ]
  %.15163 = phi i64 [ %9, %.lr.ph ], [ %.05066, %.preheader60 ]
  %9 = add i64 %.15163, 1
  %10 = getelementptr inbounds i8, ptr %.05364, i64 64
  %.053 = load ptr, ptr %10, align 8, !tbaa !19
  %.not58 = icmp eq ptr %.053, null
  br i1 %.not58, label %._crit_edge, label %.lr.ph, !llvm.loop !20

._crit_edge:                                      ; preds = %.lr.ph, %.preheader60
  %.151.lcssa = phi i64 [ %.05066, %.preheader60 ], [ %9, %.lr.ph ]
  %11 = or disjoint i64 %.05265, 1
  %12 = getelementptr inbounds [1024 x ptr], ptr @cache_state, i64 0, i64 %11
  %.05361.1 = load ptr, ptr %12, align 8, !tbaa !19
  %.not5862.1 = icmp eq ptr %.05361.1, null
  br i1 %.not5862.1, label %._crit_edge.1, label %.lr.ph.1

.lr.ph.1:                                         ; preds = %._crit_edge, %.lr.ph.1
  %.05364.1 = phi ptr [ %.053.1, %.lr.ph.1 ], [ %.05361.1, %._crit_edge ]
  %.15163.1 = phi i64 [ %13, %.lr.ph.1 ], [ %.151.lcssa, %._crit_edge ]
  %13 = add i64 %.15163.1, 1
  %14 = getelementptr inbounds i8, ptr %.05364.1, i64 64
  %.053.1 = load ptr, ptr %14, align 8, !tbaa !19
  %.not58.1 = icmp eq ptr %.053.1, null
  br i1 %.not58.1, label %._crit_edge.1, label %.lr.ph.1, !llvm.loop !20

._crit_edge.1:                                    ; preds = %.lr.ph.1, %._crit_edge
  %.151.lcssa.1 = phi i64 [ %.151.lcssa, %._crit_edge ], [ %13, %.lr.ph.1 ]
  %15 = add nuw nsw i64 %.05265, 2
  %exitcond.not.1 = icmp eq i64 %15, 1024
  br i1 %exitcond.not.1, label %6, label %.preheader60, !llvm.loop !22

16:                                               ; preds = %6
  %17 = shl i64 %.151.lcssa.1, 3
  %18 = tail call noalias ptr @malloc(i64 noundef %17) #5
  %19 = tail call noalias ptr @malloc(i64 noundef %17) #5
  %20 = icmp ne ptr %18, null
  %21 = icmp ne ptr %19, null
  %or.cond = and i1 %20, %21
  br i1 %or.cond, label %.preheader59, label %.sink.split

.preheader59:                                     ; preds = %16
  %22 = uitofp i64 %.151.lcssa.1 to float
  br label %25

23:                                               ; preds = %._crit_edge73
  %24 = load i32, ptr getelementptr inbounds (i8, ptr @cache_state, i64 8268), align 4, !tbaa !23
  %switch = icmp ult i32 %24, 5
  br i1 %switch, label %36, label %.sink.split

25:                                               ; preds = %.preheader59, %._crit_edge73
  %.04576 = phi i64 [ 0, %.preheader59 ], [ %35, %._crit_edge73 ]
  %.04675 = phi i64 [ 0, %.preheader59 ], [ %.147.lcssa, %._crit_edge73 ]
  %26 = getelementptr inbounds [1024 x ptr], ptr @cache_state, i64 0, i64 %.04576
  %.04467 = load ptr, ptr %26, align 8, !tbaa !19
  %.not5768 = icmp eq ptr %.04467, null
  br i1 %.not5768, label %._crit_edge73, label %.lr.ph72

.lr.ph72:                                         ; preds = %25, %.lr.ph72
  %.04470 = phi ptr [ %.044, %.lr.ph72 ], [ %.04467, %25 ]
  %.14769 = phi i64 [ %33, %.lr.ph72 ], [ %.04675, %25 ]
  %27 = getelementptr inbounds %struct.ComplexFloat, ptr %18, i64 %.14769
  %28 = getelementptr inbounds i8, ptr %.04470, i64 32
  %29 = load i64, ptr %28, align 8, !tbaa !24
  %30 = uitofp i64 %29 to float
  %31 = fdiv float %30, %22
  %32 = tail call <2 x float> @complex_float_create(float noundef %31, float noundef 0.000000e+00)
  store <2 x float> %32, ptr %27, align 4
  %33 = add i64 %.14769, 1
  %34 = getelementptr inbounds i8, ptr %.04470, i64 64
  %.044 = load ptr, ptr %34, align 8, !tbaa !19
  %.not57 = icmp eq ptr %.044, null
  br i1 %.not57, label %._crit_edge73, label %.lr.ph72, !llvm.loop !26

._crit_edge73:                                    ; preds = %.lr.ph72, %25
  %.147.lcssa = phi i64 [ %.04675, %25 ], [ %33, %.lr.ph72 ]
  %35 = add nuw nsw i64 %.04576, 1
  %exitcond91.not = icmp eq i64 %35, 1024
  br i1 %exitcond91.not, label %23, label %25, !llvm.loop !27

36:                                               ; preds = %23
  %37 = load ptr, ptr getelementptr inbounds (i8, ptr @cache_state, i64 8272), align 8, !tbaa !28
  %38 = tail call i32 @geometric_execute_hardware(ptr noundef %37, ptr noundef nonnull %18, ptr noundef nonnull %19, i64 noundef %.151.lcssa.1) #6
  %.not = icmp eq i32 %38, 0
  br i1 %.not, label %.preheader, label %.sink.split

.preheader:                                       ; preds = %36, %._crit_edge83
  %.04286 = phi i64 [ %57, %._crit_edge83 ], [ 0, %36 ]
  %.24885 = phi i64 [ %.349.lcssa, %._crit_edge83 ], [ 0, %36 ]
  %39 = getelementptr inbounds [1024 x ptr], ptr @cache_state, i64 0, i64 %.04286
  %.077 = load ptr, ptr %39, align 8, !tbaa !19
  %.not5678 = icmp eq ptr %.077, null
  br i1 %.not5678, label %._crit_edge83, label %.lr.ph82

.lr.ph82:                                         ; preds = %.preheader
  %40 = load i8, ptr getelementptr inbounds (i8, ptr @cache_state, i64 8244), align 4, !tbaa !18, !range !16, !noundef !17
  %41 = trunc nuw i8 %40 to i1
  br i1 %41, label %.lr.ph82.split, label %.lr.ph82.split.us

.lr.ph82.split.us:                                ; preds = %.lr.ph82, %.lr.ph82.split.us
  %.080.us = phi ptr [ %.0.us, %.lr.ph82.split.us ], [ %.077, %.lr.ph82 ]
  %.34979.us = phi i64 [ %42, %.lr.ph82.split.us ], [ %.24885, %.lr.ph82 ]
  %42 = add i64 %.34979.us, 1
  %43 = getelementptr inbounds i8, ptr %.080.us, i64 64
  %.0.us = load ptr, ptr %43, align 8, !tbaa !19
  %.not56.us = icmp eq ptr %.0.us, null
  br i1 %.not56.us, label %._crit_edge83, label %.lr.ph82.split.us, !llvm.loop !29

.lr.ph82.split:                                   ; preds = %.lr.ph82, %53
  %44 = phi i8 [ %54, %53 ], [ %40, %.lr.ph82 ]
  %.080 = phi ptr [ %.0, %53 ], [ %.077, %.lr.ph82 ]
  %.34979 = phi i64 [ %55, %53 ], [ %.24885, %.lr.ph82 ]
  %45 = trunc nuw i8 %44 to i1
  br i1 %45, label %46, label %53

46:                                               ; preds = %.lr.ph82.split
  %47 = getelementptr inbounds %struct.ComplexFloat, ptr %19, i64 %.34979
  %48 = load <2 x float>, ptr %47, align 4
  %49 = tail call float @complex_float_abs(<2 x float> %48)
  %50 = load float, ptr getelementptr inbounds (i8, ptr @cache_state, i64 8240), align 8, !tbaa !30
  %51 = fmul float %49, %50
  %52 = getelementptr inbounds i8, ptr %.080, i64 56
  store float %51, ptr %52, align 8, !tbaa !31
  %.pre = load i8, ptr getelementptr inbounds (i8, ptr @cache_state, i64 8244), align 4, !tbaa !18, !range !16
  br label %53

53:                                               ; preds = %46, %.lr.ph82.split
  %54 = phi i8 [ %.pre, %46 ], [ %44, %.lr.ph82.split ]
  %55 = add i64 %.34979, 1
  %56 = getelementptr inbounds i8, ptr %.080, i64 64
  %.0 = load ptr, ptr %56, align 8, !tbaa !19
  %.not56 = icmp eq ptr %.0, null
  br i1 %.not56, label %._crit_edge83, label %.lr.ph82.split, !llvm.loop !32

._crit_edge83:                                    ; preds = %.lr.ph82.split.us, %53, %.preheader
  %.349.lcssa = phi i64 [ %.24885, %.preheader ], [ %55, %53 ], [ %42, %.lr.ph82.split.us ]
  %57 = add nuw nsw i64 %.04286, 1
  %exitcond92.not = icmp eq i64 %57, 1024
  br i1 %exitcond92.not, label %.sink.split, label %.preheader, !llvm.loop !34

.sink.split:                                      ; preds = %._crit_edge83, %23, %36, %16
  %.3.ph = phi i32 [ -5, %16 ], [ -2, %36 ], [ -1, %23 ], [ 0, %._crit_edge83 ]
  tail call void @free(ptr noundef %18) #6
  tail call void @free(ptr noundef %19) #6
  br label %58

58:                                               ; preds = %.sink.split, %6, %3, %0
  %.3 = phi i32 [ -3, %0 ], [ 0, %3 ], [ 0, %6 ], [ %.3.ph, %.sink.split ]
  ret i32 %.3
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @complex_float_create(float noundef, float noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden float @complex_float_abs(<2 x float>) local_unnamed_addr #4

attributes #0 = { 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 #1 = { 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 #2 = { "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 uwtable "min-legal-vector-width"="64" "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 = { inlinehint nounwind uwtable "min-legal-vector-width"="64" "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 = { nounwind allocsize(0) }
attributes #6 = { 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, !15, i64 8264}
!6 = !{!"", !7, i64 0, !9, i64 8192, !12, i64 8248, !12, i64 8256, !15, i64 8264, !10, i64 8268, !11, i64 8272}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"", !10, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !13, i64 32}
!10 = !{!"int", !7, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"", !11, i64 0, !12, i64 8, !14, i64 16, !15, i64 20}
!14 = !{!"float", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!6, !15, i64 8244}
!19 = !{!11, !11, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = !{!6, !10, i64 8268}
!24 = !{!25, !12, i64 32}
!25 = !{!"cache_entry", !11, i64 0, !12, i64 8, !12, i64 16, !15, i64 24, !15, i64 25, !12, i64 32, !13, i64 40, !11, i64 64}
!26 = distinct !{!26, !21}
!27 = distinct !{!27, !21}
!28 = !{!6, !11, i64 8272}
!29 = distinct !{!29, !21}
!30 = !{!6, !14, i64 8240}
!31 = !{!25, !14, i64 56}
!32 = distinct !{!32, !21, !33}
!33 = !{!"llvm.loop.unswitch.partial.disable"}
!34 = distinct !{!34, !21}


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