; 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: 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
define dso_local void @quad_reversal128(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca x86_fp80, align 16
  %8 = alloca x86_fp80, align 16
  %9 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = ptrtoint ptr %10 to i64
  %13 = ptrtoint ptr %11 to i64
  %14 = sub i64 %12, %13
  %15 = sdiv exact i64 %14, 16
  %16 = sdiv i64 %15, 2
  store i64 %16, ptr %9, align 8, !tbaa !9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = load i64, ptr %9, align 8, !tbaa !9
  %19 = getelementptr inbounds x86_fp80, ptr %17, i64 %18
  store ptr %19, ptr %5, align 8, !tbaa !5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load i64, ptr %9, align 8, !tbaa !9
  %22 = sub i64 0, %21
  %23 = getelementptr inbounds x86_fp80, ptr %20, i64 %22
  store ptr %23, ptr %6, align 8, !tbaa !5
  %24 = load i64, ptr %9, align 8, !tbaa !9
  %25 = urem i64 %24, 2
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %27, label %39

27:                                               ; preds = %2
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = load x86_fp80, ptr %28, align 16, !tbaa !11
  store x86_fp80 %29, ptr %8, align 16, !tbaa !11
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load x86_fp80, ptr %30, align 16, !tbaa !11
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds x86_fp80, ptr %32, i32 -1
  store ptr %33, ptr %5, align 8, !tbaa !5
  store x86_fp80 %31, ptr %32, align 16, !tbaa !11
  %34 = load x86_fp80, ptr %8, align 16, !tbaa !11
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds x86_fp80, ptr %35, i32 1
  store ptr %36, ptr %6, align 8, !tbaa !5
  store x86_fp80 %34, ptr %35, align 16, !tbaa !11
  %37 = load i64, ptr %9, align 8, !tbaa !9
  %38 = add i64 %37, -1
  store i64 %38, ptr %9, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %27, %2
  %40 = load i64, ptr %9, align 8, !tbaa !9
  %41 = udiv i64 %40, 2
  store i64 %41, ptr %9, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %61, %39
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = load x86_fp80, ptr %43, align 16, !tbaa !11
  store x86_fp80 %44, ptr %7, align 16, !tbaa !11
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load x86_fp80, ptr %45, align 16, !tbaa !11
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds x86_fp80, ptr %47, i32 1
  store ptr %48, ptr %3, align 8, !tbaa !5
  store x86_fp80 %46, ptr %47, align 16, !tbaa !11
  %49 = load x86_fp80, ptr %7, align 16, !tbaa !11
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds x86_fp80, ptr %50, i32 -1
  store ptr %51, ptr %4, align 8, !tbaa !5
  store x86_fp80 %49, ptr %50, align 16, !tbaa !11
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load x86_fp80, ptr %52, align 16, !tbaa !11
  store x86_fp80 %53, ptr %8, align 16, !tbaa !11
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load x86_fp80, ptr %54, align 16, !tbaa !11
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds x86_fp80, ptr %56, i32 -1
  store ptr %57, ptr %5, align 8, !tbaa !5
  store x86_fp80 %55, ptr %56, align 16, !tbaa !11
  %58 = load x86_fp80, ptr %8, align 16, !tbaa !11
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds x86_fp80, ptr %59, i32 1
  store ptr %60, ptr %6, align 8, !tbaa !5
  store x86_fp80 %58, ptr %59, align 16, !tbaa !11
  br label %61

61:                                               ; preds = %42
  %62 = load i64, ptr %9, align 8, !tbaa !9
  %63 = add i64 %62, -1
  store i64 %63, ptr %9, align 8, !tbaa !9
  %64 = icmp ne i64 %62, 0
  br i1 %64, label %42, label %65, !llvm.loop !13

65:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @quad_reversal128(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = ptrtoint ptr %1 to i64
  %4 = ptrtoint ptr %0 to i64
  %5 = sub i64 %3, %4
  %6 = ashr exact i64 %5, 4
  %7 = sdiv i64 %6, 2
  %8 = getelementptr inbounds x86_fp80, ptr %0, i64 %7
  %9 = sub nsw i64 0, %7
  %10 = getelementptr inbounds x86_fp80, ptr %1, i64 %9
  %11 = and i64 %7, 1
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %13, label %19

13:                                               ; preds = %2
  %14 = load x86_fp80, ptr %8, align 16, !tbaa !5
  %15 = load x86_fp80, ptr %10, align 16, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %8, i64 -16
  store x86_fp80 %15, ptr %8, align 16, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %10, i64 16
  store x86_fp80 %14, ptr %10, align 16, !tbaa !5
  %18 = add nsw i64 %7, -1
  br label %19

19:                                               ; preds = %13, %2
  %.028 = phi ptr [ %17, %13 ], [ %10, %2 ]
  %.026 = phi ptr [ %16, %13 ], [ %8, %2 ]
  %.0 = phi i64 [ %18, %13 ], [ %7, %2 ]
  %20 = lshr i64 %.0, 1
  %21 = and i64 %.0, 2
  %lcmp.mod.not.not = icmp eq i64 %21, 0
  br i1 %lcmp.mod.not.not, label %.prol.loopexit.unr-lcssa, label %.prol.loopexit

.prol.loopexit.unr-lcssa:                         ; preds = %19
  %22 = load x86_fp80, ptr %0, align 16, !tbaa !5
  %23 = load x86_fp80, ptr %1, align 16, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  store x86_fp80 %23, ptr %0, align 16, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %1, i64 -16
  store x86_fp80 %22, ptr %1, align 16, !tbaa !5
  %26 = load x86_fp80, ptr %.026, align 16, !tbaa !5
  %27 = load x86_fp80, ptr %.028, align 16, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %.026, i64 -16
  store x86_fp80 %27, ptr %.026, align 16, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %.028, i64 16
  store x86_fp80 %26, ptr %.028, align 16, !tbaa !5
  %30 = add nsw i64 %20, -1
  br label %.prol.loopexit

.prol.loopexit:                                   ; preds = %.prol.loopexit.unr-lcssa, %19
  %.129.unr = phi ptr [ %.028, %19 ], [ %29, %.prol.loopexit.unr-lcssa ]
  %.127.unr = phi ptr [ %.026, %19 ], [ %28, %.prol.loopexit.unr-lcssa ]
  %.025.unr = phi ptr [ %1, %19 ], [ %25, %.prol.loopexit.unr-lcssa ]
  %.024.unr = phi ptr [ %0, %19 ], [ %24, %.prol.loopexit.unr-lcssa ]
  %.1.unr = phi i64 [ %20, %19 ], [ %30, %.prol.loopexit.unr-lcssa ]
  %31 = icmp ult i64 %.0, 2
  br i1 %31, label %.unr-lcssa, label %.new

.new:                                             ; preds = %.prol.loopexit, %.new
  %.129 = phi ptr [ %47, %.new ], [ %.129.unr, %.prol.loopexit ]
  %.127 = phi ptr [ %46, %.new ], [ %.127.unr, %.prol.loopexit ]
  %.025 = phi ptr [ %43, %.new ], [ %.025.unr, %.prol.loopexit ]
  %.024 = phi ptr [ %42, %.new ], [ %.024.unr, %.prol.loopexit ]
  %.1 = phi i64 [ %48, %.new ], [ %.1.unr, %.prol.loopexit ]
  %32 = load x86_fp80, ptr %.024, align 16, !tbaa !5
  %33 = load x86_fp80, ptr %.025, align 16, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %.024, i64 16
  store x86_fp80 %33, ptr %.024, align 16, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %.025, i64 -16
  store x86_fp80 %32, ptr %.025, align 16, !tbaa !5
  %36 = load x86_fp80, ptr %.127, align 16, !tbaa !5
  %37 = load x86_fp80, ptr %.129, align 16, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %.127, i64 -16
  store x86_fp80 %37, ptr %.127, align 16, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %.129, i64 16
  store x86_fp80 %36, ptr %.129, align 16, !tbaa !5
  %40 = load x86_fp80, ptr %34, align 16, !tbaa !5
  %41 = load x86_fp80, ptr %35, align 16, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %.024, i64 32
  store x86_fp80 %41, ptr %34, align 16, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %.025, i64 -32
  store x86_fp80 %40, ptr %35, align 16, !tbaa !5
  %44 = load x86_fp80, ptr %38, align 16, !tbaa !5
  %45 = load x86_fp80, ptr %39, align 16, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %.127, i64 -32
  store x86_fp80 %45, ptr %38, align 16, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %.129, i64 32
  store x86_fp80 %44, ptr %39, align 16, !tbaa !5
  %48 = add nsw i64 %.1, -2
  %.not.1 = icmp eq i64 %.1, 1
  br i1 %.not.1, label %.unr-lcssa, label %.new, !llvm.loop !9

.unr-lcssa:                                       ; preds = %.new, %.prol.loopexit
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass