; LLVM IR from ismdeep/sort-algos-c :: include (sorted-assert)

; 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
declare dso_local zeroext i1 @data_equal(ptr noundef, ptr noundef, i64 noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @sorted_assert(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5) #0 {
  %7 = alloca i1, align 1
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i8, align 1
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i64 %4, ptr %12, align 8, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = ptrtoint ptr %21 to i64
  %24 = ptrtoint ptr %22 to i64
  %25 = sub i64 %23, %24
  %26 = load i64, ptr %12, align 8, !tbaa !9
  %27 = udiv i64 %25, %26
  store i64 %27, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %28 = load i64, ptr %14, align 8, !tbaa !9
  %29 = mul i64 1, %28
  %30 = call noalias ptr @malloc(i64 noundef %29) #5
  store ptr %30, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 0, ptr %17, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %42, %6
  %32 = load i32, ptr %17, align 4, !tbaa !11
  %33 = sext i32 %32 to i64
  %34 = load i64, ptr %14, align 8, !tbaa !9
  %35 = icmp ult i64 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %45

37:                                               ; preds = %31
  %38 = load ptr, ptr %15, align 8, !tbaa !5
  %39 = load i32, ptr %17, align 4, !tbaa !11
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i8, ptr %38, i64 %40
  store i8 0, ptr %41, align 1, !tbaa !13
  br label %42

42:                                               ; preds = %37
  %43 = load i32, ptr %17, align 4, !tbaa !11
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %17, align 4, !tbaa !11
  br label %31, !llvm.loop !15

45:                                               ; preds = %36
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %46, ptr %16, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %95, %45
  %48 = load ptr, ptr %16, align 8, !tbaa !5
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = icmp ult ptr %48, %49
  br i1 %50, label %51, label %96

51:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 1, ptr %18) #4
  store i8 0, ptr %18, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  store i32 0, ptr %19, align 4, !tbaa !11
  br label %52

52:                                               ; preds = %81, %51
  %53 = load i32, ptr %19, align 4, !tbaa !11
  %54 = sext i32 %53 to i64
  %55 = load i64, ptr %14, align 8, !tbaa !9
  %56 = icmp ult i64 %54, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %52
  store i32 7, ptr %20, align 4
  br label %84

58:                                               ; preds = %52
  %59 = load ptr, ptr %15, align 8, !tbaa !5
  %60 = load i32, ptr %19, align 4, !tbaa !11
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds i8, ptr %59, i64 %61
  %63 = load i8, ptr %62, align 1, !tbaa !13, !range !17, !noundef !18
  %64 = trunc i8 %63 to i1
  br i1 %64, label %80, label %65

65:                                               ; preds = %58
  %66 = load ptr, ptr %16, align 8, !tbaa !5
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = load i32, ptr %19, align 4, !tbaa !11
  %69 = sext i32 %68 to i64
  %70 = load i64, ptr %12, align 8, !tbaa !9
  %71 = mul i64 %69, %70
  %72 = getelementptr inbounds i8, ptr %67, i64 %71
  %73 = load i64, ptr %12, align 8, !tbaa !9
  %74 = call zeroext i1 @data_equal(ptr noundef %66, ptr noundef %72, i64 noundef %73)
  br i1 %74, label %75, label %80

75:                                               ; preds = %65
  %76 = load ptr, ptr %15, align 8, !tbaa !5
  %77 = load i32, ptr %19, align 4, !tbaa !11
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds i8, ptr %76, i64 %78
  store i8 1, ptr %79, align 1, !tbaa !13
  store i8 1, ptr %18, align 1, !tbaa !13
  store i32 7, ptr %20, align 4
  br label %84

80:                                               ; preds = %65, %58
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %19, align 4, !tbaa !11
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %19, align 4, !tbaa !11
  br label %52, !llvm.loop !19

84:                                               ; preds = %75, %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  br label %85

85:                                               ; preds = %84
  %86 = load i8, ptr %18, align 1, !tbaa !13, !range !17, !noundef !18
  %87 = trunc i8 %86 to i1
  br i1 %87, label %89, label %88

88:                                               ; preds = %85
  store i1 false, ptr %7, align 1
  store i32 1, ptr %20, align 4
  br label %93

89:                                               ; preds = %85
  %90 = load i64, ptr %12, align 8, !tbaa !9
  %91 = load ptr, ptr %16, align 8, !tbaa !5
  %92 = getelementptr inbounds i8, ptr %91, i64 %90
  store ptr %92, ptr %16, align 8, !tbaa !5
  store i32 0, ptr %20, align 4
  br label %93

93:                                               ; preds = %89, %88
  call void @llvm.lifetime.end.p0(i64 1, ptr %18) #4
  %94 = load i32, ptr %20, align 4
  switch i32 %94, label %120 [
    i32 0, label %95
  ]

95:                                               ; preds = %93
  br label %47, !llvm.loop !20

96:                                               ; preds = %47
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %97, ptr %16, align 8, !tbaa !5
  %98 = load i64, ptr %12, align 8, !tbaa !9
  %99 = load ptr, ptr %16, align 8, !tbaa !5
  %100 = getelementptr inbounds i8, ptr %99, i64 %98
  store ptr %100, ptr %16, align 8, !tbaa !5
  br label %101

101:                                              ; preds = %114, %96
  %102 = load ptr, ptr %16, align 8, !tbaa !5
  %103 = load ptr, ptr %11, align 8, !tbaa !5
  %104 = icmp ult ptr %102, %103
  br i1 %104, label %105, label %118

105:                                              ; preds = %101
  %106 = load ptr, ptr %13, align 8, !tbaa !5
  %107 = load ptr, ptr %16, align 8, !tbaa !5
  %108 = load i64, ptr %12, align 8, !tbaa !9
  %109 = sub i64 0, %108
  %110 = getelementptr inbounds i8, ptr %107, i64 %109
  %111 = load ptr, ptr %16, align 8, !tbaa !5
  %112 = call zeroext i1 %106(ptr noundef %110, ptr noundef %111)
  br i1 %112, label %114, label %113

113:                                              ; preds = %105
  store i1 false, ptr %7, align 1
  store i32 1, ptr %20, align 4
  br label %120

114:                                              ; preds = %105
  %115 = load i64, ptr %12, align 8, !tbaa !9
  %116 = load ptr, ptr %16, align 8, !tbaa !5
  %117 = getelementptr inbounds i8, ptr %116, i64 %115
  store ptr %117, ptr %16, align 8, !tbaa !5
  br label %101, !llvm.loop !21

118:                                              ; preds = %101
  %119 = load ptr, ptr %15, align 8, !tbaa !5
  call void @free(ptr noundef %119) #4
  store i1 true, ptr %7, align 1
  store i32 1, ptr %20, align 4
  br label %120

120:                                              ; preds = %118, %113, %93
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  %121 = load i1, ptr %7, align 1
  ret i1 %121
}

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 }
attributes #5 = { 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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !16}
!20 = distinct !{!20, !16}
!21 = distinct !{!21, !16}


; 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
declare dso_local zeroext i1 @data_equal(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @sorted_assert(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef readnone %3, i64 noundef %4, ptr nocapture noundef readonly %5) local_unnamed_addr #0 {
  %7 = ptrtoint ptr %1 to i64
  %8 = ptrtoint ptr %0 to i64
  %9 = sub i64 %7, %8
  %10 = udiv i64 %9, %4
  %11 = tail call noalias ptr @malloc(i64 noundef %10) #4
  %.not = icmp ult i64 %9, %4
  br i1 %.not, label %.preheader54.thread, label %iter.check

iter.check:                                       ; preds = %6
  %umax = tail call i64 @llvm.umax.i64(i64 %10, i64 1)
  %min.iters.check = icmp ult i64 %10, 8
  br i1 %min.iters.check, label %.lr.ph.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %iter.check
  %min.iters.check71 = icmp ult i64 %10, 32
  br i1 %min.iters.check71, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %n.vec = and i64 %umax, -32
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %12 = getelementptr inbounds i8, ptr %11, i64 %index
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  store <16 x i8> zeroinitializer, ptr %12, align 1, !tbaa !5
  store <16 x i8> zeroinitializer, ptr %13, align 1, !tbaa !5
  %index.next = add nuw i64 %index, 32
  %14 = icmp eq i64 %index.next, %n.vec
  br i1 %14, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %10, %n.vec
  br i1 %cmp.n, label %.preheader54, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  %n.vec.remaining = and i64 %umax, 24
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  br i1 %min.epilog.iters.check, label %.lr.ph.preheader, label %vec.epilog.ph

.lr.ph.preheader:                                 ; preds = %vec.epilog.middle.block, %iter.check, %vec.epilog.iter.check
  %indvars.iv.ph = phi i64 [ 0, %iter.check ], [ %n.vec, %vec.epilog.iter.check ], [ %n.vec73, %vec.epilog.middle.block ]
  br label %.lr.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.vec73 = and i64 %umax, -8
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index74 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next75, %vec.epilog.vector.body ]
  %15 = getelementptr inbounds i8, ptr %11, i64 %index74
  store <8 x i8> zeroinitializer, ptr %15, align 1, !tbaa !5
  %index.next75 = add nuw i64 %index74, 8
  %16 = icmp eq i64 %index.next75, %n.vec73
  br i1 %16, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !13

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n76 = icmp eq i64 %10, %n.vec73
  br i1 %cmp.n76, label %.preheader54, label %.lr.ph.preheader

.preheader54:                                     ; preds = %.lr.ph, %vec.epilog.middle.block, %middle.block
  %17 = icmp ult ptr %2, %3
  br i1 %17, label %.preheader52.lr.ph, label %.preheader.preheader

.preheader54.thread:                              ; preds = %6
  %18 = icmp ult ptr %2, %3
  br i1 %18, label %.critedge.thread, label %.preheader.preheader

.preheader52.lr.ph:                               ; preds = %.preheader54
  br i1 %.not, label %.critedge.thread, label %.preheader52

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader ]
  %19 = getelementptr inbounds i8, ptr %11, i64 %indvars.iv
  store i8 0, ptr %19, align 1, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %20 = icmp ugt i64 %10, %indvars.iv.next
  br i1 %20, label %.lr.ph, label %.preheader54, !llvm.loop !14

.preheader52:                                     ; preds = %.preheader52.lr.ph, %.critedge
  %.04359 = phi ptr [ %32, %.critedge ], [ %2, %.preheader52.lr.ph ]
  br label %21

21:                                               ; preds = %.preheader52, %29
  %indvars.iv64 = phi i64 [ 0, %.preheader52 ], [ %indvars.iv.next65, %29 ]
  %22 = getelementptr inbounds i8, ptr %11, i64 %indvars.iv64
  %23 = load i8, ptr %22, align 1, !tbaa !5, !range !15, !noundef !16
  %24 = trunc nuw i8 %23 to i1
  br i1 %24, label %29, label %25

25:                                               ; preds = %21
  %26 = mul i64 %indvars.iv64, %4
  %27 = getelementptr inbounds i8, ptr %0, i64 %26
  %28 = tail call zeroext i1 @data_equal(ptr noundef %.04359, ptr noundef %27, i64 noundef %4)
  br i1 %28, label %.critedge, label %29

29:                                               ; preds = %21, %25
  %indvars.iv.next65 = add nuw nsw i64 %indvars.iv64, 1
  %30 = icmp ugt i64 %10, %indvars.iv.next65
  br i1 %30, label %21, label %.critedge.thread, !llvm.loop !17

.critedge:                                        ; preds = %25
  %31 = getelementptr inbounds i8, ptr %11, i64 %indvars.iv64
  store i8 1, ptr %31, align 1, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %.04359, i64 %4
  %33 = icmp ult ptr %32, %3
  br i1 %33, label %.preheader52, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.critedge, %.preheader54.thread, %.preheader54
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %35
  %.pn = phi ptr [ %.2, %35 ], [ %2, %.preheader.preheader ]
  %.2 = getelementptr inbounds i8, ptr %.pn, i64 %4
  %34 = icmp ult ptr %.2, %3
  br i1 %34, label %35, label %37

35:                                               ; preds = %.preheader
  %36 = tail call zeroext i1 %5(ptr noundef %.pn, ptr noundef nonnull %.2) #5
  br i1 %36, label %.preheader, label %.critedge.thread, !llvm.loop !18

37:                                               ; preds = %.preheader
  tail call void @free(ptr noundef %11) #5
  br label %.critedge.thread

.critedge.thread:                                 ; preds = %29, %35, %.preheader54.thread, %.preheader52.lr.ph, %37
  %.246 = phi i1 [ true, %37 ], [ false, %.preheader52.lr.ph ], [ false, %.preheader54.thread ], [ false, %35 ], [ false, %29 ]
  ret i1 %.246
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #3

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 = { 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 #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind allocsize(0) }
attributes #5 = { 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 = !{!"_Bool", !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, !12}
!14 = distinct !{!14, !10, !12, !11}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}


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