; LLVM IR from kajott/GIPS :: src/vfs.ll (ZNK3VFS7DirList4ItemltERKS1_)

; 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"

%"struct.VFS::DirList::Item" = type <{ %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", i8, [7 x i8] }>
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

; 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: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK3VFS7DirList4ItemltERKS1_(ptr noundef nonnull align 8 dereferenceable(97) %0, ptr noundef nonnull align 8 dereferenceable(97) %1) #1 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  %9 = getelementptr inbounds %"struct.VFS::DirList::Item", ptr %8, i32 0, i32 3
  %10 = load i8, ptr %9, align 8, !tbaa !9, !range !15, !noundef !16
  %11 = trunc i8 %10 to i1
  %12 = zext i1 %11 to i32
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.VFS::DirList::Item", ptr %13, i32 0, i32 3
  %15 = load i8, ptr %14, align 8, !tbaa !9, !range !15, !noundef !16
  %16 = trunc i8 %15 to i1
  %17 = zext i1 %16 to i32
  %18 = icmp ne i32 %12, %17
  br i1 %18, label %19, label %23

19:                                               ; preds = %2
  %20 = getelementptr inbounds %"struct.VFS::DirList::Item", ptr %8, i32 0, i32 3
  %21 = load i8, ptr %20, align 8, !tbaa !9, !range !15, !noundef !16
  %22 = trunc i8 %21 to i1
  store i1 %22, ptr %3, align 1
  br label %64

23:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %24 = getelementptr inbounds %"struct.VFS::DirList::Item", ptr %8, i32 0, i32 0
  %25 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %24) #3
  store ptr %25, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.VFS::DirList::Item", ptr %26, i32 0, i32 0
  %28 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %27) #3
  store ptr %28, ptr %7, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %49, %23
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i8, ptr %30, align 1, !tbaa !17
  %32 = icmp ne i8 %31, 0
  br i1 %32, label %33, label %47

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

37:                                               ; preds = %33
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load i8, ptr %38, align 1, !tbaa !17
  %40 = sext i8 %39 to i32
  %41 = call i32 @tolower(i32 noundef %40) #4
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load i8, ptr %42, align 1, !tbaa !17
  %44 = sext i8 %43 to i32
  %45 = call i32 @tolower(i32 noundef %44) #4
  %46 = icmp eq i32 %41, %45
  br label %47

47:                                               ; preds = %37, %33, %29
  %48 = phi i1 [ false, %33 ], [ false, %29 ], [ %46, %37 ]
  br i1 %48, label %49, label %54

49:                                               ; preds = %47
  %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 ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %52, i32 1
  store ptr %53, ptr %7, align 8, !tbaa !5
  br label %29, !llvm.loop !18

54:                                               ; preds = %47
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load i8, ptr %55, align 1, !tbaa !17
  %57 = sext i8 %56 to i32
  %58 = call i32 @tolower(i32 noundef %57) #4
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = load i8, ptr %59, align 1, !tbaa !17
  %61 = sext i8 %60 to i32
  %62 = call i32 @tolower(i32 noundef %61) #4
  %63 = icmp slt i32 %58, %62
  store i1 %63, ptr %3, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %64

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @tolower(i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { nounwind willreturn memory(read) "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 }
attributes #4 = { nounwind willreturn memory(read) }

!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 = !{!10, !14, i64 96}
!10 = !{!"_ZTSN3VFS7DirList4ItemE", !11, i64 0, !11, i64 32, !11, i64 64, !14, i64 96}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !12, i64 0, !13, i64 8, !7, i64 16}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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 nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK3VFS7DirList4ItemltERKS1_(ptr noundef nonnull align 8 dereferenceable(97) %0, ptr noundef nonnull align 8 dereferenceable(97) %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 96
  %4 = load i8, ptr %3, align 8, !tbaa !5, !range !14, !noundef !15
  %5 = getelementptr inbounds i8, ptr %1, i64 96
  %6 = load i8, ptr %5, align 8, !tbaa !5, !range !14, !noundef !15
  %.not = icmp eq i8 %4, %6
  br i1 %.not, label %9, label %7

7:                                                ; preds = %2
  %8 = trunc nuw i8 %4 to i1
  br label %31

9:                                                ; preds = %2
  %10 = tail call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  %11 = tail call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #2
  %12 = load i8, ptr %10, align 1, !tbaa !16
  %.not1618 = icmp eq i8 %12, 0
  br i1 %.not1618, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %9, %21
  %13 = phi i8 [ %24, %21 ], [ %12, %9 ]
  %.020 = phi ptr [ %23, %21 ], [ %11, %9 ]
  %.01219 = phi ptr [ %22, %21 ], [ %10, %9 ]
  %14 = load i8, ptr %.020, align 1, !tbaa !16
  %.not17 = icmp eq i8 %14, 0
  br i1 %.not17, label %.critedge.loopexit, label %15

15:                                               ; preds = %.lr.ph
  %16 = sext i8 %13 to i32
  %17 = tail call i32 @tolower(i32 noundef %16) #3
  %18 = sext i8 %14 to i32
  %19 = tail call i32 @tolower(i32 noundef %18) #3
  %20 = icmp eq i32 %17, %19
  br i1 %20, label %21, label %.critedge.loopexit

21:                                               ; preds = %15
  %22 = getelementptr inbounds i8, ptr %.01219, i64 1
  %23 = getelementptr inbounds i8, ptr %.020, i64 1
  %24 = load i8, ptr %22, align 1, !tbaa !16
  %.not16 = icmp eq i8 %24, 0
  br i1 %.not16, label %.critedge.loopexit, label %.lr.ph, !llvm.loop !17

.critedge.loopexit:                               ; preds = %.lr.ph, %21, %15
  %.0.lcssa.ph = phi ptr [ %.020, %15 ], [ %23, %21 ], [ %.020, %.lr.ph ]
  %.lcssa.ph = phi i8 [ %13, %15 ], [ 0, %21 ], [ %13, %.lr.ph ]
  %25 = sext i8 %.lcssa.ph to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %9
  %.0.lcssa = phi ptr [ %11, %9 ], [ %.0.lcssa.ph, %.critedge.loopexit ]
  %.lcssa = phi i32 [ 0, %9 ], [ %25, %.critedge.loopexit ]
  %26 = tail call i32 @tolower(i32 noundef %.lcssa) #3
  %27 = load i8, ptr %.0.lcssa, align 1, !tbaa !16
  %28 = sext i8 %27 to i32
  %29 = tail call i32 @tolower(i32 noundef %28) #3
  %30 = icmp slt i32 %26, %29
  br label %31

31:                                               ; preds = %.critedge, %7
  %.013 = phi i1 [ %8, %7 ], [ %30, %.critedge ]
  ret i1 %.013
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @tolower(i32 noundef) local_unnamed_addr #1

attributes #0 = { 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 nofree nounwind willreturn memory(read) "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 }
attributes #3 = { nounwind willreturn memory(read) }

!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, !13, i64 96}
!6 = !{!"_ZTSN3VFS7DirList4ItemE", !7, i64 0, !7, i64 32, !7, i64 64, !13, i64 96}
!7 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !8, i64 0, !12, i64 8, !10, i64 16}
!8 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"long", !10, i64 0}
!13 = !{!"bool", !10, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!10, !10, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass