; LLVM IR from begeekmyfriend/leetcode :: 0567_permutation_in_string (permutation_in_string)

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

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

21:                                               ; preds = %13
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i8, ptr %22, i64 %24
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = sext i8 %26 to i64
  %28 = getelementptr inbounds [128 x i32], ptr %7, 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 = %21
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %6, align 4, !tbaa !9
  br label %13, !llvm.loop !12

34:                                               ; preds = %13
  %35 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %35, ptr %8, align 4, !tbaa !9
  br label %36

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

44:                                               ; preds = %36
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load i32, ptr %10, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %10, align 4, !tbaa !9
  %48 = sext i32 %46 to i64
  %49 = getelementptr inbounds i8, ptr %45, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !11
  %51 = sext i8 %50 to i64
  %52 = getelementptr inbounds [128 x i32], ptr %7, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = add nsw i32 %53, -1
  store i32 %54, ptr %52, align 4, !tbaa !9
  %55 = icmp sge i32 %54, 0
  br i1 %55, label %56, label %59

56:                                               ; preds = %44
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %11, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %56, %44
  br label %60

60:                                               ; preds = %86, %59
  %61 = load i32, ptr %11, align 4, !tbaa !9
  %62 = load i32, ptr %8, align 4, !tbaa !9
  %63 = icmp sge i32 %61, %62
  br i1 %63, label %64, label %87

64:                                               ; preds = %60
  %65 = load i32, ptr %10, align 4, !tbaa !9
  %66 = load i32, ptr %9, align 4, !tbaa !9
  %67 = sub nsw i32 %65, %66
  %68 = load i32, ptr %8, align 4, !tbaa !9
  %69 = icmp eq i32 %67, %68
  br i1 %69, label %70, label %71

70:                                               ; preds = %64
  store i1 true, ptr %3, align 1
  store i32 1, ptr %12, align 4
  br label %89

71:                                               ; preds = %64
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %9, align 4, !tbaa !9
  %75 = sext i32 %73 to i64
  %76 = getelementptr inbounds i8, ptr %72, i64 %75
  %77 = load i8, ptr %76, align 1, !tbaa !11
  %78 = sext i8 %77 to i64
  %79 = getelementptr inbounds [128 x i32], ptr %7, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !9
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %79, align 4, !tbaa !9
  %82 = icmp sgt i32 %81, 0
  br i1 %82, label %83, label %86

83:                                               ; preds = %71
  %84 = load i32, ptr %11, align 4, !tbaa !9
  %85 = add nsw i32 %84, -1
  store i32 %85, ptr %11, align 4, !tbaa !9
  br label %86

86:                                               ; preds = %83, %71
  br label %60, !llvm.loop !14

87:                                               ; preds = %60
  br label %36, !llvm.loop !15

88:                                               ; preds = %36
  store i1 false, ptr %3, align 1
  store i32 1, ptr %12, align 4
  br label %89

89:                                               ; preds = %88, %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 512, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %90 = load i1, ptr %3, align 1
  ret i1 %90
}

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

.preheader.loopexit:                              ; preds = %.lr.ph
  %5 = trunc nuw nsw i64 %indvars.iv.next to i32
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %2
  %.023.lcssa = phi i32 [ 0, %2 ], [ %5, %.preheader.loopexit ]
  %6 = load i8, ptr %1, align 1, !tbaa !5
  %.not2441.not = icmp eq i8 %6, 0
  br i1 %.not2441.not, label %.loopexit27, label %.lr.ph46

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

.loopexit.loopexit:                               ; preds = %28
  %14 = trunc nsw i64 %indvars.iv.next52 to i32
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.lr.ph46
  %.121.lcssa = phi i32 [ %.02042, %.lr.ph46 ], [ %14, %.loopexit.loopexit ]
  %.2.lcssa = phi i32 [ %spec.select, %.lr.ph46 ], [ %spec.select26, %.loopexit.loopexit ]
  %15 = getelementptr inbounds i8, ptr %1, i64 %indvars.iv.next55
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %.not24.not = icmp eq i8 %16, 0
  br i1 %.not24.not, label %.loopexit27, label %.lr.ph46, !llvm.loop !12

.lr.ph46:                                         ; preds = %.preheader, %.loopexit
  %indvars.iv54 = phi i64 [ %indvars.iv.next55, %.loopexit ], [ 0, %.preheader ]
  %17 = phi i8 [ %16, %.loopexit ], [ %6, %.preheader ]
  %.044 = phi i32 [ %.2.lcssa, %.loopexit ], [ 0, %.preheader ]
  %.02042 = phi i32 [ %.121.lcssa, %.loopexit ], [ 0, %.preheader ]
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %18 = sext i8 %17 to i64
  %19 = getelementptr inbounds [128 x i32], ptr %3, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !8
  %21 = add nsw i32 %20, -1
  store i32 %21, ptr %19, align 4, !tbaa !8
  %22 = icmp sgt i32 %20, 0
  %23 = zext i1 %22 to i32
  %spec.select = add nsw i32 %.044, %23
  %.not2535 = icmp slt i32 %spec.select, %.023.lcssa
  br i1 %.not2535, label %.loopexit, label %.lr.ph38.preheader

.lr.ph38.preheader:                               ; preds = %.lr.ph46
  %24 = sext i32 %.02042 to i64
  br label %.lr.ph38

.lr.ph38:                                         ; preds = %.lr.ph38.preheader, %28
  %indvars.iv51 = phi i64 [ %24, %.lr.ph38.preheader ], [ %indvars.iv.next52, %28 ]
  %.237 = phi i32 [ %spec.select, %.lr.ph38.preheader ], [ %spec.select26, %28 ]
  %25 = sub nsw i64 %indvars.iv.next55, %indvars.iv51
  %26 = trunc nsw i64 %25 to i32
  %27 = icmp eq i32 %.023.lcssa, %26
  br i1 %27, label %.loopexit27, label %28

28:                                               ; preds = %.lr.ph38
  %indvars.iv.next52 = add nsw i64 %indvars.iv51, 1
  %29 = getelementptr inbounds i8, ptr %1, i64 %indvars.iv51
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = sext i8 %30 to i64
  %32 = getelementptr inbounds [128 x i32], ptr %3, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !8
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %32, align 4, !tbaa !8
  %35 = icmp sgt i32 %33, -1
  %36 = sext i1 %35 to i32
  %spec.select26 = add nsw i32 %.237, %36
  %.not25 = icmp slt i32 %spec.select26, %.023.lcssa
  br i1 %.not25, label %.loopexit.loopexit, label %.lr.ph38, !llvm.loop !13

.loopexit27:                                      ; preds = %.loopexit, %.lr.ph38, %.preheader
  %.not2432 = phi i1 [ false, %.preheader ], [ true, %.lr.ph38 ], [ false, %.loopexit ]
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %3) #3
  ret i1 %.not2432
}

; 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}
!13 = distinct !{!13, !11}


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