; LLVM IR from introlab/odas :: src/system (particle2particle)

; 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.particle2particle_obj = type { i32, float, [3 x float], [3 x float], [3 x float], [3 x float], [3 x float], float, float, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, double, ptr, ptr, ptr, float }
%struct.particles_obj = type { i32, ptr, ptr }
%struct.pots_obj = type { i32, ptr }

; 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 @particle2particle_init_pots(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.particle2particle_obj, ptr %10, i32 0, i32 12
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.particle2particle_obj, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !15
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.particle2particle_obj, ptr %16, i32 0, i32 11
  %18 = load ptr, ptr %17, align 8, !tbaa !16
  call void @random_generate(ptr noundef %12, i32 noundef %15, ptr noundef %18)
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.particles_obj, ptr %19, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.particle2particle_obj, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !15
  %25 = zext i32 %24 to i64
  %26 = mul i64 28, %25
  call void @llvm.memset.p0.i64(ptr align 4 %21, i8 0, i64 %26, i1 false)
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %112, %4
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.particle2particle_obj, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !15
  %32 = icmp ult i32 %28, %31
  br i1 %32, label %33, label %115

33:                                               ; preds = %27
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.pots_obj, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !19
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = mul i32 %37, 4
  %39 = add i32 %38, 0
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds float, ptr %36, i64 %40
  %42 = load float, ptr %41, align 4, !tbaa !21
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.particles_obj, ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = mul i32 %46, 7
  %48 = add i32 %47, 0
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds float, ptr %45, i64 %49
  store float %42, ptr %50, align 4, !tbaa !21
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.pots_obj, ptr %51, i32 0, i32 1
  %53 = load ptr, ptr %52, align 8, !tbaa !19
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = mul i32 %54, 4
  %56 = add i32 %55, 1
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds float, ptr %53, i64 %57
  %59 = load float, ptr %58, align 4, !tbaa !21
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.particles_obj, ptr %60, i32 0, i32 1
  %62 = load ptr, ptr %61, align 8, !tbaa !17
  %63 = load i32, ptr %9, align 4, !tbaa !9
  %64 = mul i32 %63, 7
  %65 = add i32 %64, 1
  %66 = zext i32 %65 to i64
  %67 = getelementptr inbounds float, ptr %62, i64 %66
  store float %59, ptr %67, align 4, !tbaa !21
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.pots_obj, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !19
  %71 = load i32, ptr %7, align 4, !tbaa !9
  %72 = mul i32 %71, 4
  %73 = add i32 %72, 2
  %74 = zext i32 %73 to i64
  %75 = getelementptr inbounds float, ptr %70, i64 %74
  %76 = load float, ptr %75, align 4, !tbaa !21
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.particles_obj, ptr %77, i32 0, i32 1
  %79 = load ptr, ptr %78, align 8, !tbaa !17
  %80 = load i32, ptr %9, align 4, !tbaa !9
  %81 = mul i32 %80, 7
  %82 = add i32 %81, 2
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds float, ptr %79, i64 %83
  store float %76, ptr %84, align 4, !tbaa !21
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.particle2particle_obj, ptr %85, i32 0, i32 0
  %87 = load i32, ptr %86, align 8, !tbaa !15
  %88 = uitofp i32 %87 to float
  %89 = fdiv float 1.000000e+00, %88
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.particles_obj, ptr %90, i32 0, i32 1
  %92 = load ptr, ptr %91, align 8, !tbaa !17
  %93 = load i32, ptr %9, align 4, !tbaa !9
  %94 = mul i32 %93, 7
  %95 = add i32 %94, 6
  %96 = zext i32 %95 to i64
  %97 = getelementptr inbounds float, ptr %92, i64 %96
  store float %89, ptr %97, align 4, !tbaa !21
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.particle2particle_obj, ptr %98, i32 0, i32 11
  %100 = load ptr, ptr %99, align 8, !tbaa !16
  %101 = load i32, ptr %9, align 4, !tbaa !9
  %102 = zext i32 %101 to i64
  %103 = getelementptr inbounds i32, ptr %100, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !9
  %105 = trunc i32 %104 to i8
  %106 = load ptr, ptr %8, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.particles_obj, ptr %106, i32 0, i32 2
  %108 = load ptr, ptr %107, align 8, !tbaa !22
  %109 = load i32, ptr %9, align 4, !tbaa !9
  %110 = zext i32 %109 to i64
  %111 = getelementptr inbounds i8, ptr %108, i64 %110
  store i8 %105, ptr %111, align 1, !tbaa !23
  br label %112

112:                                              ; preds = %33
  %113 = load i32, ptr %9, align 4, !tbaa !9
  %114 = add i32 %113, 1
  store i32 %114, ptr %9, align 4, !tbaa !9
  br label %27, !llvm.loop !24

115:                                              ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret void
}

declare void @random_generate(ptr noundef, i32 noundef, ptr noundef) #2

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

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 96}
!12 = !{!"particle2particle_obj", !10, i64 0, !13, i64 4, !7, i64 8, !7, i64 20, !7, i64 32, !7, i64 44, !7, i64 56, !13, i64 68, !13, i64 72, !13, i64 76, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !14, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !13, i64 168}
!13 = !{!"float", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!12, !10, i64 0}
!16 = !{!12, !6, i64 88}
!17 = !{!18, !6, i64 8}
!18 = !{!"particles_obj", !10, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!20, !6, i64 8}
!20 = !{!"pots_obj", !10, i64 0, !6, i64 8}
!21 = !{!13, !13, i64 0}
!22 = !{!18, !6, i64 16}
!23 = !{!7, !7, i64 0}
!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: nounwind uwtable
define dso_local void @particle2particle_init_pots(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i32 noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 96
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = load i32, ptr %0, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 88
  %9 = load ptr, ptr %8, align 8, !tbaa !14
  tail call void @random_generate(ptr noundef %6, i32 noundef %7, ptr noundef %9) #3
  %10 = getelementptr inbounds i8, ptr %3, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !15
  %12 = load i32, ptr %0, align 8, !tbaa !13
  %13 = zext i32 %12 to i64
  %14 = mul nuw nsw i64 %13, 28
  tail call void @llvm.memset.p0.i64(ptr align 4 %11, i8 0, i64 %14, i1 false)
  %15 = load i32, ptr %0, align 8, !tbaa !13
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = shl i32 %2, 2
  %18 = zext i32 %17 to i64
  %19 = or disjoint i32 %17, 1
  %20 = zext i32 %19 to i64
  %21 = or disjoint i32 %17, 2
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr %3, i64 16
  br label %24

24:                                               ; preds = %.lr.ph, %24
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %24 ]
  %25 = phi i32 [ %15, %.lr.ph ], [ %55, %24 ]
  %26 = load ptr, ptr %16, align 8, !tbaa !17
  %27 = getelementptr inbounds float, ptr %26, i64 %18
  %28 = load float, ptr %27, align 4, !tbaa !19
  %29 = load ptr, ptr %10, align 8, !tbaa !15
  %30 = trunc nuw i64 %indvars.iv to i32
  %31 = mul i32 %30, 7
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds float, ptr %29, i64 %32
  store float %28, ptr %33, align 4, !tbaa !19
  %34 = getelementptr inbounds float, ptr %26, i64 %20
  %35 = load float, ptr %34, align 4, !tbaa !19
  %36 = add i32 %31, 1
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds float, ptr %29, i64 %37
  store float %35, ptr %38, align 4, !tbaa !19
  %39 = getelementptr inbounds float, ptr %26, i64 %22
  %40 = load float, ptr %39, align 4, !tbaa !19
  %41 = add i32 %31, 2
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds float, ptr %29, i64 %42
  store float %40, ptr %43, align 4, !tbaa !19
  %44 = uitofp i32 %25 to float
  %45 = fdiv float 1.000000e+00, %44
  %46 = add i32 %31, 6
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds float, ptr %29, i64 %47
  store float %45, ptr %48, align 4, !tbaa !19
  %49 = load ptr, ptr %8, align 8, !tbaa !14
  %50 = getelementptr inbounds i32, ptr %49, i64 %indvars.iv
  %51 = load i32, ptr %50, align 4, !tbaa !20
  %52 = trunc i32 %51 to i8
  %53 = load ptr, ptr %23, align 8, !tbaa !21
  %54 = getelementptr inbounds i8, ptr %53, i64 %indvars.iv
  store i8 %52, ptr %54, align 1, !tbaa !22
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %55 = load i32, ptr %0, align 8, !tbaa !13
  %56 = zext i32 %55 to i64
  %57 = icmp ult i64 %indvars.iv.next, %56
  br i1 %57, label %24, label %._crit_edge, !llvm.loop !23

._crit_edge:                                      ; preds = %24, %4
  ret void
}

declare void @random_generate(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress 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 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !11, i64 96}
!6 = !{!"particle2particle_obj", !7, i64 0, !10, i64 4, !8, i64 8, !8, i64 20, !8, i64 32, !8, i64 44, !8, i64 56, !10, i64 68, !10, i64 72, !10, i64 76, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !12, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !10, i64 168}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"double", !8, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !11, i64 88}
!15 = !{!16, !11, i64 8}
!16 = !{!"particles_obj", !7, i64 0, !11, i64 8, !11, i64 16}
!17 = !{!18, !11, i64 8}
!18 = !{!"pots_obj", !7, i64 0, !11, i64 8}
!19 = !{!10, !10, i64 0}
!20 = !{!7, !7, i64 0}
!21 = !{!16, !11, i64 16}
!22 = !{!8, !8, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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