; LLVM IR from DimitrisJim/leetcode_solutions :: C/Algorithms (383)

; 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
  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)
  br label %9

9:                                                ; preds = %13, %2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load i8, ptr %10, align 1, !tbaa !9
  %12 = icmp ne i8 %11, 0
  br i1 %12, label %13, label %23

13:                                               ; preds = %9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i32 1
  store ptr %15, ptr %5, align 8, !tbaa !5
  %16 = load i8, ptr %14, align 1, !tbaa !9
  %17 = sext i8 %16 to i32
  %18 = sub nsw i32 %17, 97
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [26 x i32], ptr %6, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !10
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %20, align 4, !tbaa !10
  br label %9, !llvm.loop !12

23:                                               ; preds = %9
  br label %24

24:                                               ; preds = %44, %23
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i8, ptr %25, align 1, !tbaa !9
  %27 = icmp ne i8 %26, 0
  br i1 %27, label %28, label %45

28:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i32 1
  store ptr %30, ptr %4, align 8, !tbaa !5
  %31 = load i8, ptr %29, align 1, !tbaa !9
  %32 = sext i8 %31 to i32
  %33 = sub nsw i32 %32, 97
  store i32 %33, ptr %7, align 4, !tbaa !10
  %34 = load i32, ptr %7, align 4, !tbaa !10
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [26 x i32], ptr %6, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !10
  %38 = add nsw i32 %37, -1
  store i32 %38, ptr %36, align 4, !tbaa !10
  %39 = icmp eq i32 %37, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %28
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %42

41:                                               ; preds = %28
  store i32 0, ptr %8, align 4
  br label %42

42:                                               ; preds = %41, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %43 = load i32, ptr %8, align 4
  switch i32 %43, label %46 [
    i32 0, label %44
  ]

44:                                               ; preds = %42
  br label %24, !llvm.loop !14

45:                                               ; preds = %24
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %46

46:                                               ; preds = %45, %42
  call void @llvm.lifetime.end.p0(i64 104, ptr %6) #3
  %47 = load i1, ptr %3, align 1
  ret i1 %47
}

; 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !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(read, inaccessiblemem: none) 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
  %.not13 = icmp eq i8 %4, 0
  br i1 %.not13, label %.preheader.preheader, label %.lr.ph

.lr.ph:                                           ; preds = %2, %.lr.ph
  %5 = phi i8 [ %12, %.lr.ph ], [ %4, %2 ]
  %.0714 = phi ptr [ %6, %.lr.ph ], [ %1, %2 ]
  %6 = getelementptr inbounds i8, ptr %.0714, i64 1
  %7 = sext i8 %5 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
  %12 = load i8, ptr %6, align 1, !tbaa !5
  %.not = icmp eq i8 %12, 0
  br i1 %.not, label %.preheader.preheader, label %.lr.ph, !llvm.loop !10

.preheader.preheader:                             ; preds = %.lr.ph, %2
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %14
  %.08 = phi ptr [ %15, %14 ], [ %0, %.preheader.preheader ]
  %13 = load i8, ptr %.08, align 1, !tbaa !5
  %.not11 = icmp eq i8 %13, 0
  br i1 %.not11, label %21, label %14

14:                                               ; preds = %.preheader
  %15 = getelementptr inbounds i8, ptr %.08, i64 1
  %16 = sext i8 %13 to i64
  %17 = add nsw i64 %16, -97
  %18 = getelementptr inbounds [26 x i32], ptr %3, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !8
  %20 = add nsw i32 %19, -1
  store i32 %20, ptr %18, align 4, !tbaa !8
  %.not12 = icmp eq i32 %19, 0
  br i1 %.not12, label %21, label %.preheader, !llvm.loop !12

21:                                               ; preds = %.preheader, %14
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %3) #3
  ret i1 %.not11
}

; 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(read, inaccessiblemem: none) 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: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass