; LLVM IR from Voultapher/sort-research-rs :: src/cpp/thirdparty/scandum (bench)

; 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 willreturn
declare ptr @llvm.stacksave.p0() #1

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @tail_swap128(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i64 @quad_swap128(ptr noundef, i64 noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @tail_merge128(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i64 @quad_merge128(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @blit_merge128(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local void @quadsort128(ptr noundef %0, i64 noundef %1, ptr noundef %2) #4 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca [512 x x86_fp80], align 16
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %15, ptr %7, align 8, !tbaa !5
  %16 = load i64, ptr %5, align 8, !tbaa !9
  %17 = icmp ult i64 %16, 32
  br i1 %17, label %18, label %26

18:                                               ; preds = %3
  %19 = load i64, ptr %5, align 8, !tbaa !9
  %20 = call ptr @llvm.stacksave.p0()
  store ptr %20, ptr %8, align 8
  %21 = alloca x86_fp80, i64 %19, align 16
  store i64 %19, ptr %9, align 8
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  call void @tail_swap128(ptr noundef %22, ptr noundef %21, i64 noundef %23, ptr noundef %24)
  %25 = load ptr, ptr %8, align 8
  call void @llvm.stackrestore.p0(ptr %25)
  br label %74

26:                                               ; preds = %3
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load i64, ptr %5, align 8, !tbaa !9
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call i64 @quad_swap128(ptr noundef %27, i64 noundef %28, ptr noundef %29)
  %31 = icmp eq i64 %30, 0
  br i1 %31, label %32, label %73

32:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store i64 32, ptr %12, align 8, !tbaa !9
  br label %33

33:                                               ; preds = %38, %32
  %34 = load i64, ptr %12, align 8, !tbaa !9
  %35 = mul i64 %34, 4
  %36 = load i64, ptr %5, align 8, !tbaa !9
  %37 = icmp ule i64 %35, %36
  br i1 %37, label %38, label %41

38:                                               ; preds = %33
  %39 = load i64, ptr %12, align 8, !tbaa !9
  %40 = mul i64 %39, 4
  store i64 %40, ptr %12, align 8, !tbaa !9
  br label %33, !llvm.loop !11

41:                                               ; preds = %33
  %42 = load i64, ptr %12, align 8, !tbaa !9
  %43 = mul i64 %42, 16
  %44 = call noalias ptr @malloc(i64 noundef %43) #6
  store ptr %44, ptr %10, align 8, !tbaa !5
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %56

47:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8192, ptr %13) #5
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds [512 x x86_fp80], ptr %13, i64 0, i64 0
  %50 = load i64, ptr %5, align 8, !tbaa !9
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  call void @tail_merge128(ptr noundef %48, ptr noundef %49, i64 noundef 32, i64 noundef %50, i64 noundef 32, ptr noundef %51)
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds [512 x x86_fp80], ptr %13, i64 0, i64 0
  %54 = load i64, ptr %5, align 8, !tbaa !9
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  call void @blit_merge128(ptr noundef %52, ptr noundef %53, i64 noundef 32, i64 noundef %54, i64 noundef 64, ptr noundef %55)
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 8192, ptr %13) #5
  br label %70

56:                                               ; preds = %41
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = load i64, ptr %12, align 8, !tbaa !9
  %60 = load i64, ptr %5, align 8, !tbaa !9
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = call i64 @quad_merge128(ptr noundef %57, ptr noundef %58, i64 noundef %59, i64 noundef %60, i64 noundef 32, ptr noundef %61)
  store i64 %62, ptr %11, align 8, !tbaa !9
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = load i64, ptr %12, align 8, !tbaa !9
  %66 = load i64, ptr %5, align 8, !tbaa !9
  %67 = load i64, ptr %11, align 8, !tbaa !9
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  call void @blit_merge128(ptr noundef %63, ptr noundef %64, i64 noundef %65, i64 noundef %66, i64 noundef %67, ptr noundef %68)
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %69) #5
  store i32 0, ptr %14, align 4
  br label %70

70:                                               ; preds = %56, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %71 = load i32, ptr %14, align 4
  switch i32 %71, label %75 [
    i32 0, label %72
  ]

72:                                               ; preds = %70
  br label %73

73:                                               ; preds = %72, %26
  br label %74

74:                                               ; preds = %73, %18
  store i32 0, ptr %14, align 4
  br label %75

75:                                               ; preds = %74, %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  %76 = load i32, ptr %14, align 4
  switch i32 %76, label %78 [
    i32 0, label %77
    i32 1, label %77
  ]

77:                                               ; preds = %75, %75
  ret void

78:                                               ; preds = %75
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn }
attributes #2 = { nounwind 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 #3 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @tail_swap128(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local i64 @quad_swap128(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local void @tail_merge128(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local i64 @quad_merge128(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local void @blit_merge128(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local void @quadsort128(ptr noundef %0, i64 noundef %1, ptr noundef %2) local_unnamed_addr #4 {
  %4 = alloca [512 x x86_fp80], align 16
  %5 = icmp ult i64 %1, 32
  br i1 %5, label %6, label %9

6:                                                ; preds = %3
  %7 = tail call ptr @llvm.stacksave.p0()
  %8 = alloca x86_fp80, i64 %1, align 16
  call void @tail_swap128(ptr noundef %0, ptr noundef nonnull %8, i64 noundef %1, ptr noundef %2)
  call void @llvm.stackrestore.p0(ptr %7)
  br label %19

9:                                                ; preds = %3
  %10 = tail call i64 @quad_swap128(ptr noundef %0, i64 noundef %1, ptr noundef %2)
  %11 = icmp eq i64 %10, 0
  br i1 %11, label %.preheader, label %19

.preheader:                                       ; preds = %9, %.preheader
  %.033 = phi i64 [ %12, %.preheader ], [ 32, %9 ]
  %12 = shl i64 %.033, 2
  %.not = icmp ugt i64 %12, %1
  br i1 %.not, label %13, label %.preheader, !llvm.loop !5

13:                                               ; preds = %.preheader
  %14 = shl i64 %.033, 4
  %15 = tail call noalias ptr @malloc(i64 noundef %14) #5
  %.not37 = icmp eq ptr %15, null
  br i1 %.not37, label %16, label %17

16:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8192, ptr nonnull %4) #6
  call void @tail_merge128(ptr noundef %0, ptr noundef nonnull %4, i64 noundef 32, i64 noundef %1, i64 noundef 32, ptr noundef %2)
  call void @blit_merge128(ptr noundef %0, ptr noundef nonnull %4, i64 noundef 32, i64 noundef %1, i64 noundef 64, ptr noundef %2)
  call void @llvm.lifetime.end.p0(i64 8192, ptr nonnull %4) #6
  br label %19

17:                                               ; preds = %13
  %18 = tail call i64 @quad_merge128(ptr noundef %0, ptr noundef nonnull %15, i64 noundef %.033, i64 noundef %1, i64 noundef 32, ptr noundef %2)
  tail call void @blit_merge128(ptr noundef %0, ptr noundef nonnull %15, i64 noundef %.033, i64 noundef %1, i64 noundef %18, ptr noundef %2)
  tail call void @free(ptr noundef nonnull %15) #6
  br label %19

19:                                               ; preds = %16, %17, %6, %9
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { 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 #5 = { nounwind allocsize(0) }
attributes #6 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass