; LLVM IR from UtkarshPathrabe/Competitive-Coding :: HackerRank Solutions/Algorithms/Strings/Pangrams.ll (Z9IsPangramv)

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

@flag = external dso_local global [26 x i8], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z9IsPangramv() #0 {
  %1 = alloca i1, align 1
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %16, %0
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = icmp slt i32 %5, 26
  br i1 %6, label %8, label %7

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

8:                                                ; preds = %4
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [26 x i8], ptr @flag, i64 0, i64 %10
  %12 = load i8, ptr %11, align 1, !tbaa !9, !range !11, !noundef !12
  %13 = trunc i8 %12 to i1
  br i1 %13, label %15, label %14

14:                                               ; preds = %8
  store i1 false, ptr %1, align 1
  store i32 1, ptr %3, align 4
  br label %19

15:                                               ; preds = %8
  br label %16

16:                                               ; preds = %15
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %2, align 4, !tbaa !5
  br label %4, !llvm.loop !13

19:                                               ; preds = %14, %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  %20 = load i32, ptr %3, align 4
  switch i32 %20, label %24 [
    i32 2, label %21
    i32 1, label %22
  ]

21:                                               ; preds = %19
  store i1 true, ptr %1, align 1
  br label %22

22:                                               ; preds = %21, %19
  %23 = load i1, ptr %1, align 1
  ret i1 %23

24:                                               ; preds = %19
  unreachable
}

; 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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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

@flag = external dso_local local_unnamed_addr global [26 x i8], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_Z9IsPangramv() local_unnamed_addr #0 {
  %1 = load i8, ptr @flag, align 16, !tbaa !5, !range !9, !noundef !10
  %2 = trunc nuw i8 %1 to i1
  br i1 %2, label %3, label %78

3:                                                ; preds = %0
  %4 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 1), align 1, !tbaa !5, !range !9, !noundef !10
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %6, label %78

6:                                                ; preds = %3
  %7 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 2), align 2, !tbaa !5, !range !9, !noundef !10
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %9, label %78

9:                                                ; preds = %6
  %10 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 3), align 1, !tbaa !5, !range !9, !noundef !10
  %11 = trunc nuw i8 %10 to i1
  br i1 %11, label %12, label %78

12:                                               ; preds = %9
  %13 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 4), align 4, !tbaa !5, !range !9, !noundef !10
  %14 = trunc nuw i8 %13 to i1
  br i1 %14, label %15, label %78

15:                                               ; preds = %12
  %16 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 5), align 1, !tbaa !5, !range !9, !noundef !10
  %17 = trunc nuw i8 %16 to i1
  br i1 %17, label %18, label %78

18:                                               ; preds = %15
  %19 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 6), align 2, !tbaa !5, !range !9, !noundef !10
  %20 = trunc nuw i8 %19 to i1
  br i1 %20, label %21, label %78

21:                                               ; preds = %18
  %22 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 7), align 1, !tbaa !5, !range !9, !noundef !10
  %23 = trunc nuw i8 %22 to i1
  br i1 %23, label %24, label %78

24:                                               ; preds = %21
  %25 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 8), align 8, !tbaa !5, !range !9, !noundef !10
  %26 = trunc nuw i8 %25 to i1
  br i1 %26, label %27, label %78

27:                                               ; preds = %24
  %28 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 9), align 1, !tbaa !5, !range !9, !noundef !10
  %29 = trunc nuw i8 %28 to i1
  br i1 %29, label %30, label %78

30:                                               ; preds = %27
  %31 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 10), align 2, !tbaa !5, !range !9, !noundef !10
  %32 = trunc nuw i8 %31 to i1
  br i1 %32, label %33, label %78

33:                                               ; preds = %30
  %34 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 11), align 1, !tbaa !5, !range !9, !noundef !10
  %35 = trunc nuw i8 %34 to i1
  br i1 %35, label %36, label %78

36:                                               ; preds = %33
  %37 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 12), align 4, !tbaa !5, !range !9, !noundef !10
  %38 = trunc nuw i8 %37 to i1
  br i1 %38, label %39, label %78

39:                                               ; preds = %36
  %40 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 13), align 1, !tbaa !5, !range !9, !noundef !10
  %41 = trunc nuw i8 %40 to i1
  br i1 %41, label %42, label %78

42:                                               ; preds = %39
  %43 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 14), align 2, !tbaa !5, !range !9, !noundef !10
  %44 = trunc nuw i8 %43 to i1
  br i1 %44, label %45, label %78

45:                                               ; preds = %42
  %46 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 15), align 1, !tbaa !5, !range !9, !noundef !10
  %47 = trunc nuw i8 %46 to i1
  br i1 %47, label %48, label %78

48:                                               ; preds = %45
  %49 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 16), align 16, !tbaa !5, !range !9, !noundef !10
  %50 = trunc nuw i8 %49 to i1
  br i1 %50, label %51, label %78

51:                                               ; preds = %48
  %52 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 17), align 1, !tbaa !5, !range !9, !noundef !10
  %53 = trunc nuw i8 %52 to i1
  br i1 %53, label %54, label %78

54:                                               ; preds = %51
  %55 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 18), align 2, !tbaa !5, !range !9, !noundef !10
  %56 = trunc nuw i8 %55 to i1
  br i1 %56, label %57, label %78

57:                                               ; preds = %54
  %58 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 19), align 1, !tbaa !5, !range !9, !noundef !10
  %59 = trunc nuw i8 %58 to i1
  br i1 %59, label %60, label %78

60:                                               ; preds = %57
  %61 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 20), align 4, !tbaa !5, !range !9, !noundef !10
  %62 = trunc nuw i8 %61 to i1
  br i1 %62, label %63, label %78

63:                                               ; preds = %60
  %64 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 21), align 1, !tbaa !5, !range !9, !noundef !10
  %65 = trunc nuw i8 %64 to i1
  br i1 %65, label %66, label %78

66:                                               ; preds = %63
  %67 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 22), align 2, !tbaa !5, !range !9, !noundef !10
  %68 = trunc nuw i8 %67 to i1
  br i1 %68, label %69, label %78

69:                                               ; preds = %66
  %70 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 23), align 1, !tbaa !5, !range !9, !noundef !10
  %71 = trunc nuw i8 %70 to i1
  br i1 %71, label %72, label %78

72:                                               ; preds = %69
  %73 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 24), align 8, !tbaa !5, !range !9, !noundef !10
  %74 = trunc nuw i8 %73 to i1
  br i1 %74, label %75, label %78

75:                                               ; preds = %72
  %76 = load i8, ptr getelementptr inbounds (i8, ptr @flag, i64 25), align 1, !tbaa !5, !range !9, !noundef !10
  %77 = trunc nuw i8 %76 to i1
  br label %78

78:                                               ; preds = %75, %72, %69, %66, %63, %60, %57, %54, %51, %48, %45, %42, %39, %36, %33, %30, %27, %24, %21, %18, %15, %12, %9, %6, %3, %0
  %.lcssa = phi i1 [ false, %0 ], [ false, %3 ], [ false, %6 ], [ false, %9 ], [ false, %12 ], [ false, %15 ], [ false, %18 ], [ false, %21 ], [ false, %24 ], [ false, %27 ], [ false, %30 ], [ false, %33 ], [ false, %36 ], [ false, %39 ], [ false, %42 ], [ false, %45 ], [ false, %48 ], [ false, %51 ], [ false, %54 ], [ false, %57 ], [ false, %60 ], [ false, %63 ], [ false, %66 ], [ false, %69 ], [ false, %72 ], [ %77, %75 ]
  ret i1 %.lcssa
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, 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" }

!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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass