; LLVM IR from NongMindHouse/MasterNongMind :: mm-ga-pretty (SinglePointCrossover)

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

@CODE_LENGTH = external dso_local global i32, align 4

; 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
declare i32 @rand() #1

; Function Attrs: nounwind uwtable
define dso_local void @SinglePointCrossover(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %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
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %12 = call i32 @rand() #3
  %13 = load i32, ptr @CODE_LENGTH, align 4, !tbaa !9
  %14 = srem i32 %12, %13
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %40, %4
  %17 = load i32, ptr %10, align 4, !tbaa !9
  %18 = load i32, ptr %9, align 4, !tbaa !9
  %19 = icmp slt i32 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %43

21:                                               ; preds = %16
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load i32, ptr %10, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i32, ptr %22, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load i32, ptr %10, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i32, ptr %27, i64 %29
  store i32 %26, ptr %30, align 4, !tbaa !9
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load i32, ptr %10, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr %31, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !9
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr %36, i64 %38
  store i32 %35, ptr %39, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %21
  %41 = load i32, ptr %10, align 4, !tbaa !9
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %10, align 4, !tbaa !9
  br label %16, !llvm.loop !11

43:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %44 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %44, ptr %11, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %69, %43
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = load i32, ptr @CODE_LENGTH, align 4, !tbaa !9
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %72

50:                                               ; preds = %45
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr %51, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i32, ptr %56, i64 %58
  store i32 %55, ptr %59, align 4, !tbaa !9
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = load i32, ptr %11, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds i32, ptr %60, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !9
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = load i32, ptr %11, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds i32, ptr %65, i64 %67
  store i32 %64, ptr %68, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %50
  %70 = load i32, ptr %11, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %11, align 4, !tbaa !9
  br label %45, !llvm.loop !13

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

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


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

@CODE_LENGTH = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @SinglePointCrossover(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #1 {
  %5 = ptrtoint ptr %1 to i64
  %6 = ptrtoint ptr %0 to i64
  %7 = ptrtoint ptr %2 to i64
  %8 = ptrtoint ptr %3 to i64
  %9 = tail call i32 @rand() #2
  %10 = load i32, ptr @CODE_LENGTH, align 4, !tbaa !5
  %11 = srem i32 %9, %10
  %.not23 = icmp slt i32 %11, 0
  %.pre32 = add i32 %11, 1
  br i1 %.not23, label %.preheader, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %wide.trip.count = zext i32 %.pre32 to i64
  %min.iters.check = icmp ult i32 %.pre32, 24
  br i1 %min.iters.check, label %.lr.ph.preheader43, label %vector.memcheck

.lr.ph.preheader43:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %wide.trip.count, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader43
  %12 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv.ph
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.ph
  store i32 %13, ptr %14, align 4, !tbaa !5
  %15 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv.ph
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv.ph
  store i32 %16, ptr %17, align 4, !tbaa !5
  %indvars.iv.next.prol = or disjoint i64 %indvars.iv.ph, 1
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader43
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %.lr.ph.preheader43 ], [ %indvars.iv.next.prol, %.lr.ph.prol ]
  %18 = add nsw i64 %wide.trip.count, -1
  %19 = icmp eq i64 %indvars.iv.ph, %18
  br i1 %19, label %.preheader.loopexit, label %.lr.ph

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %20 = sub i64 %8, %7
  %diff.check = icmp ult i64 %20, 32
  %21 = sub i64 %7, %6
  %diff.check33 = icmp ult i64 %21, 32
  %conflict.rdx = or i1 %diff.check, %diff.check33
  %22 = sub i64 %5, %7
  %diff.check34 = icmp ult i64 %22, 32
  %conflict.rdx35 = or i1 %conflict.rdx, %diff.check34
  %23 = sub i64 %8, %6
  %diff.check36 = icmp ult i64 %23, 32
  %conflict.rdx37 = or i1 %conflict.rdx35, %diff.check36
  %24 = sub i64 %8, %5
  %diff.check38 = icmp ult i64 %24, 32
  %conflict.rdx39 = or i1 %conflict.rdx37, %diff.check38
  br i1 %conflict.rdx39, label %.lr.ph.preheader43, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 4294967288
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %25 = getelementptr inbounds i32, ptr %0, i64 %index
  %26 = getelementptr inbounds i8, ptr %25, i64 16
  %wide.load = load <4 x i32>, ptr %25, align 4, !tbaa !5
  %wide.load40 = load <4 x i32>, ptr %26, align 4, !tbaa !5
  %27 = getelementptr inbounds i32, ptr %2, i64 %index
  %28 = getelementptr inbounds i8, ptr %27, i64 16
  store <4 x i32> %wide.load, ptr %27, align 4, !tbaa !5
  store <4 x i32> %wide.load40, ptr %28, align 4, !tbaa !5
  %29 = getelementptr inbounds i32, ptr %1, i64 %index
  %30 = getelementptr inbounds i8, ptr %29, i64 16
  %wide.load41 = load <4 x i32>, ptr %29, align 4, !tbaa !5
  %wide.load42 = load <4 x i32>, ptr %30, align 4, !tbaa !5
  %31 = getelementptr inbounds i32, ptr %3, i64 %index
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  store <4 x i32> %wide.load41, ptr %31, align 4, !tbaa !5
  store <4 x i32> %wide.load42, ptr %32, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %33 = icmp eq i64 %index.next, %n.vec
  br i1 %33, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.preheader.loopexit, label %.lr.ph.preheader43

.preheader.loopexit:                              ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block
  %.pre = load i32, ptr @CODE_LENGTH, align 4, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %4, %.preheader.loopexit
  %34 = phi i32 [ %.pre, %.preheader.loopexit ], [ %10, %4 ]
  %35 = icmp slt i32 %.pre32, %34
  br i1 %35, label %.lr.ph27.preheader, label %._crit_edge

.lr.ph27.preheader:                               ; preds = %.preheader
  %36 = sext i32 %.pre32 to i64
  br label %.lr.ph27

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph ], [ %indvars.iv.unr, %.lr.ph.prol.loopexit ]
  %37 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
  store i32 %38, ptr %39, align 4, !tbaa !5
  %40 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv
  store i32 %41, ptr %42, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %43 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv.next
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.next
  store i32 %44, ptr %45, align 4, !tbaa !5
  %46 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv.next
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv.next
  store i32 %47, ptr %48, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
  br i1 %exitcond.not.1, label %.preheader.loopexit, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph27, %.preheader
  ret void

.lr.ph27:                                         ; preds = %.lr.ph27.preheader, %.lr.ph27
  %indvars.iv29 = phi i64 [ %36, %.lr.ph27.preheader ], [ %indvars.iv.next30, %.lr.ph27 ]
  %49 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv29
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv29
  store i32 %50, ptr %51, align 4, !tbaa !5
  %52 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv29
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv29
  store i32 %53, ptr %54, align 4, !tbaa !5
  %indvars.iv.next30 = add nsw i64 %indvars.iv29, 1
  %55 = load i32, ptr @CODE_LENGTH, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = icmp slt i64 %indvars.iv.next30, %56
  br i1 %57, label %.lr.ph27, label %._crit_edge, !llvm.loop !14
}

attributes #0 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass