; LLVM IR from scandum/blitsort :: src (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: nounwind uwtable
define dso_local x86_fp80 @blit_binary_median128(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %31, %4
  %10 = load i64, ptr %7, align 8, !tbaa !9
  %11 = udiv i64 %10, 2
  store i64 %11, ptr %7, align 8, !tbaa !9
  %12 = icmp ne i64 %11, 0
  br i1 %12, label %13, label %32

13:                                               ; preds = %9
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load i64, ptr %7, align 8, !tbaa !9
  %17 = getelementptr inbounds x86_fp80, ptr %15, i64 %16
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load i64, ptr %7, align 8, !tbaa !9
  %20 = getelementptr inbounds x86_fp80, ptr %18, i64 %19
  %21 = call i32 %14(ptr noundef %17, ptr noundef %20)
  %22 = icmp sle i32 %21, 0
  br i1 %22, label %23, label %27

23:                                               ; preds = %13
  %24 = load i64, ptr %7, align 8, !tbaa !9
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds x86_fp80, ptr %25, i64 %24
  store ptr %26, ptr %5, align 8, !tbaa !5
  br label %31

27:                                               ; preds = %13
  %28 = load i64, ptr %7, align 8, !tbaa !9
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds x86_fp80, ptr %29, i64 %28
  store ptr %30, ptr %6, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %27, %23
  br label %9, !llvm.loop !11

32:                                               ; preds = %9
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = call i32 %33(ptr noundef %34, ptr noundef %35)
  %37 = icmp sgt i32 %36, 0
  br i1 %37, label %38, label %41

38:                                               ; preds = %32
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load x86_fp80, ptr %39, align 16, !tbaa !13
  br label %44

41:                                               ; preds = %32
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load x86_fp80, ptr %42, align 16, !tbaa !13
  br label %44

44:                                               ; preds = %41, %38
  %45 = phi x86_fp80 [ %40, %38 ], [ %43, %41 ]
  ret x86_fp80 %45
}

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

!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"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long double", !7, i64 0}


; 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 x86_fp80 @blit_binary_median128(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %.not18 = icmp ult i64 %2, 2
  br i1 %.not18, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4, %.lr.ph
  %.021 = phi ptr [ %..0, %.lr.ph ], [ %0, %4 ]
  %.01420 = phi i64 [ %5, %.lr.ph ], [ %2, %4 ]
  %.01519 = phi ptr [ %.015., %.lr.ph ], [ %1, %4 ]
  %5 = lshr i64 %.01420, 1
  %6 = getelementptr inbounds x86_fp80, ptr %.021, i64 %5
  %7 = getelementptr inbounds x86_fp80, ptr %.01519, i64 %5
  %8 = tail call i32 %3(ptr noundef %6, ptr noundef %7) #1
  %9 = icmp slt i32 %8, 1
  %.015. = select i1 %9, ptr %.01519, ptr %7
  %..0 = select i1 %9, ptr %6, ptr %.021
  %.not = icmp ult i64 %.01420, 4
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %4
  %.015.lcssa = phi ptr [ %1, %4 ], [ %.015., %.lr.ph ]
  %.0.lcssa = phi ptr [ %0, %4 ], [ %..0, %.lr.ph ]
  %10 = tail call i32 %3(ptr noundef %.0.lcssa, ptr noundef %.015.lcssa) #1
  %11 = icmp sgt i32 %10, 0
  %.0..015 = select i1 %11, ptr %.0.lcssa, ptr %.015.lcssa
  %12 = load x86_fp80, ptr %.0..015, align 16, !tbaa !7
  ret x86_fp80 %12
}

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 = { 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"}
!7 = !{!8, !8, i64 0}
!8 = !{!"long double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}


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