; LLVM IR from kajott/GIPS :: src/string_util.ll (ZN10StringUtil12pathContainsEPKcS1_)

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN10StringUtil9ispathsepEc(i8 noundef signext) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN10StringUtil12pathContainsEPKcS1_(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %20

12:                                               ; preds = %2
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %20

15:                                               ; preds = %12
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 0
  %18 = load i8, ptr %17, align 1, !tbaa !9
  %19 = icmp ne i8 %18, 0
  br i1 %19, label %21, label %20

20:                                               ; preds = %15, %12, %2
  store i1 false, ptr %3, align 1
  br label %65

21:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %22, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  store i8 1, ptr %7, align 1, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %23, ptr %8, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %58, %21
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load i8, ptr %25, align 1, !tbaa !9
  %27 = icmp ne i8 %26, 0
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 2, ptr %9, align 4
  br label %61

29:                                               ; preds = %24
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load i8, ptr %30, align 1, !tbaa !9
  %32 = call noundef zeroext i1 @_ZN10StringUtil9ispathsepEc(i8 noundef signext %31)
  br i1 %32, label %33, label %43

33:                                               ; preds = %29
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load i8, ptr %34, align 1, !tbaa !9
  %36 = icmp ne i8 %35, 0
  br i1 %36, label %41, label %37

37:                                               ; preds = %33
  %38 = load i8, ptr %7, align 1, !tbaa !10, !range !12, !noundef !13
  %39 = trunc i8 %38 to i1
  br i1 %39, label %40, label %41

40:                                               ; preds = %37
  store i1 true, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %61

41:                                               ; preds = %37, %33
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %42, ptr %6, align 8, !tbaa !5
  store i8 1, ptr %7, align 1, !tbaa !10
  br label %57

43:                                               ; preds = %29
  %44 = load i8, ptr %7, align 1, !tbaa !10, !range !12, !noundef !13
  %45 = trunc i8 %44 to i1
  br i1 %45, label %46, label %56

46:                                               ; preds = %43
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load i8, ptr %47, align 1, !tbaa !9
  %49 = sext i8 %48 to i32
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %50, i32 1
  store ptr %51, ptr %6, align 8, !tbaa !5
  %52 = load i8, ptr %50, align 1, !tbaa !9
  %53 = sext i8 %52 to i32
  %54 = icmp eq i32 %49, %53
  %55 = zext i1 %54 to i8
  store i8 %55, ptr %7, align 1, !tbaa !10
  br label %56

56:                                               ; preds = %46, %43
  br label %57

57:                                               ; preds = %56, %41
  br label %58

58:                                               ; preds = %57
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %59, i32 1
  store ptr %60, ptr %8, align 8, !tbaa !5
  br label %24, !llvm.loop !14

61:                                               ; preds = %40, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %62 = load i32, ptr %9, align 4
  switch i32 %62, label %64 [
    i32 2, label %63
  ]

63:                                               ; preds = %61
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %64

64:                                               ; preds = %63, %61
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %65

65:                                               ; preds = %64, %20
  %66 = load i1, ptr %3, align 1
  ret i1 %66
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress 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 = { mustprogress 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 #3 = { 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++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"bool", !7, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = distinct !{!14, !15}
!15 = !{!"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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN10StringUtil9ispathsepEc(i8 noundef signext) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN10StringUtil12pathContainsEPKcS1_(ptr noundef readonly %0, ptr noundef readonly %1) local_unnamed_addr #1 {
  %3 = icmp ne ptr %0, null
  %4 = icmp ne ptr %1, null
  %or.cond = and i1 %3, %4
  br i1 %or.cond, label %5, label %.critedge

5:                                                ; preds = %2
  %6 = load i8, ptr %1, align 1, !tbaa !5
  %.not = icmp eq i8 %6, 0
  br i1 %.not, label %.critedge, label %.preheader

.preheader:                                       ; preds = %5
  %7 = load i8, ptr %0, align 1, !tbaa !5
  %.not25.not27 = icmp eq i8 %7, 0
  br i1 %.not25.not27, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %22
  %8 = phi i8 [ %24, %22 ], [ %7, %.preheader ]
  %.01630 = phi ptr [ %23, %22 ], [ %0, %.preheader ]
  %.01729 = phi i8 [ %.1, %22 ], [ 1, %.preheader ]
  %.01828 = phi ptr [ %.119, %22 ], [ %1, %.preheader ]
  %9 = tail call noundef zeroext i1 @_ZN10StringUtil9ispathsepEc(i8 noundef signext %8)
  br i1 %9, label %10, label %14

10:                                               ; preds = %.lr.ph
  %11 = load i8, ptr %.01828, align 1, !tbaa !5
  %.not26 = icmp eq i8 %11, 0
  br i1 %.not26, label %12, label %22

12:                                               ; preds = %10
  %13 = trunc nuw i8 %.01729 to i1
  br i1 %13, label %.critedge, label %22

14:                                               ; preds = %.lr.ph
  %15 = trunc nuw i8 %.01729 to i1
  br i1 %15, label %16, label %22

16:                                               ; preds = %14
  %17 = load i8, ptr %.01630, align 1, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %.01828, i64 1
  %19 = load i8, ptr %.01828, align 1, !tbaa !5
  %20 = icmp eq i8 %17, %19
  %21 = zext i1 %20 to i8
  br label %22

22:                                               ; preds = %10, %12, %16, %14
  %.119 = phi ptr [ %18, %16 ], [ %.01828, %14 ], [ %1, %12 ], [ %1, %10 ]
  %.1 = phi i8 [ %21, %16 ], [ %.01729, %14 ], [ 1, %12 ], [ 1, %10 ]
  %23 = getelementptr inbounds i8, ptr %.01630, i64 1
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %.not25.not = icmp eq i8 %24, 0
  br i1 %.not25.not, label %.critedge, label %.lr.ph, !llvm.loop !8

.critedge:                                        ; preds = %12, %22, %.preheader, %2, %5
  %.2 = phi i1 [ false, %5 ], [ false, %2 ], [ false, %.preheader ], [ true, %12 ], [ false, %22 ]
  ret i1 %.2
}

attributes #0 = { inlinehint mustprogress 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 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass