; LLVM IR from alexzheng42/sDMD :: analysis (Tools)

; 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.AtomStr = type { ptr, ptr }
%struct.DynamicStr = type { [4 x i32], [4 x double], [4 x double], %struct.HBStr, %struct.HBNeighborStr, %struct.InteractionEventStr }
%struct.HBStr = type { i32, i32, i8, i32 }
%struct.HBNeighborStr = type { [5 x i32], i32, i32 }
%struct.InteractionEventStr = type { i32, i64, i64, double, double, i32, i32 }

@boxOrigDim = external global [4 x double], align 16
@cellNum = external global [4 x double], align 16
@atomnum = external global i32, align 4
@cellSize = external global [4 x double], align 16
@celllist = external global ptr, align 8
@atom = external global ptr, 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind uwtable
define dso_local void @LinkList() #2 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store ptr @boxOrigDim, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %19, %0
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = sitofp i32 %9 to double
  %11 = load double, ptr @cellNum, align 16, !tbaa !11
  %12 = fcmp olt double %10, %11
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %8
  %15 = load ptr, ptr @celllist, align 8, !tbaa !5
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds i32, ptr %15, i64 %17
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %14
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %4, align 4, !tbaa !9
  br label %8, !llvm.loop !13

22:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %155, %22
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = load i32, ptr @atomnum, align 4, !tbaa !9
  %26 = icmp sle i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %158

28:                                               ; preds = %23
  %29 = load ptr, ptr @atom, align 8, !tbaa !5
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %struct.AtomStr, ptr %29, i64 %31
  %33 = getelementptr inbounds %struct.AtomStr, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = getelementptr inbounds %struct.DynamicStr, ptr %34, i32 0, i32 1
  %36 = getelementptr inbounds [4 x double], ptr %35, i64 0, i64 0
  store ptr %36, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %94, %28
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = icmp sle i32 %38, 3
  br i1 %39, label %41, label %40

40:                                               ; preds = %37
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %97

41:                                               ; preds = %37
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds double, ptr %42, i64 %44
  %46 = load double, ptr %45, align 8, !tbaa !11
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [4 x double], ptr @cellSize, i64 0, i64 %48
  %50 = load double, ptr %49, align 8, !tbaa !11
  %51 = fdiv double %46, %50
  %52 = fptosi double %51 to i32
  %53 = load ptr, ptr @atom, align 8, !tbaa !5
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds %struct.AtomStr, ptr %53, i64 %55
  %57 = getelementptr inbounds %struct.AtomStr, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !15
  %59 = getelementptr inbounds %struct.DynamicStr, ptr %58, i32 0, i32 0
  %60 = load i32, ptr %7, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [4 x i32], ptr %59, i64 0, i64 %61
  store i32 %52, ptr %62, align 4, !tbaa !9
  %63 = load ptr, ptr @atom, align 8, !tbaa !5
  %64 = load i32, ptr %5, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds %struct.AtomStr, ptr %63, i64 %65
  %67 = getelementptr inbounds %struct.AtomStr, ptr %66, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !15
  %69 = getelementptr inbounds %struct.DynamicStr, ptr %68, i32 0, i32 0
  %70 = load i32, ptr %7, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [4 x i32], ptr %69, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !9
  %74 = sitofp i32 %73 to double
  %75 = load i32, ptr %7, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [4 x double], ptr @cellNum, i64 0, i64 %76
  %78 = load double, ptr %77, align 8, !tbaa !11
  %79 = fcmp oeq double %74, %78
  br i1 %79, label %80, label %93

80:                                               ; preds = %41
  %81 = load ptr, ptr @atom, align 8, !tbaa !5
  %82 = load i32, ptr %5, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds %struct.AtomStr, ptr %81, i64 %83
  %85 = getelementptr inbounds %struct.AtomStr, ptr %84, i32 0, i32 1
  %86 = load ptr, ptr %85, align 8, !tbaa !15
  %87 = getelementptr inbounds %struct.DynamicStr, ptr %86, i32 0, i32 0
  %88 = load i32, ptr %7, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [4 x i32], ptr %87, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !9
  %92 = add nsw i32 %91, -1
  store i32 %92, ptr %90, align 4, !tbaa !9
  br label %93

93:                                               ; preds = %80, %41
  br label %94

94:                                               ; preds = %93
  %95 = load i32, ptr %7, align 4, !tbaa !9
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %7, align 4, !tbaa !9
  br label %37, !llvm.loop !17

97:                                               ; preds = %40
  %98 = load ptr, ptr @atom, align 8, !tbaa !5
  %99 = load i32, ptr %5, align 4, !tbaa !9
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds %struct.AtomStr, ptr %98, i64 %100
  %102 = getelementptr inbounds %struct.AtomStr, ptr %101, i32 0, i32 1
  %103 = load ptr, ptr %102, align 8, !tbaa !15
  %104 = getelementptr inbounds %struct.DynamicStr, ptr %103, i32 0, i32 0
  %105 = getelementptr inbounds [4 x i32], ptr %104, i64 0, i64 3
  %106 = load i32, ptr %105, align 4, !tbaa !9
  %107 = sitofp i32 %106 to double
  %108 = load double, ptr getelementptr inbounds ([4 x double], ptr @cellNum, i64 0, i64 1), align 8, !tbaa !11
  %109 = fmul double %107, %108
  %110 = load double, ptr getelementptr inbounds ([4 x double], ptr @cellNum, i64 0, i64 2), align 16, !tbaa !11
  %111 = load ptr, ptr @atom, align 8, !tbaa !5
  %112 = load i32, ptr %5, align 4, !tbaa !9
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds %struct.AtomStr, ptr %111, i64 %113
  %115 = getelementptr inbounds %struct.AtomStr, ptr %114, i32 0, i32 1
  %116 = load ptr, ptr %115, align 8, !tbaa !15
  %117 = getelementptr inbounds %struct.DynamicStr, ptr %116, i32 0, i32 0
  %118 = getelementptr inbounds [4 x i32], ptr %117, i64 0, i64 2
  %119 = load i32, ptr %118, align 8, !tbaa !9
  %120 = sitofp i32 %119 to double
  %121 = load double, ptr getelementptr inbounds ([4 x double], ptr @cellNum, i64 0, i64 1), align 8, !tbaa !11
  %122 = fmul double %120, %121
  %123 = call double @llvm.fmuladd.f64(double %109, double %110, double %122)
  %124 = load ptr, ptr @atom, align 8, !tbaa !5
  %125 = load i32, ptr %5, align 4, !tbaa !9
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds %struct.AtomStr, ptr %124, i64 %126
  %128 = getelementptr inbounds %struct.AtomStr, ptr %127, i32 0, i32 1
  %129 = load ptr, ptr %128, align 8, !tbaa !15
  %130 = getelementptr inbounds %struct.DynamicStr, ptr %129, i32 0, i32 0
  %131 = getelementptr inbounds [4 x i32], ptr %130, i64 0, i64 1
  %132 = load i32, ptr %131, align 4, !tbaa !9
  %133 = sitofp i32 %132 to double
  %134 = fadd double %123, %133
  %135 = fadd double %134, 1.000000e+00
  %136 = fptosi double %135 to i32
  store i32 %136, ptr %1, align 4, !tbaa !9
  %137 = load ptr, ptr @celllist, align 8, !tbaa !5
  %138 = load i32, ptr @atomnum, align 4, !tbaa !9
  %139 = load i32, ptr %1, align 4, !tbaa !9
  %140 = add nsw i32 %138, %139
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds i32, ptr %137, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !9
  %144 = load ptr, ptr @celllist, align 8, !tbaa !5
  %145 = load i32, ptr %5, align 4, !tbaa !9
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds i32, ptr %144, i64 %146
  store i32 %143, ptr %147, align 4, !tbaa !9
  %148 = load i32, ptr %5, align 4, !tbaa !9
  %149 = load ptr, ptr @celllist, align 8, !tbaa !5
  %150 = load i32, ptr @atomnum, align 4, !tbaa !9
  %151 = load i32, ptr %1, align 4, !tbaa !9
  %152 = add nsw i32 %150, %151
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds i32, ptr %149, i64 %153
  store i32 %148, ptr %154, align 4, !tbaa !9
  br label %155

155:                                              ; preds = %97
  %156 = load i32, ptr %5, align 4, !tbaa !9
  %157 = add nsw i32 %156, 1
  store i32 %157, ptr %5, align 4, !tbaa !9
  br label %23, !llvm.loop !18

158:                                              ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !6, i64 8}
!16 = !{!"AtomStr", !6, i64 0, !6, i64 8}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !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"

%struct.AtomStr = type { ptr, ptr }

@cellNum = external local_unnamed_addr global [4 x double], align 16
@atomnum = external local_unnamed_addr global i32, align 4
@cellSize = external local_unnamed_addr global [4 x double], align 16
@celllist = external local_unnamed_addr global ptr, align 8
@atom = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @LinkList() local_unnamed_addr #1 {
  %1 = load double, ptr @cellNum, align 16, !tbaa !5
  %2 = fcmp ogt double %1, 0.000000e+00
  br i1 %2, label %.lr.ph, label %.preheader

.lr.ph:                                           ; preds = %0
  %3 = load ptr, ptr @celllist, align 8, !tbaa !9
  br label %13

.preheader:                                       ; preds = %13, %0
  %4 = load i32, ptr @atomnum, align 4, !tbaa !11
  %.not28 = icmp slt i32 %4, 1
  br i1 %.not28, label %._crit_edge, label %.lr.ph30

.lr.ph30:                                         ; preds = %.preheader
  %5 = load ptr, ptr @atom, align 8, !tbaa !9
  %6 = load ptr, ptr @celllist, align 8, !tbaa !9
  %7 = load <2 x double>, ptr getelementptr inbounds (i8, ptr @cellNum, i64 8), align 8, !tbaa !5
  %8 = load <2 x double>, ptr getelementptr inbounds (i8, ptr @cellSize, i64 8), align 8, !tbaa !5
  %9 = load double, ptr getelementptr inbounds (i8, ptr @cellSize, i64 24), align 8, !tbaa !5
  %10 = load double, ptr getelementptr inbounds (i8, ptr @cellNum, i64 24), align 8, !tbaa !5
  %11 = extractelement <2 x double> %7, i64 0
  %12 = extractelement <2 x double> %7, i64 1
  br label %18

13:                                               ; preds = %.lr.ph, %13
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %13 ]
  %14 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv
  store i32 0, ptr %14, align 4, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = trunc nuw nsw i64 %indvars.iv.next to i32
  %16 = uitofp nneg i32 %15 to double
  %17 = fcmp ogt double %1, %16
  br i1 %17, label %13, label %.preheader, !llvm.loop !13

._crit_edge:                                      ; preds = %40, %.preheader
  ret void

18:                                               ; preds = %.lr.ph30, %40
  %19 = phi i32 [ %4, %.lr.ph30 ], [ %61, %40 ]
  %indvars.iv35 = phi i64 [ 1, %.lr.ph30 ], [ %indvars.iv.next36, %40 ]
  %20 = getelementptr inbounds %struct.AtomStr, ptr %5, i64 %indvars.iv35, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = getelementptr inbounds i8, ptr %21, i64 24
  %23 = getelementptr inbounds i8, ptr %21, i64 4
  %24 = load <2 x double>, ptr %22, align 8, !tbaa !5
  %25 = fdiv <2 x double> %24, %8
  %26 = fptosi <2 x double> %25 to <2 x i32>
  %27 = sitofp <2 x i32> %26 to <2 x double>
  %28 = fcmp oeq <2 x double> %7, %27
  %29 = sext <2 x i1> %28 to <2 x i32>
  %30 = add nsw <2 x i32> %26, %29
  store <2 x i32> %30, ptr %23, align 4, !tbaa !11
  %31 = getelementptr inbounds i8, ptr %21, i64 40
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = fdiv double %32, %9
  %34 = fptosi double %33 to i32
  %35 = getelementptr inbounds i8, ptr %21, i64 12
  store i32 %34, ptr %35, align 4, !tbaa !11
  %36 = sitofp i32 %34 to double
  %37 = fcmp oeq double %10, %36
  br i1 %37, label %38, label %40

38:                                               ; preds = %18
  %39 = add nsw i32 %34, -1
  store i32 %39, ptr %35, align 4, !tbaa !11
  %.pre38 = sitofp i32 %39 to double
  br label %40

40:                                               ; preds = %38, %18
  %.pre-phi = phi double [ %.pre38, %38 ], [ %36, %18 ]
  %41 = fmul double %11, %.pre-phi
  %42 = extractelement <2 x i32> %30, i64 1
  %43 = sitofp i32 %42 to double
  %44 = fmul double %11, %43
  %45 = tail call double @llvm.fmuladd.f64(double %41, double %12, double %44)
  %46 = extractelement <2 x i32> %30, i64 0
  %47 = sitofp i32 %46 to double
  %48 = fadd double %45, %47
  %49 = fadd double %48, 1.000000e+00
  %50 = fptosi double %49 to i32
  %51 = add nsw i32 %19, %50
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i32, ptr %6, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !11
  %55 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv35
  store i32 %54, ptr %55, align 4, !tbaa !11
  %56 = load i32, ptr @atomnum, align 4, !tbaa !11
  %57 = add nsw i32 %56, %50
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i32, ptr %6, i64 %58
  %60 = trunc nuw nsw i64 %indvars.iv35 to i32
  store i32 %60, ptr %59, align 4, !tbaa !11
  %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, 1
  %61 = load i32, ptr @atomnum, align 4, !tbaa !11
  %62 = sext i32 %61 to i64
  %.not.not = icmp slt i64 %indvars.iv35, %62
  br i1 %.not.not, label %18, label %._crit_edge, !llvm.loop !17
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nofree norecurse nosync nounwind memory(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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !10, i64 8}
!16 = !{!"AtomStr", !10, i64 0, !10, i64 8}
!17 = distinct !{!17, !14}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass