; LLVM IR from lolosssss/leetcode :: c (242_valid_anagram)

; 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 @isAnagram(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 = %14, %2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = load i8, ptr %10, align 1, !tbaa !9
  %12 = sext i8 %11 to i32
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %25

14:                                               ; preds = %9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load i8, ptr %15, 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
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i32 1
  store ptr %24, ptr %4, align 8, !tbaa !5
  br label %9, !llvm.loop !12

25:                                               ; preds = %9
  br label %26

26:                                               ; preds = %31, %25
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load i8, ptr %27, align 1, !tbaa !9
  %29 = sext i8 %28 to i32
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %42

31:                                               ; preds = %26
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load i8, ptr %32, align 1, !tbaa !9
  %34 = sext i8 %33 to i32
  %35 = sub nsw i32 %34, 97
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [26 x i32], ptr %6, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !10
  %39 = add nsw i32 %38, -1
  store i32 %39, ptr %37, align 4, !tbaa !10
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i32 1
  store ptr %41, ptr %5, align 8, !tbaa !5
  br label %26, !llvm.loop !14

42:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !10
  br label %43

43:                                               ; preds = %55, %42
  %44 = load i32, ptr %7, align 4, !tbaa !10
  %45 = icmp slt i32 %44, 26
  br i1 %45, label %47, label %46

46:                                               ; preds = %43
  store i32 6, ptr %8, align 4
  br label %58

47:                                               ; preds = %43
  %48 = load i32, ptr %7, align 4, !tbaa !10
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [26 x i32], ptr %6, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !10
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %47
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %58

54:                                               ; preds = %47
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %7, align 4, !tbaa !10
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %7, align 4, !tbaa !10
  br label %43, !llvm.loop !15

58:                                               ; preds = %53, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %59 = load i32, ptr %8, align 4
  switch i32 %59, label %61 [
    i32 6, label %60
  ]

60:                                               ; preds = %58
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %61

61:                                               ; preds = %60, %58
  call void @llvm.lifetime.end.p0(i64 104, ptr %6) #3
  %62 = load i1, ptr %3, align 1
  ret i1 %62
}

; 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}
!15 = distinct !{!15, !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 zeroext i1 @isAnagram(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 %0, align 1, !tbaa !5
  %.not19 = icmp eq i8 %4, 0
  br i1 %.not19, label %.preheader18, label %.lr.ph

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

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

.preheader:                                       ; preds = %.lr.ph23, %.preheader18
  %14 = load <16 x i32>, ptr %3, align 16
  %.fr = freeze <16 x i32> %14
  %15 = getelementptr inbounds i8, ptr %3, i64 64
  %16 = load <8 x i32>, ptr %15, align 16
  %.fr76 = freeze <8 x i32> %16
  %17 = getelementptr inbounds i8, ptr %3, i64 96
  %18 = load i32, ptr %17, align 16
  %.fr77 = freeze i32 %18
  %.not17.24 = icmp eq i32 %.fr77, 0
  %19 = getelementptr inbounds i8, ptr %3, i64 100
  %20 = load i32, ptr %19, align 4
  %.not17.25 = icmp eq i32 %20, 0
  %21 = icmp ne <16 x i32> %.fr, zeroinitializer
  %22 = bitcast <16 x i1> %21 to i16
  %23 = icmp eq i16 %22, 0
  %24 = icmp ne <8 x i32> %.fr76, zeroinitializer
  %25 = bitcast <8 x i1> %24 to i8
  %26 = icmp eq i8 %25, 0
  %op.rdx = and i1 %23, %26
  %op.rdx74 = and i1 %op.rdx, %.not17.24
  %op.rdx75 = select i1 %op.rdx74, i1 %.not17.25, i1 false
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %3) #3
  ret i1 %op.rdx75

.lr.ph23:                                         ; preds = %.preheader18, %.lr.ph23
  %27 = phi i8 [ %34, %.lr.ph23 ], [ %5, %.preheader18 ]
  %.01122 = phi ptr [ %33, %.lr.ph23 ], [ %1, %.preheader18 ]
  %28 = sext i8 %27 to i64
  %29 = add nsw i64 %28, -97
  %30 = getelementptr inbounds [26 x i32], ptr %3, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !8
  %32 = add nsw i32 %31, -1
  store i32 %32, ptr %30, align 4, !tbaa !8
  %33 = getelementptr inbounds i8, ptr %.01122, i64 1
  %34 = load i8, ptr %33, align 1, !tbaa !5
  %.not16 = icmp eq i8 %34, 0
  br i1 %.not16, label %.preheader, label %.lr.ph23, !llvm.loop !12
}

; 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,GlobalDCEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass