; LLVM IR from alexzheng42/sDMD :: src (ToolFunctions)

; 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.AtomListStr = type { i32, [27 x i32], [27 x i32], [27 x i32], double, ptr, ptr, ptr }
%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 }

; 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 void @ResetTarget(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %42, %2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = load i32, ptr %6, align 4, !tbaa !9
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds i32, ptr %8, i64 %10
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %15, label %14

14:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %45

15:                                               ; preds = %7
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.AtomListStr, ptr %16, i32 0, i32 7
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i32, ptr %19, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds ptr, ptr %18, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  store ptr %26, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.AtomStr, ptr %27, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = getelementptr inbounds %struct.DynamicStr, ptr %29, i32 0, i32 5
  %31 = getelementptr inbounds %struct.InteractionEventStr, ptr %30, i32 0, i32 5
  store i32 15, ptr %31, align 8, !tbaa !16
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.AtomStr, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = getelementptr inbounds %struct.DynamicStr, ptr %34, i32 0, i32 5
  %36 = getelementptr inbounds %struct.InteractionEventStr, ptr %35, i32 0, i32 3
  store double 1.000000e+08, ptr %36, align 8, !tbaa !22
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.AtomStr, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !14
  %40 = getelementptr inbounds %struct.DynamicStr, ptr %39, i32 0, i32 5
  %41 = getelementptr inbounds %struct.InteractionEventStr, ptr %40, i32 0, i32 0
  store i32 -111, ptr %41, align 8, !tbaa !23
  br label %42

42:                                               ; preds = %15
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %6, align 4, !tbaa !9
  br label %7, !llvm.loop !24

45:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 352}
!12 = !{!"AtomListStr", !10, i64 0, !7, i64 4, !7, i64 112, !7, i64 220, !13, i64 328, !6, i64 336, !6, i64 344, !6, i64 352}
!13 = !{!"double", !7, i64 0}
!14 = !{!15, !6, i64 8}
!15 = !{!"AtomStr", !6, i64 0, !6, i64 8}
!16 = !{!17, !10, i64 168}
!17 = !{!"DynamicStr", !7, i64 0, !7, i64 16, !7, i64 48, !18, i64 80, !19, i64 96, !20, i64 128}
!18 = !{!"HBStr", !10, i64 0, !10, i64 4, !7, i64 8, !10, i64 12}
!19 = !{!"HBNeighborStr", !7, i64 0, !10, i64 20, !10, i64 24}
!20 = !{!"InteractionEventStr", !10, i64 0, !21, i64 8, !21, i64 16, !13, i64 24, !13, i64 32, !10, i64 40, !10, i64 44}
!21 = !{!"long", !7, i64 0}
!22 = !{!17, !13, i64 152}
!23 = !{!17, !10, i64 128}
!24 = distinct !{!24, !25}
!25 = !{!"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"

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @ResetTarget(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %.not9 = icmp eq i32 %4, 0
  br i1 %.not9, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %5 = getelementptr inbounds i8, ptr %1, i64 352
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  br label %7

._crit_edge:                                      ; preds = %7, %2
  ret void

7:                                                ; preds = %.lr.ph, %7
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %7 ]
  %8 = phi i32 [ %4, %.lr.ph ], [ %18, %7 ]
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds ptr, ptr %6, i64 %9
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %13, i64 168
  store i32 15, ptr %14, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %13, i64 152
  store double 1.000000e+08, ptr %15, align 8, !tbaa !22
  %16 = getelementptr inbounds i8, ptr %13, i64 128
  store i32 -111, ptr %16, align 8, !tbaa !23
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv.next
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %.not = icmp eq i32 %18, 0
  br i1 %.not, label %._crit_edge, label %7, !llvm.loop !24
}

attributes #0 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 352}
!10 = !{!"AtomListStr", !6, i64 0, !7, i64 4, !7, i64 112, !7, i64 220, !11, i64 328, !12, i64 336, !12, i64 344, !12, i64 352}
!11 = !{!"double", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!15, !12, i64 8}
!15 = !{!"AtomStr", !12, i64 0, !12, i64 8}
!16 = !{!17, !6, i64 168}
!17 = !{!"DynamicStr", !7, i64 0, !7, i64 16, !7, i64 48, !18, i64 80, !19, i64 96, !20, i64 128}
!18 = !{!"HBStr", !6, i64 0, !6, i64 4, !7, i64 8, !6, i64 12}
!19 = !{!"HBNeighborStr", !7, i64 0, !6, i64 20, !6, i64 24}
!20 = !{!"InteractionEventStr", !6, i64 0, !21, i64 8, !21, i64 16, !11, i64 24, !11, i64 32, !6, i64 40, !6, i64 44}
!21 = !{!"long", !7, i64 0}
!22 = !{!17, !11, i64 152}
!23 = !{!17, !6, i64 128}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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