; 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: nounwind uwtable
declare dso_local void @trim_four128(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local x86_fp80 @median_of_nine128(ptr noundef %0, i64 noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca [9 x x86_fp80], align 16
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  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) #2
  call void @llvm.lifetime.start.p0(i64 144, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %12 = load i64, ptr %5, align 8, !tbaa !9
  %13 = udiv i64 %12, 9
  store i64 %13, ptr %11, align 8, !tbaa !9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %14, ptr %7, align 8, !tbaa !5
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %26, %3
  %16 = load i64, ptr %9, align 8, !tbaa !9
  %17 = icmp ult i64 %16, 9
  br i1 %17, label %18, label %29

18:                                               ; preds = %15
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load x86_fp80, ptr %19, align 16, !tbaa !11
  %21 = load i64, ptr %9, align 8, !tbaa !9
  %22 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 %21
  store x86_fp80 %20, ptr %22, align 16, !tbaa !11
  %23 = load i64, ptr %11, align 8, !tbaa !9
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds x86_fp80, ptr %24, i64 %23
  store ptr %25, ptr %7, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %18
  %27 = load i64, ptr %9, align 8, !tbaa !9
  %28 = add i64 %27, 1
  store i64 %28, ptr %9, align 8, !tbaa !9
  br label %15, !llvm.loop !13

29:                                               ; preds = %15
  %30 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 0
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  call void @trim_four128(ptr noundef %30, ptr noundef %31)
  %32 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 0
  %33 = getelementptr inbounds x86_fp80, ptr %32, i64 4
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  call void @trim_four128(ptr noundef %33, ptr noundef %34)
  %35 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 5
  %36 = load x86_fp80, ptr %35, align 16, !tbaa !11
  %37 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 0
  store x86_fp80 %36, ptr %37, align 16, !tbaa !11
  %38 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 8
  %39 = load x86_fp80, ptr %38, align 16, !tbaa !11
  %40 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 3
  store x86_fp80 %39, ptr %40, align 16, !tbaa !11
  %41 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 0
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  call void @trim_four128(ptr noundef %41, ptr noundef %42)
  %43 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 6
  %44 = load x86_fp80, ptr %43, align 16, !tbaa !11
  %45 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 0
  store x86_fp80 %44, ptr %45, align 16, !tbaa !11
  %46 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 0
  %47 = getelementptr inbounds x86_fp80, ptr %46, i64 0
  %48 = load x86_fp80, ptr %47, align 16, !tbaa !11
  %49 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 0
  %50 = getelementptr inbounds x86_fp80, ptr %49, i64 1
  %51 = load x86_fp80, ptr %50, align 16, !tbaa !11
  %52 = fcmp ogt x86_fp80 %48, %51
  %53 = zext i1 %52 to i32
  %54 = icmp sgt i32 %53, 0
  %55 = zext i1 %54 to i32
  %56 = sext i32 %55 to i64
  store i64 %56, ptr %9, align 8, !tbaa !9
  %57 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 0
  %58 = getelementptr inbounds x86_fp80, ptr %57, i64 0
  %59 = load x86_fp80, ptr %58, align 16, !tbaa !11
  %60 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 0
  %61 = getelementptr inbounds x86_fp80, ptr %60, i64 2
  %62 = load x86_fp80, ptr %61, align 16, !tbaa !11
  %63 = fcmp ogt x86_fp80 %59, %62
  %64 = zext i1 %63 to i32
  %65 = icmp sgt i32 %64, 0
  %66 = zext i1 %65 to i32
  %67 = sext i32 %66 to i64
  store i64 %67, ptr %10, align 8, !tbaa !9
  %68 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 0
  %69 = getelementptr inbounds x86_fp80, ptr %68, i64 1
  %70 = load x86_fp80, ptr %69, align 16, !tbaa !11
  %71 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 0
  %72 = getelementptr inbounds x86_fp80, ptr %71, i64 2
  %73 = load x86_fp80, ptr %72, align 16, !tbaa !11
  %74 = fcmp ogt x86_fp80 %70, %73
  %75 = zext i1 %74 to i32
  %76 = icmp sgt i32 %75, 0
  %77 = zext i1 %76 to i32
  %78 = sext i32 %77 to i64
  store i64 %78, ptr %11, align 8, !tbaa !9
  %79 = load i64, ptr %9, align 8, !tbaa !9
  %80 = load i64, ptr %10, align 8, !tbaa !9
  %81 = icmp eq i64 %79, %80
  %82 = zext i1 %81 to i32
  %83 = sext i32 %82 to i64
  %84 = load i64, ptr %10, align 8, !tbaa !9
  %85 = load i64, ptr %11, align 8, !tbaa !9
  %86 = xor i64 %84, %85
  %87 = add i64 %83, %86
  %88 = getelementptr inbounds [9 x x86_fp80], ptr %8, i64 0, i64 %87
  %89 = load x86_fp80, ptr %88, align 16, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 144, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret x86_fp80 %89
}

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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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: nounwind uwtable
declare dso_local void @trim_four128(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local x86_fp80 @median_of_nine128(ptr nocapture noundef readonly %0, i64 noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = alloca [9 x x86_fp80], align 16
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %4) #2
  %5 = udiv i64 %1, 9
  %6 = load x86_fp80, ptr %0, align 16, !tbaa !5
  store x86_fp80 %6, ptr %4, align 16, !tbaa !5
  %7 = getelementptr inbounds x86_fp80, ptr %0, i64 %5
  %8 = load x86_fp80, ptr %7, align 16, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %4, i64 16
  store x86_fp80 %8, ptr %9, align 16, !tbaa !5
  %10 = getelementptr inbounds x86_fp80, ptr %7, i64 %5
  %11 = load x86_fp80, ptr %10, align 16, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %4, i64 32
  store x86_fp80 %11, ptr %12, align 16, !tbaa !5
  %13 = getelementptr inbounds x86_fp80, ptr %10, i64 %5
  %14 = load x86_fp80, ptr %13, align 16, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %4, i64 48
  store x86_fp80 %14, ptr %15, align 16, !tbaa !5
  %16 = getelementptr inbounds x86_fp80, ptr %13, i64 %5
  %17 = load x86_fp80, ptr %16, align 16, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %4, i64 64
  store x86_fp80 %17, ptr %18, align 16, !tbaa !5
  %19 = getelementptr inbounds x86_fp80, ptr %16, i64 %5
  %20 = load x86_fp80, ptr %19, align 16, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %4, i64 80
  store x86_fp80 %20, ptr %21, align 16, !tbaa !5
  %22 = getelementptr inbounds x86_fp80, ptr %19, i64 %5
  %23 = load x86_fp80, ptr %22, align 16, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %4, i64 96
  store x86_fp80 %23, ptr %24, align 16, !tbaa !5
  %25 = getelementptr inbounds x86_fp80, ptr %22, i64 %5
  %26 = load x86_fp80, ptr %25, align 16, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %4, i64 112
  store x86_fp80 %26, ptr %27, align 16, !tbaa !5
  %28 = getelementptr inbounds x86_fp80, ptr %25, i64 %5
  %29 = load x86_fp80, ptr %28, align 16, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %4, i64 128
  store x86_fp80 %29, ptr %30, align 16, !tbaa !5
  call void @trim_four128(ptr noundef nonnull %4, ptr noundef %2)
  call void @trim_four128(ptr noundef nonnull %18, ptr noundef %2)
  %31 = load x86_fp80, ptr %21, align 16, !tbaa !5
  store x86_fp80 %31, ptr %4, align 16, !tbaa !5
  %32 = load x86_fp80, ptr %30, align 16, !tbaa !5
  store x86_fp80 %32, ptr %15, align 16, !tbaa !5
  call void @trim_four128(ptr noundef nonnull %4, ptr noundef %2)
  %33 = load x86_fp80, ptr %24, align 16, !tbaa !5
  store x86_fp80 %33, ptr %4, align 16, !tbaa !5
  %34 = load x86_fp80, ptr %9, align 16, !tbaa !5
  %35 = load x86_fp80, ptr %12, align 16, !tbaa !5
  %36 = fcmp ogt x86_fp80 %33, %35
  %37 = fcmp ogt x86_fp80 %34, %35
  %38 = fcmp ule x86_fp80 %33, %34
  %39 = xor i1 %38, %36
  %40 = zext i1 %39 to i64
  %41 = xor i1 %36, %37
  %42 = zext i1 %41 to i64
  %43 = add nuw nsw i64 %40, %42
  %44 = getelementptr inbounds [9 x x86_fp80], ptr %4, i64 0, i64 %43
  %45 = load x86_fp80, ptr %44, align 16, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %4) #2
  ret x86_fp80 %45
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass