; LLVM IR from sbischoff-ai/simple-molecular-dynamics :: SimpleMolecularDynamics/SimpleMolecularDynamics/MDSim.ll (ZN5MDSim12updateGraphsEv)

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

%class.MDSim = type <{ ptr, i8, [7 x i8], ptr, ptr, ptr, ptr, double, double, double, double, double, double, double, double, ptr, %class.vec, %class.vec, %class.mat, i32, i32, i32, i32, i8, [7 x i8] }>
%class.vec = type <{ ptr, i32, [4 x i8] }>
%class.mat = type { ptr, i32, i32 }
%struct.graphData_t = type { double, double, ptr }

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5MDSim12updateGraphsEv(ptr noundef nonnull align 8 dereferenceable(185) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 1
  %5 = load i8, ptr %4, align 8, !tbaa !9, !range !16, !noundef !17
  %6 = trunc i8 %5 to i1
  br i1 %6, label %7, label %8

7:                                                ; preds = %1
  br label %64

8:                                                ; preds = %1
  %9 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #2
  %10 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 4
  %11 = load ptr, ptr %10, align 8, !tbaa !18
  %12 = getelementptr inbounds %struct.graphData_t, ptr %11, i32 0, i32 2
  store ptr %9, ptr %12, align 8, !tbaa !19
  %13 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 4
  store ptr %9, ptr %13, align 8, !tbaa !18
  %14 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 12
  %15 = load double, ptr %14, align 8, !tbaa !21
  %16 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 4
  %17 = load ptr, ptr %16, align 8, !tbaa !18
  %18 = getelementptr inbounds %struct.graphData_t, ptr %17, i32 0, i32 1
  store double %15, ptr %18, align 8, !tbaa !22
  %19 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 3
  %20 = load ptr, ptr %19, align 8, !tbaa !23
  %21 = getelementptr inbounds %struct.graphData_t, ptr %20, i32 0, i32 1
  %22 = load double, ptr %21, align 8, !tbaa !22
  %23 = fcmp ogt double %15, %22
  br i1 %23, label %24, label %32

24:                                               ; preds = %8
  %25 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %27 = getelementptr inbounds %struct.graphData_t, ptr %26, i32 0, i32 1
  %28 = load double, ptr %27, align 8, !tbaa !22
  %29 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 3
  %30 = load ptr, ptr %29, align 8, !tbaa !23
  %31 = getelementptr inbounds %struct.graphData_t, ptr %30, i32 0, i32 1
  store double %28, ptr %31, align 8, !tbaa !22
  br label %32

32:                                               ; preds = %24, %8
  %33 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 11
  %34 = load double, ptr %33, align 8, !tbaa !24
  %35 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 4
  %36 = load ptr, ptr %35, align 8, !tbaa !18
  %37 = getelementptr inbounds %struct.graphData_t, ptr %36, i32 0, i32 0
  store double %34, ptr %37, align 8, !tbaa !25
  %38 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !23
  %40 = getelementptr inbounds %struct.graphData_t, ptr %39, i32 0, i32 0
  %41 = load double, ptr %40, align 8, !tbaa !25
  %42 = fcmp ogt double %34, %41
  br i1 %42, label %43, label %51

43:                                               ; preds = %32
  %44 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 4
  %45 = load ptr, ptr %44, align 8, !tbaa !18
  %46 = getelementptr inbounds %struct.graphData_t, ptr %45, i32 0, i32 0
  %47 = load double, ptr %46, align 8, !tbaa !25
  %48 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 3
  %49 = load ptr, ptr %48, align 8, !tbaa !23
  %50 = getelementptr inbounds %struct.graphData_t, ptr %49, i32 0, i32 0
  store double %47, ptr %50, align 8, !tbaa !25
  br label %51

51:                                               ; preds = %43, %32
  %52 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 4
  %53 = load ptr, ptr %52, align 8, !tbaa !18
  %54 = getelementptr inbounds %struct.graphData_t, ptr %53, i32 0, i32 2
  store ptr null, ptr %54, align 8, !tbaa !19
  %55 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 12
  %56 = load double, ptr %55, align 8, !tbaa !21
  %57 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 13
  %58 = load double, ptr %57, align 8, !tbaa !26
  %59 = fcmp olt double %56, %58
  br i1 %59, label %60, label %64

60:                                               ; preds = %51
  %61 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 12
  %62 = load double, ptr %61, align 8, !tbaa !21
  %63 = getelementptr inbounds %class.MDSim, ptr %3, i32 0, i32 13
  store double %62, ptr %63, align 8, !tbaa !26
  br label %64

64:                                               ; preds = %60, %51, %7
  ret void
}

attributes #0 = { nobuiltin 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 #1 = { mustprogress 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 = { builtin 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"_ZTS5MDSim", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !6, i64 112, !13, i64 120, !13, i64 136, !15, i64 152, !14, i64 168, !14, i64 172, !14, i64 176, !14, i64 180, !11, i64 184}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"_ZTS3vec", !6, i64 0, !14, i64 8}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTS3mat", !6, i64 0, !14, i64 8, !14, i64 12}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!10, !6, i64 24}
!19 = !{!20, !6, i64 16}
!20 = !{!"_ZTS11graphData_t", !12, i64 0, !12, i64 8, !6, i64 16}
!21 = !{!10, !12, i64 88}
!22 = !{!20, !12, i64 8}
!23 = !{!10, !6, i64 16}
!24 = !{!10, !12, i64 80}
!25 = !{!20, !12, i64 0}
!26 = !{!10, !12, i64 96}


; 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5MDSim12updateGraphsEv(ptr nocapture noundef nonnull align 8 dereferenceable(185) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i8, ptr %2, align 8, !tbaa !5, !range !15, !noundef !16
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %31, label %5

5:                                                ; preds = %1
  %6 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #2
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !17
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr %6, ptr %9, align 8, !tbaa !18
  store ptr %6, ptr %7, align 8, !tbaa !17
  %10 = getelementptr inbounds i8, ptr %0, i64 88
  %11 = load double, ptr %10, align 8, !tbaa !20
  %12 = getelementptr inbounds i8, ptr %6, i64 8
  store double %11, ptr %12, align 8, !tbaa !21
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !22
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load double, ptr %15, align 8, !tbaa !21
  %17 = fcmp ogt double %11, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %5
  store double %11, ptr %15, align 8, !tbaa !21
  br label %19

19:                                               ; preds = %18, %5
  %20 = getelementptr inbounds i8, ptr %0, i64 80
  %21 = load double, ptr %20, align 8, !tbaa !23
  store double %21, ptr %6, align 8, !tbaa !24
  %22 = load double, ptr %14, align 8, !tbaa !24
  %23 = fcmp ogt double %21, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %19
  store double %21, ptr %14, align 8, !tbaa !24
  br label %25

25:                                               ; preds = %24, %19
  %26 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr null, ptr %26, align 8, !tbaa !18
  %27 = getelementptr inbounds i8, ptr %0, i64 96
  %28 = load double, ptr %27, align 8, !tbaa !25
  %29 = fcmp olt double %11, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %25
  store double %11, ptr %27, align 8, !tbaa !25
  br label %31

31:                                               ; preds = %1, %30, %25
  ret void
}

attributes #0 = { nobuiltin 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 #1 = { mustprogress 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 = { builtin 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, !10, i64 8}
!6 = !{!"_ZTS5MDSim", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !7, i64 112, !12, i64 120, !12, i64 136, !14, i64 152, !13, i64 168, !13, i64 172, !13, i64 176, !13, i64 180, !10, i64 184}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"_ZTS3vec", !7, i64 0, !13, i64 8}
!13 = !{!"int", !8, i64 0}
!14 = !{!"_ZTS3mat", !7, i64 0, !13, i64 8, !13, i64 12}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!6, !7, i64 24}
!18 = !{!19, !7, i64 16}
!19 = !{!"_ZTS11graphData_t", !11, i64 0, !11, i64 8, !7, i64 16}
!20 = !{!6, !11, i64 88}
!21 = !{!19, !11, i64 8}
!22 = !{!6, !7, i64 16}
!23 = !{!6, !11, i64 80}
!24 = !{!19, !11, i64 0}
!25 = !{!6, !11, i64 96}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass