; LLVM IR from Simple-XX/SimpleKernel :: src/drv/dtb/dtb.ll (ZN3DTB13find_via_pathEPKcP10resource_t)

; 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.DTB::node_t" = type { %"struct.DTB::path_t", ptr, ptr, ptr, i32, i32, i32, i32, i8, [16 x %"struct.DTB::prop_t"], i64 }
%"struct.DTB::path_t" = type { [16 x ptr], i64 }
%"struct.DTB::prop_t" = type { ptr, i64, i64 }
%struct.resource_t = type <{ i8, [7 x i8], ptr, %struct.anon, i8, [7 x i8] }>
%struct.anon = type { i64, i64 }

@.str.22 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [11 x i8], align 1

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

; Function Attrs: nounwind
declare i32 @strcmp(ptr noundef, ptr noundef) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3DTB13fill_resourceEP10resource_tPKNS_6node_tEPKNS_6prop_tE(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef, ptr noundef, ptr noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3DTB18find_node_via_pathEPKc(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN3DTB13find_via_pathEPKcP10resource_t(ptr noundef nonnull align 1 dereferenceable(1) %0, ptr noundef %1, ptr noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = call noundef ptr @_ZN3DTB18find_node_via_pathEPKc(ptr noundef nonnull align 1 dereferenceable(1) %9, ptr noundef %10)
  store ptr %11, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %65, %3
  %13 = load i64, ptr %8, align 8, !tbaa !9
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.DTB::node_t", ptr %14, i32 0, i32 10
  %16 = load i64, ptr %15, align 8, !tbaa !11
  %17 = icmp ult i64 %13, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %68

19:                                               ; preds = %12
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.DTB::node_t", ptr %20, i32 0, i32 9
  %22 = load i64, ptr %8, align 8, !tbaa !9
  %23 = getelementptr inbounds [16 x %"struct.DTB::prop_t"], ptr %21, i64 0, i64 %22
  %24 = getelementptr inbounds %"struct.DTB::prop_t", ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = call i32 @strcmp(ptr noundef %25, ptr noundef @.str.22) #4
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %41

28:                                               ; preds = %19
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.resource_t, ptr %29, i32 0, i32 0
  %31 = load i8, ptr %30, align 8, !tbaa !17
  %32 = zext i8 %31 to i32
  %33 = or i32 %32, 1
  %34 = trunc i32 %33 to i8
  store i8 %34, ptr %30, align 8, !tbaa !17
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.DTB::node_t", ptr %37, i32 0, i32 9
  %39 = load i64, ptr %8, align 8, !tbaa !9
  %40 = getelementptr inbounds [16 x %"struct.DTB::prop_t"], ptr %38, i64 0, i64 %39
  call void @_ZN3DTB13fill_resourceEP10resource_tPKNS_6node_tEPKNS_6prop_tE(ptr noundef nonnull align 1 dereferenceable(1) %9, ptr noundef %35, ptr noundef %36, ptr noundef %40)
  br label %64

41:                                               ; preds = %19
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.DTB::node_t", ptr %42, i32 0, i32 9
  %44 = load i64, ptr %8, align 8, !tbaa !9
  %45 = getelementptr inbounds [16 x %"struct.DTB::prop_t"], ptr %43, i64 0, i64 %44
  %46 = getelementptr inbounds %"struct.DTB::prop_t", ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !15
  %48 = call i32 @strcmp(ptr noundef %47, ptr noundef @.str.23) #4
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %63

50:                                               ; preds = %41
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.resource_t, ptr %51, i32 0, i32 0
  %53 = load i8, ptr %52, align 8, !tbaa !17
  %54 = zext i8 %53 to i32
  %55 = or i32 %54, 2
  %56 = trunc i32 %55 to i8
  store i8 %56, ptr %52, align 8, !tbaa !17
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.DTB::node_t", ptr %59, i32 0, i32 9
  %61 = load i64, ptr %8, align 8, !tbaa !9
  %62 = getelementptr inbounds [16 x %"struct.DTB::prop_t"], ptr %60, i64 0, i64 %61
  call void @_ZN3DTB13fill_resourceEP10resource_tPKNS_6node_tEPKNS_6prop_tE(ptr noundef nonnull align 1 dereferenceable(1) %9, ptr noundef %57, ptr noundef %58, ptr noundef %62)
  br label %63

63:                                               ; preds = %50, %41
  br label %64

64:                                               ; preds = %63, %28
  br label %65

65:                                               ; preds = %64
  %66 = load i64, ptr %8, align 8, !tbaa !9
  %67 = add i64 %66, 1
  store i64 %67, ptr %8, align 8, !tbaa !9
  br label %12, !llvm.loop !20

68:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret i1 true
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 #4 = { 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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 568}
!12 = !{!"_ZTSN3DTB6node_tE", !13, i64 0, !6, i64 136, !6, i64 144, !6, i64 152, !14, i64 160, !14, i64 164, !14, i64 168, !14, i64 172, !7, i64 176, !7, i64 184, !10, i64 568}
!13 = !{!"_ZTSN3DTB6path_tE", !7, i64 0, !10, i64 128}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"_ZTSN3DTB6prop_tE", !6, i64 0, !10, i64 8, !10, i64 16}
!17 = !{!18, !7, i64 0}
!18 = !{!"_ZTS10resource_t", !7, i64 0, !6, i64 8, !19, i64 16, !7, i64 32}
!19 = !{!"_ZTSN10resource_tUt0_E", !10, i64 0, !10, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"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"

%"struct.DTB::prop_t" = type { ptr, i64, i64 }

@.str.22 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3DTB13fill_resourceEP10resource_tPKNS_6node_tEPKNS_6prop_tE(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3DTB18find_node_via_pathEPKc(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN3DTB13find_via_pathEPKcP10resource_t(ptr noundef nonnull align 1 dereferenceable(1) %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 align 2 {
  %4 = tail call noundef ptr @_ZN3DTB18find_node_via_pathEPKc(ptr noundef nonnull align 1 dereferenceable(1) %0, ptr noundef %1)
  %5 = getelementptr inbounds i8, ptr %4, i64 568
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %7 = getelementptr inbounds i8, ptr %4, i64 184
  br label %8

._crit_edge:                                      ; preds = %18, %3
  ret i1 true

8:                                                ; preds = %.lr.ph, %18
  %.018 = phi i64 [ 0, %.lr.ph ], [ %19, %18 ]
  %9 = getelementptr inbounds [16 x %"struct.DTB::prop_t"], ptr %7, i64 0, i64 %.018
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %11 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %10, ptr noundef nonnull dereferenceable(1) @.str.22) #3
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %.sink.split, label %13

13:                                               ; preds = %8
  %14 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %10, ptr noundef nonnull dereferenceable(1) @.str.23) #3
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %.sink.split, label %18

.sink.split:                                      ; preds = %13, %8
  %.sink20 = phi i8 [ 1, %8 ], [ 2, %13 ]
  %16 = load i8, ptr %2, align 8, !tbaa !15
  %17 = or i8 %16, %.sink20
  store i8 %17, ptr %2, align 8, !tbaa !15
  tail call void @_ZN3DTB13fill_resourceEP10resource_tPKNS_6node_tEPKNS_6prop_tE(ptr noundef nonnull align 1 dereferenceable(1) %0, ptr noundef nonnull %2, ptr noundef nonnull %4, ptr noundef nonnull %9)
  br label %18

18:                                               ; preds = %.sink.split, %13
  %19 = add nuw i64 %.018, 1
  %20 = load i64, ptr %5, align 8, !tbaa !5
  %21 = icmp ult i64 %19, %20
  br i1 %21, label %8, label %._crit_edge, !llvm.loop !18
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: 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 #1 = { 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 #2 = { 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 #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, !10, i64 568}
!6 = !{!"_ZTSN3DTB6node_tE", !7, i64 0, !11, i64 136, !11, i64 144, !11, i64 152, !12, i64 160, !12, i64 164, !12, i64 168, !12, i64 172, !8, i64 176, !8, i64 184, !10, i64 568}
!7 = !{!"_ZTSN3DTB6path_tE", !8, i64 0, !10, i64 128}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!14, !11, i64 0}
!14 = !{!"_ZTSN3DTB6prop_tE", !11, i64 0, !10, i64 8, !10, i64 16}
!15 = !{!16, !8, i64 0}
!16 = !{!"_ZTS10resource_t", !8, i64 0, !11, i64 8, !17, i64 16, !8, i64 32}
!17 = !{!"_ZTSN10resource_tUt0_E", !10, i64 0, !10, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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