; LLVM IR from ritikbanger/Hacktoberfest2022-DSA :: 09. String (Check-if-string-consists-of-unique-chars-Hashmaps)

; 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 @_Z11checkUniqueNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %0) #0 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %8 = call noalias noundef nonnull ptr @_Znam(i64 noundef 104) #7
  call void @llvm.memset.p0.i64(ptr align 4 %8, i8 0, i64 104, i1 false)
  store ptr %8, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %37, %1
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = sext i32 %10 to i64
  %12 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #6
  %13 = icmp ult i64 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %40

15:                                               ; preds = %9
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %17)
  %19 = load i8, ptr %18, align 1, !tbaa !11
  %20 = sext i8 %19 to i32
  %21 = call i32 @tolower(i32 noundef %20) #8
  %22 = trunc i32 %21 to i8
  %23 = load i32, ptr %5, 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)
  store i8 %22, ptr %25, align 1, !tbaa !11
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = load i32, ptr %5, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %28)
  %30 = load i8, ptr %29, align 1, !tbaa !11
  %31 = sext i8 %30 to i32
  %32 = sub nsw i32 %31, 97
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr %26, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %34, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %15
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %5, align 4, !tbaa !9
  br label %9, !llvm.loop !12

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

41:                                               ; preds = %54, %40
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = icmp slt i32 %42, 26
  br i1 %43, label %45, label %44

44:                                               ; preds = %41
  store i32 5, ptr %7, align 4
  br label %57

45:                                               ; preds = %41
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i32, ptr %46, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = icmp sgt i32 %50, 1
  br i1 %51, label %52, label %53

52:                                               ; preds = %45
  store i1 false, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %57

53:                                               ; preds = %45
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %6, align 4, !tbaa !9
  br label %41, !llvm.loop !14

57:                                               ; preds = %52, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %58 = load i32, ptr %7, align 4
  switch i32 %58, label %60 [
    i32 5, label %59
  ]

59:                                               ; preds = %57
  store i1 true, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %60

60:                                               ; preds = %59, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  %61 = load i1, ptr %2, align 1
  ret i1 %61
}

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #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 i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #4 align 2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @tolower(i32 noundef) #5

; 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) #4 align 2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nobuiltin allocsize(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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { nounwind willreturn memory(read) "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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { nounwind willreturn memory(read) }

!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}


; 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 uwtable
define dso_local noundef zeroext i1 @_Z11checkUniqueNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call noalias noundef nonnull dereferenceable(104) ptr @_Znam(i64 noundef 104) #5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(104) %2, i8 0, i64 104, i1 false)
  %invariant.gep = getelementptr i8, ptr %2, i64 -388
  %3 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #6
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %.preheader.thread, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph
  %.pre = load i32, ptr %2, align 4, !tbaa !5
  %4 = icmp sgt i32 %.pre, 1
  br i1 %4, label %.critedge, label %.preheader.thread

.lr.ph:                                           ; preds = %1, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %1 ]
  %5 = 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)
  %6 = load i8, ptr %5, align 1, !tbaa !9
  %7 = sext i8 %6 to i32
  %8 = tail call i32 @tolower(i32 noundef %7) #7
  %9 = trunc i32 %8 to i8
  %10 = 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)
  store i8 %9, ptr %10, align 1, !tbaa !9
  %11 = 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)
  %12 = load i8, ptr %11, align 1, !tbaa !9
  %13 = sext i8 %12 to i64
  %gep = getelementptr i32, ptr %invariant.gep, i64 %13
  %14 = load i32, ptr %gep, align 4, !tbaa !5
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %gep, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #6
  %17 = icmp ugt i64 %16, %indvars.iv.next
  br i1 %17, label %.lr.ph, label %.preheader, !llvm.loop !10

.preheader.thread:                                ; preds = %1, %.preheader
  %18 = getelementptr inbounds i8, ptr %2, i64 4
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = icmp sgt i32 %19, 1
  br i1 %20, label %.critedge, label %21

21:                                               ; preds = %.preheader.thread
  %22 = getelementptr inbounds i8, ptr %2, i64 8
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = icmp sgt i32 %23, 1
  br i1 %24, label %.critedge, label %25

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %2, i64 12
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = icmp sgt i32 %27, 1
  br i1 %28, label %.critedge, label %29

29:                                               ; preds = %25
  %30 = getelementptr inbounds i8, ptr %2, i64 16
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = icmp sgt i32 %31, 1
  br i1 %32, label %.critedge, label %33

33:                                               ; preds = %29
  %34 = getelementptr inbounds i8, ptr %2, i64 20
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = icmp sgt i32 %35, 1
  br i1 %36, label %.critedge, label %37

37:                                               ; preds = %33
  %38 = getelementptr inbounds i8, ptr %2, i64 24
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = icmp sgt i32 %39, 1
  br i1 %40, label %.critedge, label %41

41:                                               ; preds = %37
  %42 = getelementptr inbounds i8, ptr %2, i64 28
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = icmp sgt i32 %43, 1
  br i1 %44, label %.critedge, label %45

45:                                               ; preds = %41
  %46 = getelementptr inbounds i8, ptr %2, i64 32
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = icmp sgt i32 %47, 1
  br i1 %48, label %.critedge, label %49

49:                                               ; preds = %45
  %50 = getelementptr inbounds i8, ptr %2, i64 36
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = icmp sgt i32 %51, 1
  br i1 %52, label %.critedge, label %53

53:                                               ; preds = %49
  %54 = getelementptr inbounds i8, ptr %2, i64 40
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = icmp sgt i32 %55, 1
  br i1 %56, label %.critedge, label %57

57:                                               ; preds = %53
  %58 = getelementptr inbounds i8, ptr %2, i64 44
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = icmp sgt i32 %59, 1
  br i1 %60, label %.critedge, label %61

61:                                               ; preds = %57
  %62 = getelementptr inbounds i8, ptr %2, i64 48
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = icmp sgt i32 %63, 1
  br i1 %64, label %.critedge, label %65

65:                                               ; preds = %61
  %66 = getelementptr inbounds i8, ptr %2, i64 52
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = icmp sgt i32 %67, 1
  br i1 %68, label %.critedge, label %69

69:                                               ; preds = %65
  %70 = getelementptr inbounds i8, ptr %2, i64 56
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = icmp sgt i32 %71, 1
  br i1 %72, label %.critedge, label %73

73:                                               ; preds = %69
  %74 = getelementptr inbounds i8, ptr %2, i64 60
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = icmp sgt i32 %75, 1
  br i1 %76, label %.critedge, label %77

77:                                               ; preds = %73
  %78 = getelementptr inbounds i8, ptr %2, i64 64
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = icmp sgt i32 %79, 1
  br i1 %80, label %.critedge, label %81

81:                                               ; preds = %77
  %82 = getelementptr inbounds i8, ptr %2, i64 68
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = icmp sgt i32 %83, 1
  br i1 %84, label %.critedge, label %85

85:                                               ; preds = %81
  %86 = getelementptr inbounds i8, ptr %2, i64 72
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = icmp sgt i32 %87, 1
  br i1 %88, label %.critedge, label %89

89:                                               ; preds = %85
  %90 = getelementptr inbounds i8, ptr %2, i64 76
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = icmp sgt i32 %91, 1
  br i1 %92, label %.critedge, label %93

93:                                               ; preds = %89
  %94 = getelementptr inbounds i8, ptr %2, i64 80
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = icmp sgt i32 %95, 1
  br i1 %96, label %.critedge, label %97

97:                                               ; preds = %93
  %98 = getelementptr inbounds i8, ptr %2, i64 84
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = icmp sgt i32 %99, 1
  br i1 %100, label %.critedge, label %101

101:                                              ; preds = %97
  %102 = getelementptr inbounds i8, ptr %2, i64 88
  %103 = load i32, ptr %102, align 4, !tbaa !5
  %104 = icmp sgt i32 %103, 1
  br i1 %104, label %.critedge, label %105

105:                                              ; preds = %101
  %106 = getelementptr inbounds i8, ptr %2, i64 92
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = icmp sgt i32 %107, 1
  br i1 %108, label %.critedge, label %109

109:                                              ; preds = %105
  %110 = getelementptr inbounds i8, ptr %2, i64 96
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = icmp sgt i32 %111, 1
  br i1 %112, label %.critedge, label %113

113:                                              ; preds = %109
  %114 = getelementptr inbounds i8, ptr %2, i64 100
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = icmp slt i32 %115, 2
  br label %.critedge

.critedge:                                        ; preds = %113, %109, %105, %101, %97, %93, %89, %85, %81, %77, %73, %69, %65, %61, %57, %53, %49, %45, %41, %37, %33, %29, %25, %21, %.preheader.thread, %.preheader
  %.lcssa = phi i1 [ false, %.preheader ], [ false, %.preheader.thread ], [ false, %21 ], [ false, %25 ], [ false, %29 ], [ false, %33 ], [ false, %37 ], [ false, %41 ], [ false, %45 ], [ false, %49 ], [ false, %53 ], [ false, %57 ], [ false, %61 ], [ false, %65 ], [ false, %69 ], [ false, %73 ], [ false, %77 ], [ false, %81 ], [ false, %85 ], [ false, %89 ], [ false, %93 ], [ false, %97 ], [ false, %101 ], [ false, %105 ], [ false, %109 ], [ %116, %113 ]
  ret i1 %.lcssa
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #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 i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @tolower(i32 noundef) local_unnamed_addr #4

; 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 #3 align 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 = { nobuiltin allocsize(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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { mustprogress nofree nounwind willreturn memory(read) "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 #5 = { builtin allocsize(0) }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


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