; LLVM IR from FSmallenburg/EDMD :: Single (mdSingle)

; 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.sparticle = type { double, double, double, double, double, double, double, double, double, [24 x ptr], i8, double, double, double, i8, i32, i32, i32, i32, i32, i32, ptr, ptr, i8, double, ptr, ptr, ptr, ptr, i32, i8 }

@initialconfig = external dso_local global i32, align 4
@N = external dso_local global i32, align 4
@particles = external dso_local global ptr, align 8
@xsize = external dso_local global double, align 8
@ysize = external dso_local global double, align 8
@zsize = external dso_local global double, align 8
@.str.5 = external hidden unnamed_addr constant [10 x i8], align 1
@hx = external dso_local global double, align 8
@hy = external dso_local global double, align 8
@hz = external dso_local global double, align 8
@.str.6 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @init_genrand(i64 noundef) #0

; 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

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
define dso_local void @init() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  store i64 1, ptr %2, align 8, !tbaa !5
  %4 = load i64, ptr %2, align 8, !tbaa !5
  %5 = trunc i64 %4 to i32
  %6 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %5)
  %7 = load i64, ptr %2, align 8, !tbaa !5
  call void @init_genrand(i64 noundef %7)
  %8 = load i32, ptr @initialconfig, align 4, !tbaa !9
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %11

10:                                               ; preds = %0
  call void @loadparticles()
  br label %12

11:                                               ; preds = %0
  call void @fcc()
  br label %12

12:                                               ; preds = %11, %10
  call void @randommovement()
  %13 = load double, ptr @xsize, align 8, !tbaa !11
  %14 = fmul double 5.000000e-01, %13
  store double %14, ptr @hx, align 8, !tbaa !11
  %15 = load double, ptr @ysize, align 8, !tbaa !11
  %16 = fmul double 5.000000e-01, %15
  store double %16, ptr @hy, align 8, !tbaa !11
  %17 = load double, ptr @zsize, align 8, !tbaa !11
  %18 = fmul double 5.000000e-01, %17
  store double %18, ptr @hz, align 8, !tbaa !11
  call void @initevents()
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %55, %12
  %20 = load i32, ptr %1, align 4, !tbaa !9
  %21 = load i32, ptr @N, align 4, !tbaa !9
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %23, label %58

23:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %24 = load ptr, ptr @particles, align 8, !tbaa !13
  %25 = load i32, ptr %1, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds %struct.sparticle, ptr %24, i64 %26
  store ptr %27, ptr %3, align 8, !tbaa !13
  %28 = load ptr, ptr %3, align 8, !tbaa !13
  %29 = getelementptr inbounds %struct.sparticle, ptr %28, i32 0, i32 16
  store i32 0, ptr %29, align 8, !tbaa !15
  %30 = load ptr, ptr %3, align 8, !tbaa !13
  %31 = getelementptr inbounds %struct.sparticle, ptr %30, i32 0, i32 17
  store i32 0, ptr %31, align 4, !tbaa !17
  %32 = load ptr, ptr %3, align 8, !tbaa !13
  %33 = getelementptr inbounds %struct.sparticle, ptr %32, i32 0, i32 18
  store i32 0, ptr %33, align 8, !tbaa !18
  %34 = load ptr, ptr %3, align 8, !tbaa !13
  %35 = getelementptr inbounds %struct.sparticle, ptr %34, i32 0, i32 10
  store i8 0, ptr %35, align 8, !tbaa !19
  %36 = load ptr, ptr %3, align 8, !tbaa !13
  %37 = getelementptr inbounds %struct.sparticle, ptr %36, i32 0, i32 19
  store i32 0, ptr %37, align 4, !tbaa !20
  %38 = load ptr, ptr %3, align 8, !tbaa !13
  %39 = getelementptr inbounds %struct.sparticle, ptr %38, i32 0, i32 11
  store double 0.000000e+00, ptr %39, align 8, !tbaa !21
  %40 = load ptr, ptr %3, align 8, !tbaa !13
  %41 = getelementptr inbounds %struct.sparticle, ptr %40, i32 0, i32 0
  %42 = load double, ptr %41, align 8, !tbaa !22
  %43 = load ptr, ptr %3, align 8, !tbaa !13
  %44 = getelementptr inbounds %struct.sparticle, ptr %43, i32 0, i32 6
  store double %42, ptr %44, align 8, !tbaa !23
  %45 = load ptr, ptr %3, align 8, !tbaa !13
  %46 = getelementptr inbounds %struct.sparticle, ptr %45, i32 0, i32 1
  %47 = load double, ptr %46, align 8, !tbaa !24
  %48 = load ptr, ptr %3, align 8, !tbaa !13
  %49 = getelementptr inbounds %struct.sparticle, ptr %48, i32 0, i32 7
  store double %47, ptr %49, align 8, !tbaa !25
  %50 = load ptr, ptr %3, align 8, !tbaa !13
  %51 = getelementptr inbounds %struct.sparticle, ptr %50, i32 0, i32 2
  %52 = load double, ptr %51, align 8, !tbaa !26
  %53 = load ptr, ptr %3, align 8, !tbaa !13
  %54 = getelementptr inbounds %struct.sparticle, ptr %53, i32 0, i32 8
  store double %52, ptr %54, align 8, !tbaa !27
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %55

55:                                               ; preds = %23
  %56 = load i32, ptr %1, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %1, align 4, !tbaa !9
  br label %19, !llvm.loop !28

58:                                               ; preds = %19
  call void @initcelllist()
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %68, %58
  %60 = load i32, ptr %1, align 4, !tbaa !9
  %61 = load i32, ptr @N, align 4, !tbaa !9
  %62 = icmp slt i32 %60, %61
  br i1 %62, label %63, label %71

63:                                               ; preds = %59
  %64 = load ptr, ptr @particles, align 8, !tbaa !13
  %65 = load i32, ptr %1, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds %struct.sparticle, ptr %64, i64 %66
  call void @makeneighborlist(ptr noundef %67)
  br label %68

68:                                               ; preds = %63
  %69 = load i32, ptr %1, align 4, !tbaa !9
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %1, align 4, !tbaa !9
  br label %59, !llvm.loop !30

71:                                               ; preds = %59
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @makeneighborlist(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @fcc() #0

; Function Attrs: nounwind uwtable
declare dso_local void @loadparticles() #0

; Function Attrs: nounwind uwtable
declare dso_local void @randommovement() #0

; Function Attrs: nounwind uwtable
declare dso_local void @initcelllist() #0

; Function Attrs: nounwind uwtable
declare dso_local void @initevents() #0

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 = { "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 = !{!"long", !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 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!16, !10, i64 304}
!16 = !{!"sparticle", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !7, i64 72, !7, i64 264, !12, i64 272, !12, i64 280, !12, i64 288, !7, i64 296, !10, i64 300, !10, i64 304, !10, i64 308, !10, i64 312, !10, i64 316, !10, i64 320, !14, i64 328, !14, i64 336, !7, i64 344, !12, i64 352, !14, i64 360, !14, i64 368, !14, i64 376, !14, i64 384, !10, i64 392, !7, i64 396}
!17 = !{!16, !10, i64 308}
!18 = !{!16, !10, i64 312}
!19 = !{!16, !7, i64 264}
!20 = !{!16, !10, i64 316}
!21 = !{!16, !12, i64 272}
!22 = !{!16, !12, i64 0}
!23 = !{!16, !12, i64 48}
!24 = !{!16, !12, i64 8}
!25 = !{!16, !12, i64 56}
!26 = !{!16, !12, i64 16}
!27 = !{!16, !12, i64 64}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = distinct !{!30, !29}


; 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.sparticle = type { double, double, double, double, double, double, double, double, double, [24 x ptr], i8, double, double, double, i8, i32, i32, i32, i32, i32, i32, ptr, ptr, i8, double, ptr, ptr, ptr, ptr, i32, i8 }

@initialconfig = external dso_local local_unnamed_addr global i32, align 4
@N = external dso_local local_unnamed_addr global i32, align 4
@particles = external dso_local local_unnamed_addr global ptr, align 8
@xsize = external dso_local local_unnamed_addr global double, align 8
@ysize = external dso_local local_unnamed_addr global double, align 8
@zsize = external dso_local local_unnamed_addr global double, align 8
@.str.5 = external hidden unnamed_addr constant [10 x i8], align 1
@hx = external dso_local local_unnamed_addr global double, align 8
@hy = external dso_local local_unnamed_addr global double, align 8
@hz = external dso_local local_unnamed_addr global double, align 8
@.str.6 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @init_genrand(i64 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @init() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef 1)
  tail call void @init_genrand(i64 noundef 1)
  %2 = load i32, ptr @initialconfig, align 4, !tbaa !5
  %3 = icmp eq i32 %2, 0
  br i1 %3, label %4, label %5

4:                                                ; preds = %0
  tail call void @loadparticles()
  br label %6

5:                                                ; preds = %0
  tail call void @fcc()
  br label %6

6:                                                ; preds = %5, %4
  tail call void @randommovement()
  %7 = load double, ptr @xsize, align 8, !tbaa !9
  %8 = fmul double %7, 5.000000e-01
  store double %8, ptr @hx, align 8, !tbaa !9
  %9 = load double, ptr @ysize, align 8, !tbaa !9
  %10 = fmul double %9, 5.000000e-01
  store double %10, ptr @hy, align 8, !tbaa !9
  %11 = load double, ptr @zsize, align 8, !tbaa !9
  %12 = fmul double %11, 5.000000e-01
  store double %12, ptr @hz, align 8, !tbaa !9
  tail call void @initevents()
  %13 = load i32, ptr @N, align 4, !tbaa !5
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %6
  %15 = load ptr, ptr @particles, align 8, !tbaa !11
  br label %16

16:                                               ; preds = %.lr.ph, %16
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %16 ]
  %17 = getelementptr inbounds %struct.sparticle, ptr %15, i64 %indvars.iv
  %18 = getelementptr inbounds i8, ptr %17, i64 304
  %19 = getelementptr inbounds i8, ptr %17, i64 264
  store i8 0, ptr %19, align 8, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %17, i64 272
  store double 0.000000e+00, ptr %20, align 8, !tbaa !15
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %18, i8 0, i64 16, i1 false)
  %21 = getelementptr inbounds i8, ptr %17, i64 48
  %22 = load <2 x double>, ptr %17, align 8, !tbaa !9
  store <2 x double> %22, ptr %21, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %17, i64 16
  %24 = load double, ptr %23, align 8, !tbaa !16
  %25 = getelementptr inbounds i8, ptr %17, i64 64
  store double %24, ptr %25, align 8, !tbaa !17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr @N, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = icmp slt i64 %indvars.iv.next, %27
  br i1 %28, label %16, label %._crit_edge, !llvm.loop !18

._crit_edge:                                      ; preds = %16, %6
  tail call void @initcelllist()
  %29 = load i32, ptr @N, align 4, !tbaa !5
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %.lr.ph22, label %._crit_edge23

.lr.ph22:                                         ; preds = %._crit_edge, %.lr.ph22
  %indvars.iv25 = phi i64 [ %indvars.iv.next26, %.lr.ph22 ], [ 0, %._crit_edge ]
  %31 = load ptr, ptr @particles, align 8, !tbaa !11
  %32 = getelementptr inbounds %struct.sparticle, ptr %31, i64 %indvars.iv25
  tail call void @makeneighborlist(ptr noundef %32)
  %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 1
  %33 = load i32, ptr @N, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = icmp slt i64 %indvars.iv.next26, %34
  br i1 %35, label %.lr.ph22, label %._crit_edge23, !llvm.loop !20

._crit_edge23:                                    ; preds = %.lr.ph22, %._crit_edge
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @makeneighborlist(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @fcc() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @loadparticles() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @randommovement() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @initcelllist() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @initevents() local_unnamed_addr #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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 = { nofree 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !7, i64 264}
!14 = !{!"sparticle", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !7, i64 72, !7, i64 264, !10, i64 272, !10, i64 280, !10, i64 288, !7, i64 296, !6, i64 300, !6, i64 304, !6, i64 308, !6, i64 312, !6, i64 316, !6, i64 320, !12, i64 328, !12, i64 336, !7, i64 344, !10, i64 352, !12, i64 360, !12, i64 368, !12, i64 376, !12, i64 384, !6, i64 392, !7, i64 396}
!15 = !{!14, !10, i64 272}
!16 = !{!14, !10, i64 16}
!17 = !{!14, !10, i64 64}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


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