; LLVM IR from clibraries/array-algorithms :: test (impl)

; 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 i32 @intv_lexicographical_compare(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = 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 ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %54, %6
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = icmp eq ptr %17, %18
  br i1 %19, label %20, label %25

20:                                               ; preds = %16
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = load ptr, ptr %11, align 8, !tbaa !5
  %23 = icmp eq ptr %21, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %20
  store i32 0, ptr %7, align 4
  br label %55

25:                                               ; preds = %20, %16
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = icmp eq ptr %26, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %25
  store i32 -1, ptr %7, align 4
  br label %55

30:                                               ; preds = %25
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = icmp eq ptr %31, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  store i32 1, ptr %7, align 4
  br label %55

35:                                               ; preds = %30
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = load ptr, ptr %13, align 8, !tbaa !5
  %42 = call i32 %38(ptr noundef %39, ptr noundef %40, ptr noundef %41)
  store i32 %42, ptr %14, align 4, !tbaa !9
  %43 = load i32, ptr %14, align 4, !tbaa !9
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %47

45:                                               ; preds = %37
  %46 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %46, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %52

47:                                               ; preds = %37
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds i32, ptr %48, i32 1
  store ptr %49, ptr %8, align 8, !tbaa !5
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = getelementptr inbounds i32, ptr %50, i32 1
  store ptr %51, ptr %10, align 8, !tbaa !5
  store i32 0, ptr %15, align 4
  br label %52

52:                                               ; preds = %47, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  %53 = load i32, ptr %15, align 4
  switch i32 %53, label %57 [
    i32 0, label %54
    i32 1, label %55
  ]

54:                                               ; preds = %52
  br label %16

55:                                               ; preds = %52, %34, %29, %24
  %56 = load i32, ptr %7, align 4
  ret i32 %56

57:                                               ; preds = %52
  unreachable
}

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 = !{!"int", !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 i32 @intv_lexicographical_compare(ptr noundef %0, ptr noundef readnone %1, ptr noundef %2, ptr noundef readnone %3, ptr nocapture noundef readonly %4, ptr noundef %5) local_unnamed_addr #0 {
  br label %7

7:                                                ; preds = %10, %6
  %.020 = phi ptr [ %2, %6 ], [ %13, %10 ]
  %.018 = phi ptr [ %0, %6 ], [ %12, %10 ]
  %8 = icmp eq ptr %.018, %1
  %9 = icmp eq ptr %.020, %3
  %brmerge = select i1 %8, i1 true, i1 %9
  br i1 %brmerge, label %.split.loop.exit, label %10

10:                                               ; preds = %7
  %11 = tail call i32 %4(ptr noundef %.018, ptr noundef %.020, ptr noundef %5) #1
  %.not.not = icmp eq i32 %11, 0
  %12 = getelementptr inbounds i8, ptr %.018, i64 4
  %13 = getelementptr inbounds i8, ptr %.020, i64 4
  br i1 %.not.not, label %7, label %.split.loop.exit23

.split.loop.exit:                                 ; preds = %7
  %or.cond.le = select i1 %8, i1 %9, i1 false
  %not.or.cond.le = xor i1 %or.cond.le, true
  %.mux.le = sext i1 %not.or.cond.le to i32
  %.mux.mux.le = select i1 %8, i32 %.mux.le, i32 1
  br label %.split.loop.exit23

.split.loop.exit23:                               ; preds = %10, %.split.loop.exit
  %.2 = phi i32 [ %.mux.mux.le, %.split.loop.exit ], [ %11, %10 ]
  ret i32 %.2
}

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


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