; LLVM IR from ImChong/Practice_LeetCode_C :: F02_Programming_Topics/F01_Data_Structure/03_Hash_Table/06_CanConstruct/src (canConstruct)

; 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
define dso_local zeroext i1 @canConstruct(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [26 x i32], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 104, ptr %6) #3
  call void @llvm.memset.p0.i64(ptr align 16 %6, i8 0, i64 104, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %31, %2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds i8, ptr %11, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !11
  %16 = sext i8 %15 to i32
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %19, label %18

18:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %34

19:                                               ; preds = %10
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr %20, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = sext i8 %24 to i32
  %26 = sub nsw i32 %25, 97
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [26 x i32], ptr %6, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %28, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %19
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %7, align 4, !tbaa !9
  br label %10, !llvm.loop !12

34:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %69, %34
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i8, ptr %36, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !11
  %41 = sext i8 %40 to i32
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %44, label %43

43:                                               ; preds = %35
  store i32 5, ptr %9, align 4
  br label %72

44:                                               ; preds = %35
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i8, ptr %45, i64 %47
  %49 = load i8, ptr %48, align 1, !tbaa !11
  %50 = sext i8 %49 to i32
  %51 = sub nsw i32 %50, 97
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [26 x i32], ptr %6, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = add nsw i32 %54, -1
  store i32 %55, ptr %53, align 4, !tbaa !9
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = load i32, ptr %8, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr %56, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !11
  %61 = sext i8 %60 to i32
  %62 = sub nsw i32 %61, 97
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [26 x i32], ptr %6, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !9
  %66 = icmp slt i32 %65, 0
  br i1 %66, label %67, label %68

67:                                               ; preds = %44
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %72

68:                                               ; preds = %44
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %8, align 4, !tbaa !9
  br label %35, !llvm.loop !14

72:                                               ; preds = %67, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %73 = load i32, ptr %9, align 4
  switch i32 %73, label %75 [
    i32 5, label %74
  ]

74:                                               ; preds = %72
  store i1 true, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %75

75:                                               ; preds = %74, %72
  call void @llvm.lifetime.end.p0(i64 104, ptr %6) #3
  %76 = load i1, ptr %3, align 1
  ret i1 %76
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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: nofree norecurse nosync nounwind memory(argmem: read) uwtable
define dso_local noundef zeroext i1 @canConstruct(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca [26 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %3) #3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(104) %3, i8 0, i64 104, i1 false)
  %4 = load i8, ptr %1, align 1, !tbaa !5
  %.not19 = icmp eq i8 %4, 0
  br i1 %.not19, label %.preheader, label %.lr.ph

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

.lr.ph:                                           ; preds = %2, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %2 ]
  %6 = phi i8 [ %13, %.lr.ph ], [ %4, %2 ]
  %7 = sext i8 %6 to i64
  %8 = add nsw i64 %7, -97
  %9 = getelementptr inbounds [26 x i32], ptr %3, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !8
  %11 = add nsw i32 %10, 1
  store i32 %11, ptr %9, align 4, !tbaa !8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %12 = getelementptr inbounds i8, ptr %1, i64 %indvars.iv.next
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %.not = icmp eq i8 %13, 0
  br i1 %.not, label %.preheader, label %.lr.ph, !llvm.loop !10

14:                                               ; preds = %.lr.ph24
  %indvars.iv.next28 = add nuw nsw i64 %indvars.iv27, 1
  %15 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next28
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %.not18 = icmp eq i8 %16, 0
  br i1 %.not18, label %.critedge, label %.lr.ph24, !llvm.loop !12

.lr.ph24:                                         ; preds = %.preheader, %14
  %indvars.iv27 = phi i64 [ %indvars.iv.next28, %14 ], [ 0, %.preheader ]
  %17 = phi i8 [ %16, %14 ], [ %5, %.preheader ]
  %18 = sext i8 %17 to i64
  %19 = add nsw i64 %18, -97
  %20 = getelementptr inbounds [26 x i32], ptr %3, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !8
  %22 = add nsw i32 %21, -1
  store i32 %22, ptr %20, align 4, !tbaa !8
  %23 = icmp sgt i32 %21, 0
  br i1 %23, label %14, label %.critedge

.critedge:                                        ; preds = %.lr.ph24, %14, %.preheader
  %.not18.lcssa = phi i1 [ true, %.preheader ], [ %23, %14 ], [ %23, %.lr.ph24 ]
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %3) #3
  ret i1 %.not18.lcssa
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: read) 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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