; LLVM IR from microsoft/LightAIMD :: src (soad)

; 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"

@element_shell_count = external dso_local global [55 x i64], align 16
@element_ao_count = external dso_local global <{ [11 x i64], <{ i64, [10 x i64] }>, <{ i64, [10 x i64] }>, <{ i64, i64, [9 x i64] }>, <{ i64, i64, [9 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64] }>, align 16
@element_electron_distribution = external dso_local global <{ [11 x i64], <{ i64, [10 x i64] }>, <{ i64, [10 x i64] }>, <{ i64, i64, [9 x i64] }>, <{ i64, i64, [9 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64] }>, align 16

; Function Attrs: nounwind uwtable
define dso_local void @soad_initialize_density_matrix(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca double, align 8
  %19 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i64 %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %82, %4
  %21 = load i64, ptr %10, align 8, !tbaa !9
  %22 = load i64, ptr %8, align 8, !tbaa !9
  %23 = icmp ult i64 %21, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  br label %85

25:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load i64, ptr %10, align 8, !tbaa !9
  %28 = getelementptr inbounds i64, ptr %26, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !9
  store i64 %29, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %30 = load i64, ptr %12, align 8, !tbaa !9
  %31 = getelementptr inbounds [55 x i64], ptr @element_shell_count, i64 0, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !9
  store i64 %32, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  %33 = load i64, ptr %12, align 8, !tbaa !9
  %34 = getelementptr inbounds [55 x [11 x i64]], ptr @element_ao_count, i64 0, i64 %33
  %35 = getelementptr inbounds [11 x i64], ptr %34, i64 0, i64 0
  store ptr %35, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  %36 = load i64, ptr %12, align 8, !tbaa !9
  %37 = getelementptr inbounds [55 x [11 x i64]], ptr @element_electron_distribution, i64 0, i64 %36
  %38 = getelementptr inbounds [11 x i64], ptr %37, i64 0, i64 0
  store ptr %38, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  store i64 0, ptr %16, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %78, %25
  %40 = load i64, ptr %16, align 8, !tbaa !9
  %41 = load i64, ptr %13, align 8, !tbaa !9
  %42 = icmp ult i64 %40, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  br label %81

44:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #2
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = load i64, ptr %16, align 8, !tbaa !9
  %47 = getelementptr inbounds i64, ptr %45, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !9
  store i64 %48, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #2
  %49 = load ptr, ptr %15, align 8, !tbaa !5
  %50 = load i64, ptr %16, align 8, !tbaa !9
  %51 = getelementptr inbounds i64, ptr %49, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !9
  %53 = uitofp i64 %52 to double
  %54 = fmul double 5.000000e-01, %53
  %55 = load i64, ptr %17, align 8, !tbaa !9
  %56 = uitofp i64 %55 to double
  %57 = fdiv double %54, %56
  store double %57, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #2
  store i64 0, ptr %19, align 8, !tbaa !9
  br label %58

58:                                               ; preds = %74, %44
  %59 = load i64, ptr %19, align 8, !tbaa !9
  %60 = load i64, ptr %17, align 8, !tbaa !9
  %61 = icmp ult i64 %59, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %58
  store i32 8, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #2
  br label %77

63:                                               ; preds = %58
  %64 = load double, ptr %18, align 8, !tbaa !11
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load i64, ptr %9, align 8, !tbaa !9
  %67 = load i64, ptr %6, align 8, !tbaa !9
  %68 = mul i64 %66, %67
  %69 = load i64, ptr %9, align 8, !tbaa !9
  %70 = add i64 %68, %69
  %71 = getelementptr inbounds double, ptr %65, i64 %70
  store double %64, ptr %71, align 8, !tbaa !11
  %72 = load i64, ptr %9, align 8, !tbaa !9
  %73 = add i64 %72, 1
  store i64 %73, ptr %9, align 8, !tbaa !9
  br label %74

74:                                               ; preds = %63
  %75 = load i64, ptr %19, align 8, !tbaa !9
  %76 = add i64 %75, 1
  store i64 %76, ptr %19, align 8, !tbaa !9
  br label %58, !llvm.loop !13

77:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #2
  br label %78

78:                                               ; preds = %77
  %79 = load i64, ptr %16, align 8, !tbaa !9
  %80 = add i64 %79, 1
  store i64 %80, ptr %16, align 8, !tbaa !9
  br label %39, !llvm.loop !15

81:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  br label %82

82:                                               ; preds = %81
  %83 = load i64, ptr %10, align 8, !tbaa !9
  %84 = add i64 %83, 1
  store i64 %84, ptr %10, align 8, !tbaa !9
  br label %20, !llvm.loop !16

85:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  ret void
}

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

; 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 }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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"

@element_shell_count = external dso_local local_unnamed_addr global [55 x i64], align 16
@element_ao_count = external dso_local local_unnamed_addr global <{ [11 x i64], <{ i64, [10 x i64] }>, <{ i64, [10 x i64] }>, <{ i64, i64, [9 x i64] }>, <{ i64, i64, [9 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64] }>, align 16
@element_electron_distribution = external dso_local local_unnamed_addr global <{ [11 x i64], <{ i64, [10 x i64] }>, <{ i64, [10 x i64] }>, <{ i64, i64, [9 x i64] }>, <{ i64, i64, [9 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, <{ i64, i64, i64, [8 x i64] }>, [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64], [11 x i64] }>, align 16

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @soad_initialize_density_matrix(ptr nocapture noundef writeonly %0, i64 noundef %1, ptr nocapture noundef readonly %2, i64 noundef %3) local_unnamed_addr #0 {
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge40, label %.lr.ph39

.lr.ph39:                                         ; preds = %4
  %.227 = add i64 %1, 1
  br label %5

._crit_edge40:                                    ; preds = %._crit_edge34, %4
  ret void

5:                                                ; preds = %.lr.ph39, %._crit_edge34
  %.02437 = phi i64 [ 0, %.lr.ph39 ], [ %.1.lcssa, %._crit_edge34 ]
  %.02536 = phi i64 [ 0, %.lr.ph39 ], [ %12, %._crit_edge34 ]
  %6 = getelementptr inbounds i64, ptr %2, i64 %.02536
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds [55 x i64], ptr @element_shell_count, i64 0, i64 %7
  %9 = load i64, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds [55 x [11 x i64]], ptr @element_ao_count, i64 0, i64 %7
  %11 = getelementptr inbounds [55 x [11 x i64]], ptr @element_electron_distribution, i64 0, i64 %7
  %.not41 = icmp eq i64 %9, 0
  br i1 %.not41, label %._crit_edge34, label %.lr.ph33

._crit_edge34:                                    ; preds = %._crit_edge, %5
  %.1.lcssa = phi i64 [ %.02437, %5 ], [ %.2.lcssa, %._crit_edge ]
  %12 = add nuw i64 %.02536, 1
  %exitcond44.not = icmp eq i64 %12, %3
  br i1 %exitcond44.not, label %._crit_edge40, label %5, !llvm.loop !9

.lr.ph33:                                         ; preds = %5, %._crit_edge
  %.131 = phi i64 [ %.2.lcssa, %._crit_edge ], [ %.02437, %5 ]
  %.02630 = phi i64 [ %26, %._crit_edge ], [ 0, %5 ]
  %13 = getelementptr inbounds i64, ptr %10, i64 %.02630
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i64, ptr %11, i64 %.02630
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = uitofp i64 %16 to double
  %18 = fmul double %17, 5.000000e-01
  %19 = uitofp i64 %14 to double
  %20 = fdiv double %18, %19
  %.not42 = icmp eq i64 %14, 0
  br i1 %.not42, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph33
  %21 = add i64 %.131, %14
  %xtraiter = and i64 %14, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader, %.lr.ph.prol
  %.228.prol = phi i64 [ %24, %.lr.ph.prol ], [ %.131, %.lr.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader ]
  %22 = mul i64 %.228.prol, %.227
  %23 = getelementptr inbounds double, ptr %0, i64 %22
  store double %20, ptr %23, align 8, !tbaa !11
  %24 = add i64 %.228.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !13

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.228.unr = phi i64 [ %.131, %.lr.ph.preheader ], [ %24, %.lr.ph.prol ]
  %25 = icmp ult i64 %14, 4
  br i1 %25, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %.lr.ph33
  %.2.lcssa = phi i64 [ %.131, %.lr.ph33 ], [ %21, %.lr.ph ], [ %21, %.lr.ph.prol.loopexit ]
  %26 = add nuw i64 %.02630, 1
  %exitcond43.not = icmp eq i64 %26, %9
  br i1 %exitcond43.not, label %._crit_edge34, label %.lr.ph33, !llvm.loop !15

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.228 = phi i64 [ %38, %.lr.ph ], [ %.228.unr, %.lr.ph.prol.loopexit ]
  %27 = mul i64 %.228, %.227
  %28 = getelementptr inbounds double, ptr %0, i64 %27
  store double %20, ptr %28, align 8, !tbaa !11
  %29 = add i64 %.228, 1
  %30 = mul i64 %29, %.227
  %31 = getelementptr inbounds double, ptr %0, i64 %30
  store double %20, ptr %31, align 8, !tbaa !11
  %32 = add i64 %.228, 2
  %33 = mul i64 %32, %.227
  %34 = getelementptr inbounds double, ptr %0, i64 %33
  store double %20, ptr %34, align 8, !tbaa !11
  %35 = add i64 %.228, 3
  %36 = mul i64 %35, %.227
  %37 = getelementptr inbounds double, ptr %0, i64 %36
  store double %20, ptr %37, align 8, !tbaa !11
  %38 = add i64 %.228, 4
  %exitcond.not.3 = icmp eq i64 %38, %21
  br i1 %exitcond.not.3, label %._crit_edge, label %.lr.ph, !llvm.loop !16
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}


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