; LLVM IR from MinaFaried3/Assiut-University-Training---Newcomers :: m-sheet10_general_hard (I-Coins)

; 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"

%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@_Z3ABCB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@abc = external dso_local global [3 x i32], align 4

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5checkNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #3
  %9 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef 0)
  %10 = load i8, ptr %9, align 1, !tbaa !9
  store i8 %10, ptr %3, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #3
  %11 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef 1)
  %12 = load i8, ptr %11, align 1, !tbaa !9
  store i8 %12, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  %13 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef 2)
  %14 = load i8, ptr %13, align 1, !tbaa !9
  store i8 %14, ptr %5, align 1, !tbaa !9
  %15 = load i8, ptr %4, align 1, !tbaa !9
  %16 = sext i8 %15 to i32
  %17 = icmp eq i32 %16, 62
  br i1 %17, label %18, label %44

18:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !10
  br label %19

19:                                               ; preds = %39, %18
  %20 = load i32, ptr %6, align 4, !tbaa !10
  %21 = icmp slt i32 %20, 3
  br i1 %21, label %23, label %22

22:                                               ; preds = %19
  store i32 2, ptr %7, align 4
  br label %42

23:                                               ; preds = %19
  %24 = load i32, ptr %6, align 4, !tbaa !10
  %25 = sext i32 %24 to i64
  %26 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3ABCB5cxx11, i64 noundef %25)
  %27 = load i8, ptr %26, align 1, !tbaa !9
  %28 = sext i8 %27 to i32
  %29 = load i8, ptr %3, align 1, !tbaa !9
  %30 = sext i8 %29 to i32
  %31 = icmp eq i32 %28, %30
  br i1 %31, label %32, label %38

32:                                               ; preds = %23
  %33 = load i32, ptr %6, align 4, !tbaa !10
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [3 x i32], ptr @abc, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !10
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %35, align 4, !tbaa !10
  store i32 2, ptr %7, align 4
  br label %42

38:                                               ; preds = %23
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %6, align 4, !tbaa !10
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %6, align 4, !tbaa !10
  br label %19, !llvm.loop !12

42:                                               ; preds = %32, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %43

43:                                               ; preds = %42
  br label %70

44:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !10
  br label %45

45:                                               ; preds = %65, %44
  %46 = load i32, ptr %8, align 4, !tbaa !10
  %47 = icmp slt i32 %46, 3
  br i1 %47, label %49, label %48

48:                                               ; preds = %45
  store i32 5, ptr %7, align 4
  br label %68

49:                                               ; preds = %45
  %50 = load i32, ptr %8, align 4, !tbaa !10
  %51 = sext i32 %50 to i64
  %52 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3ABCB5cxx11, i64 noundef %51)
  %53 = load i8, ptr %52, align 1, !tbaa !9
  %54 = sext i8 %53 to i32
  %55 = load i8, ptr %5, align 1, !tbaa !9
  %56 = sext i8 %55 to i32
  %57 = icmp eq i32 %54, %56
  br i1 %57, label %58, label %64

58:                                               ; preds = %49
  %59 = load i32, ptr %8, align 4, !tbaa !10
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [3 x i32], ptr @abc, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !10
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %61, align 4, !tbaa !10
  store i32 5, ptr %7, align 4
  br label %68

64:                                               ; preds = %49
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %8, align 4, !tbaa !10
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %8, align 4, !tbaa !10
  br label %45, !llvm.loop !14

68:                                               ; preds = %58, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %69

69:                                               ; preds = %68
  br label %70

70:                                               ; preds = %69, %43
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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++ 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"

%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@_Z3ABCB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@abc = external dso_local local_unnamed_addr global [3 x i32], align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z5checkNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull %0) local_unnamed_addr #0 {
  %2 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef 0)
  %3 = load i8, ptr %2, align 1, !tbaa !5
  %4 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef 1)
  %5 = load i8, ptr %4, align 1, !tbaa !5
  %6 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef 2)
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = icmp eq i8 %5, 62
  %9 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3ABCB5cxx11, i64 noundef 0)
  %10 = load i8, ptr %9, align 1, !tbaa !5
  br i1 %8, label %.preheader.preheader, label %.preheader12.preheader

.preheader12.preheader:                           ; preds = %1
  %11 = icmp eq i8 %10, %7
  br i1 %11, label %.loopexit.sink.split, label %.preheader12.1

.preheader.preheader:                             ; preds = %1
  %12 = icmp eq i8 %10, %3
  br i1 %12, label %.loopexit.sink.split, label %.preheader.1

.preheader.1:                                     ; preds = %.preheader.preheader
  %13 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3ABCB5cxx11, i64 noundef 1)
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = icmp eq i8 %14, %3
  br i1 %15, label %.loopexit.sink.split, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %16 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3ABCB5cxx11, i64 noundef 2)
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %18 = icmp eq i8 %17, %3
  br i1 %18, label %.loopexit.sink.split, label %.loopexit

.preheader12.1:                                   ; preds = %.preheader12.preheader
  %19 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3ABCB5cxx11, i64 noundef 1)
  %20 = load i8, ptr %19, align 1, !tbaa !5
  %21 = icmp eq i8 %20, %7
  br i1 %21, label %.loopexit.sink.split, label %.preheader12.2

.preheader12.2:                                   ; preds = %.preheader12.1
  %22 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z3ABCB5cxx11, i64 noundef 2)
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %24 = icmp eq i8 %23, %7
  br i1 %24, label %.loopexit.sink.split, label %.loopexit

.loopexit.sink.split:                             ; preds = %.preheader12.preheader, %.preheader12.1, %.preheader12.2, %.preheader.preheader, %.preheader.1, %.preheader.2
  %.lcssa19.sink = phi i64 [ 0, %.preheader.preheader ], [ 1, %.preheader.1 ], [ 2, %.preheader.2 ], [ 0, %.preheader12.preheader ], [ 1, %.preheader12.1 ], [ 2, %.preheader12.2 ]
  %25 = getelementptr inbounds [3 x i32], ptr @abc, i64 0, i64 %.lcssa19.sink
  %26 = load i32, ptr %25, align 4, !tbaa !8
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %25, align 4, !tbaa !8
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.sink.split, %.preheader12.2, %.preheader.2
  ret void
}

; 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

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

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


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