; LLVM IR from scemama/slaterlib :: src (core)

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

; 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 i64 @llvm.cttz.i64(i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @get_particles(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = zext i32 %15 to i64
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = zext i32 %17 to i64
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 0, ptr %13, align 4, !tbaa !5
  store i32 1, ptr %11, align 4, !tbaa !5
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %78, %4
  %20 = load i32, ptr %10, align 4, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = icmp ult i32 %20, %21
  br i1 %22, label %23, label %81

23:                                               ; preds = %19
  %24 = load ptr, ptr %6, align 8, !tbaa !9
  %25 = load i32, ptr %10, align 4, !tbaa !5
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds i64, ptr %24, i64 %26
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = load ptr, ptr %7, align 8, !tbaa !9
  %30 = load i32, ptr %10, align 4, !tbaa !5
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds i64, ptr %29, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = icmp ne i64 %28, %33
  br i1 %34, label %35, label %75

35:                                               ; preds = %23
  %36 = load ptr, ptr %6, align 8, !tbaa !9
  %37 = load i32, ptr %10, align 4, !tbaa !5
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds i64, ptr %36, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !11
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  %42 = load i32, ptr %10, align 4, !tbaa !5
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds i64, ptr %41, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !11
  %46 = xor i64 %40, %45
  %47 = load ptr, ptr %7, align 8, !tbaa !9
  %48 = load i32, ptr %10, align 4, !tbaa !5
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds i64, ptr %47, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !11
  %52 = and i64 %46, %51
  store i64 %52, ptr %12, align 8, !tbaa !11
  br label %53

53:                                               ; preds = %56, %35
  %54 = load i64, ptr %12, align 8, !tbaa !11
  %55 = icmp ne i64 %54, 0
  br i1 %55, label %56, label %74

56:                                               ; preds = %53
  %57 = load i64, ptr %12, align 8, !tbaa !11
  %58 = call i64 @llvm.cttz.i64(i64 %57, i1 true)
  %59 = trunc i64 %58 to i32
  store i32 %59, ptr %14, align 4, !tbaa !5
  %60 = load i32, ptr %14, align 4, !tbaa !5
  %61 = load i32, ptr %11, align 4, !tbaa !5
  %62 = add i32 %60, %61
  %63 = load ptr, ptr %8, align 8, !tbaa !9
  %64 = load i32, ptr %13, align 4, !tbaa !5
  %65 = zext i32 %64 to i64
  %66 = getelementptr inbounds i32, ptr %63, i64 %65
  store i32 %62, ptr %66, align 4, !tbaa !5
  %67 = load i32, ptr %14, align 4, !tbaa !5
  %68 = zext i32 %67 to i64
  %69 = shl i64 1, %68
  %70 = load i64, ptr %12, align 8, !tbaa !11
  %71 = xor i64 %70, %69
  store i64 %71, ptr %12, align 8, !tbaa !11
  %72 = load i32, ptr %13, align 4, !tbaa !5
  %73 = add i32 %72, 1
  store i32 %73, ptr %13, align 4, !tbaa !5
  br label %53, !llvm.loop !13

74:                                               ; preds = %53
  br label %75

75:                                               ; preds = %74, %23
  %76 = load i32, ptr %11, align 4, !tbaa !5
  %77 = add i32 %76, 64
  store i32 %77, ptr %11, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %75
  %79 = load i32, ptr %10, align 4, !tbaa !5
  %80 = add i32 %79, 1
  store i32 %80, ptr %10, align 4, !tbaa !5
  br label %19, !llvm.loop !15

81:                                               ; preds = %19
  %82 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %82, ptr %9, align 4, !tbaa !5
  %83 = load i32, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i32 %83
}

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 = !{!"int", !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 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !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"

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.cttz.i64(i64, i1 immarg) #0

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local i32 @get_particles(i32 noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #1 {
  %.not40 = icmp eq i32 %0, 0
  br i1 %.not40, label %._crit_edge, label %.lr.ph38.preheader

.lr.ph38.preheader:                               ; preds = %4
  %wide.trip.count = zext i32 %0 to i64
  br label %.lr.ph38

.lr.ph38:                                         ; preds = %.lr.ph38.preheader, %.loopexit
  %indvars.iv = phi i64 [ 0, %.lr.ph38.preheader ], [ %indvars.iv.next, %.loopexit ]
  %.02636 = phi i32 [ 0, %.lr.ph38.preheader ], [ %.2, %.loopexit ]
  %.02835 = phi i32 [ 1, %.lr.ph38.preheader ], [ %20, %.loopexit ]
  %5 = getelementptr inbounds i64, ptr %1, i64 %indvars.iv
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i64, ptr %2, i64 %indvars.iv
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %.not = icmp eq i64 %6, %8
  br i1 %.not, label %.loopexit, label %9

9:                                                ; preds = %.lr.ph38
  %10 = xor i64 %6, -1
  %11 = and i64 %8, %10
  %.not3132 = icmp eq i64 %11, 0
  br i1 %.not3132, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %9, %.lr.ph
  %.134 = phi i32 [ %19, %.lr.ph ], [ %.02636, %9 ]
  %.02733 = phi i64 [ %18, %.lr.ph ], [ %11, %9 ]
  %12 = tail call range(i64 0, 65) i64 @llvm.cttz.i64(i64 %.02733, i1 true)
  %13 = trunc nuw nsw i64 %12 to i32
  %14 = add i32 %.02835, %13
  %15 = zext i32 %.134 to i64
  %16 = getelementptr inbounds i32, ptr %3, i64 %15
  store i32 %14, ptr %16, align 4, !tbaa !9
  %17 = shl nuw i64 1, %12
  %18 = xor i64 %17, %.02733
  %19 = add i32 %.134, 1
  %.not31 = icmp eq i64 %17, %.02733
  br i1 %.not31, label %.loopexit, label %.lr.ph, !llvm.loop !11

.loopexit:                                        ; preds = %.lr.ph, %9, %.lr.ph38
  %.2 = phi i32 [ %.02636, %.lr.ph38 ], [ %.02636, %9 ], [ %19, %.lr.ph ]
  %20 = add i32 %.02835, 64
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph38, !llvm.loop !13

._crit_edge:                                      ; preds = %.loopexit, %4
  %.026.lcssa = phi i32 [ 0, %4 ], [ %.2, %.loopexit ]
  ret i32 %.026.lcssa
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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 = !{!"long 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass