; LLVM IR from HarshCasper/NeoAlgo :: C-Plus-Plus/cp (check_anagrams)

; 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: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z14check_anagramsNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES4_(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [256 x i32], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #4
  %12 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #4
  %13 = icmp ne i64 %11, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %73

15:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 1024, ptr %6) #4
  call void @llvm.memset.p0.i64(ptr align 16 %6, i8 0, i64 1024, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %31, %15
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #4
  %20 = icmp ult i64 %18, %19
  br i1 %20, label %22, label %21

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

22:                                               ; preds = %16
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %24)
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = sext i8 %26 to i64
  %28 = getelementptr inbounds [256 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 = %22
  %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 %16, !llvm.loop !12

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

35:                                               ; preds = %50, %34
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #4
  %39 = icmp ult i64 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %53

41:                                               ; preds = %35
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %1, i64 noundef %43)
  %45 = load i8, ptr %44, align 1, !tbaa !11
  %46 = sext i8 %45 to i64
  %47 = getelementptr inbounds [256 x i32], ptr %6, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = add nsw i32 %48, -1
  store i32 %49, ptr %47, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %41
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %8, align 4, !tbaa !9
  br label %35, !llvm.loop !14

53:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %66, %53
  %55 = load i32, ptr %9, align 4, !tbaa !9
  %56 = icmp slt i32 %55, 256
  br i1 %56, label %58, label %57

57:                                               ; preds = %54
  store i32 8, ptr %10, align 4
  br label %69

58:                                               ; preds = %54
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [256 x i32], ptr %6, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !9
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %58
  store i1 false, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %69

65:                                               ; preds = %58
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %9, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %9, align 4, !tbaa !9
  br label %54, !llvm.loop !15

69:                                               ; preds = %64, %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  %70 = load i32, ptr %10, align 4
  switch i32 %70, label %72 [
    i32 8, label %71
  ]

71:                                               ; preds = %69
  store i1 true, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %72

72:                                               ; preds = %71, %69
  call void @llvm.lifetime.end.p0(i64 1024, ptr %6) #4
  br label %73

73:                                               ; preds = %72, %14
  %74 = load i1, ptr %3, align 1
  ret i1 %74
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #1 align 2

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

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"int", !7, i64 0}
!11 = !{!7, !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: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z14check_anagramsNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES4_(ptr noundef nonnull %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca [256 x i32], align 16
  %4 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #3
  %5 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #3
  %.not = icmp eq i64 %4, %5
  br i1 %.not, label %6, label %37

6:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %3) #3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1024) %3, i8 0, i64 1024, i1 false)
  %7 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #3
  %.not22 = icmp eq i64 %7, 0
  br i1 %.not22, label %.preheader17, label %.lr.ph

.preheader17:                                     ; preds = %.lr.ph, %6
  %8 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #3
  %.not23 = icmp eq i64 %8, 0
  br i1 %.not23, label %.preheader, label %.lr.ph20

.lr.ph:                                           ; preds = %6, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %6 ]
  %9 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %indvars.iv)
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %11 = sext i8 %10 to i64
  %12 = getelementptr inbounds [256 x i32], ptr %3, i64 0, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !8
  %14 = add nsw i32 %13, 1
  store i32 %14, ptr %12, align 4, !tbaa !8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #3
  %16 = icmp ugt i64 %15, %indvars.iv.next
  br i1 %16, label %.lr.ph, label %.preheader17, !llvm.loop !10

.preheader:                                       ; preds = %.lr.ph20, %.preheader17
  %17 = load i32, ptr %3, align 16, !tbaa !8
  %.not1630 = icmp eq i32 %17, 0
  br i1 %.not1630, label %.lr.ph32, label %.critedge

.lr.ph20:                                         ; preds = %.preheader17, %.lr.ph20
  %indvars.iv25 = phi i64 [ %indvars.iv.next26, %.lr.ph20 ], [ 0, %.preheader17 ]
  %18 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %1, i64 noundef %indvars.iv25)
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = sext i8 %19 to i64
  %21 = getelementptr inbounds [256 x i32], ptr %3, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !8
  %23 = add nsw i32 %22, -1
  store i32 %23, ptr %21, align 4, !tbaa !8
  %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 1
  %24 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #3
  %25 = icmp ugt i64 %24, %indvars.iv.next26
  br i1 %25, label %.lr.ph20, label %.preheader, !llvm.loop !12

.lr.ph32:                                         ; preds = %.preheader, %32
  %indvars.iv2831 = phi i64 [ %indvars.iv.next29.3, %32 ], [ 0, %.preheader ]
  %indvars.iv.next29 = or disjoint i64 %indvars.iv2831, 1
  %26 = getelementptr inbounds [256 x i32], ptr %3, i64 0, i64 %indvars.iv.next29
  %27 = load i32, ptr %26, align 4, !tbaa !8
  %.not16 = icmp eq i32 %27, 0
  br i1 %.not16, label %.lr.ph32.1, label %.critedge, !llvm.loop !13

.lr.ph32.1:                                       ; preds = %.lr.ph32
  %indvars.iv.next29.1 = or disjoint i64 %indvars.iv2831, 2
  %28 = getelementptr inbounds [256 x i32], ptr %3, i64 0, i64 %indvars.iv.next29.1
  %29 = load i32, ptr %28, align 8, !tbaa !8
  %.not16.1 = icmp eq i32 %29, 0
  br i1 %.not16.1, label %.lr.ph32.2, label %.critedge, !llvm.loop !13

.lr.ph32.2:                                       ; preds = %.lr.ph32.1
  %indvars.iv.next29.2 = or disjoint i64 %indvars.iv2831, 3
  %30 = getelementptr inbounds [256 x i32], ptr %3, i64 0, i64 %indvars.iv.next29.2
  %31 = load i32, ptr %30, align 4, !tbaa !8
  %.not16.2 = icmp eq i32 %31, 0
  br i1 %.not16.2, label %.lr.ph32.3, label %.critedge, !llvm.loop !13

.lr.ph32.3:                                       ; preds = %.lr.ph32.2
  %indvars.iv.next29.3 = add nuw nsw i64 %indvars.iv2831, 4
  %exitcond.3 = icmp eq i64 %indvars.iv.next29.3, 256
  br i1 %exitcond.3, label %.critedge.loopexit.split.loop.exit36, label %32, !llvm.loop !13

32:                                               ; preds = %.lr.ph32.3
  %33 = getelementptr inbounds [256 x i32], ptr %3, i64 0, i64 %indvars.iv.next29.3
  %34 = load i32, ptr %33, align 16, !tbaa !8
  %.not16.3 = icmp eq i32 %34, 0
  br i1 %.not16.3, label %.lr.ph32, label %.critedge.loopexit.split.loop.exit, !llvm.loop !13

.critedge.loopexit.split.loop.exit:               ; preds = %32
  %35 = icmp ugt i64 %indvars.iv.next29.2, 254
  br label %.critedge

.critedge.loopexit.split.loop.exit36:             ; preds = %.lr.ph32.3
  %36 = icmp ugt i64 %indvars.iv.next29.2, 254
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit.split.loop.exit, %.critedge.loopexit.split.loop.exit36, %.lr.ph32.2, %.lr.ph32.1, %.lr.ph32, %.preheader
  %.lcssa = phi i1 [ false, %.preheader ], [ %35, %.critedge.loopexit.split.loop.exit ], [ %36, %.critedge.loopexit.split.loop.exit36 ], [ false, %.lr.ph32.2 ], [ false, %.lr.ph32.1 ], [ false, %.lr.ph32 ]
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %3) #3
  br label %37

37:                                               ; preds = %2, %.critedge
  %.2 = phi i1 [ %.lcssa, %.critedge ], [ false, %2 ]
  ret i1 %.2
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

; 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 nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 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 = { 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 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++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}


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