; LLVM IR from JessonYue/LeetCodeLearning :: Array/caiweixiong/c (homework_base64)

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

@base64Alphabet = external dso_local global [128 x i8], align 16
@lookUpBase64Alphabet = external dso_local global [64 x i8], align 16

; Function Attrs: nounwind uwtable
define dso_local void @initSymbolTable() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %18, %0
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 128
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  br label %21

14:                                               ; preds = %10
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [128 x i8], ptr @base64Alphabet, i64 0, i64 %16
  store i8 -1, ptr %17, align 1, !tbaa !9
  br label %18

18:                                               ; preds = %14
  %19 = load i32, ptr %1, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %1, align 4, !tbaa !5
  br label %10, !llvm.loop !10

21:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  store i32 90, ptr %2, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %33, %21
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = icmp sge i32 %23, 65
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  br label %36

26:                                               ; preds = %22
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sub nsw i32 %27, 65
  %29 = trunc i32 %28 to i8
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [128 x i8], ptr @base64Alphabet, i64 0, i64 %31
  store i8 %29, ptr %32, align 1, !tbaa !9
  br label %33

33:                                               ; preds = %26
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr %2, align 4, !tbaa !5
  br label %22, !llvm.loop !12

36:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 122, ptr %3, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %49, %36
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = icmp sge i32 %38, 97
  br i1 %39, label %41, label %40

40:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %52

41:                                               ; preds = %37
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = sub nsw i32 %42, 97
  %44 = add nsw i32 %43, 26
  %45 = trunc i32 %44 to i8
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [128 x i8], ptr @base64Alphabet, i64 0, i64 %47
  store i8 %45, ptr %48, align 1, !tbaa !9
  br label %49

49:                                               ; preds = %41
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = add nsw i32 %50, -1
  store i32 %51, ptr %3, align 4, !tbaa !5
  br label %37, !llvm.loop !13

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

53:                                               ; preds = %65, %52
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = icmp sge i32 %54, 48
  br i1 %55, label %57, label %56

56:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %68

57:                                               ; preds = %53
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = sub nsw i32 %58, 48
  %60 = add nsw i32 %59, 52
  %61 = trunc i32 %60 to i8
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [128 x i8], ptr @base64Alphabet, i64 0, i64 %63
  store i8 %61, ptr %64, align 1, !tbaa !9
  br label %65

65:                                               ; preds = %57
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = add nsw i32 %66, -1
  store i32 %67, ptr %4, align 4, !tbaa !5
  br label %53, !llvm.loop !14

68:                                               ; preds = %56
  store i8 62, ptr getelementptr inbounds ([128 x i8], ptr @base64Alphabet, i64 0, i64 43), align 1, !tbaa !9
  store i8 63, ptr getelementptr inbounds ([128 x i8], ptr @base64Alphabet, i64 0, i64 47), align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %80, %68
  %70 = load i32, ptr %5, align 4, !tbaa !5
  %71 = icmp sle i32 %70, 25
  br i1 %71, label %73, label %72

72:                                               ; preds = %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %83

73:                                               ; preds = %69
  %74 = load i32, ptr %5, align 4, !tbaa !5
  %75 = add nsw i32 65, %74
  %76 = trunc i32 %75 to i8
  %77 = load i32, ptr %5, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [64 x i8], ptr @lookUpBase64Alphabet, i64 0, i64 %78
  store i8 %76, ptr %79, align 1, !tbaa !9
  br label %80

80:                                               ; preds = %73
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %5, align 4, !tbaa !5
  br label %69, !llvm.loop !15

83:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 26, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %95, %83
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = icmp sle i32 %85, 51
  br i1 %86, label %88, label %87

87:                                               ; preds = %84
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %100

88:                                               ; preds = %84
  %89 = load i32, ptr %7, align 4, !tbaa !5
  %90 = add nsw i32 97, %89
  %91 = trunc i32 %90 to i8
  %92 = load i32, ptr %6, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [64 x i8], ptr @lookUpBase64Alphabet, i64 0, i64 %93
  store i8 %91, ptr %94, align 1, !tbaa !9
  br label %95

95:                                               ; preds = %88
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %6, align 4, !tbaa !5
  %98 = load i32, ptr %7, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %7, align 4, !tbaa !5
  br label %84, !llvm.loop !16

100:                                              ; preds = %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 52, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %112, %100
  %102 = load i32, ptr %8, align 4, !tbaa !5
  %103 = icmp sle i32 %102, 61
  br i1 %103, label %105, label %104

104:                                              ; preds = %101
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %117

105:                                              ; preds = %101
  %106 = load i32, ptr %9, align 4, !tbaa !5
  %107 = add nsw i32 48, %106
  %108 = trunc i32 %107 to i8
  %109 = load i32, ptr %8, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [64 x i8], ptr @lookUpBase64Alphabet, i64 0, i64 %110
  store i8 %108, ptr %111, align 1, !tbaa !9
  br label %112

112:                                              ; preds = %105
  %113 = load i32, ptr %8, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %8, align 4, !tbaa !5
  %115 = load i32, ptr %9, align 4, !tbaa !5
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %9, align 4, !tbaa !5
  br label %101, !llvm.loop !17

117:                                              ; preds = %104
  store i8 43, ptr getelementptr inbounds ([64 x i8], ptr @lookUpBase64Alphabet, i64 0, i64 62), align 2, !tbaa !9
  store i8 47, ptr getelementptr inbounds ([64 x i8], ptr @lookUpBase64Alphabet, i64 0, i64 63), align 1, !tbaa !9
  ret void
}

; 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 = { 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/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11}
!16 = distinct !{!16, !11}
!17 = distinct !{!17, !11}


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

@base64Alphabet = external dso_local local_unnamed_addr global [128 x i8], align 16
@lookUpBase64Alphabet = external dso_local local_unnamed_addr global [64 x i8], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @initSymbolTable() local_unnamed_addr #0 {
.preheader40.preheader:
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(128) @base64Alphabet, i8 -1, i64 128, i1 false), !tbaa !5
  store i8 25, ptr getelementptr inbounds (i8, ptr @base64Alphabet, i64 90), align 2, !tbaa !5
  store i8 24, ptr getelementptr inbounds (i8, ptr @base64Alphabet, i64 89), align 1, !tbaa !5
  store <8 x i8> <i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23>, ptr getelementptr inbounds (i8, ptr @base64Alphabet, i64 81), align 1, !tbaa !5
  store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, ptr getelementptr inbounds (i8, ptr @base64Alphabet, i64 65), align 1, !tbaa !5
  store i8 51, ptr getelementptr inbounds (i8, ptr @base64Alphabet, i64 122), align 2, !tbaa !5
  store i8 50, ptr getelementptr inbounds (i8, ptr @base64Alphabet, i64 121), align 1, !tbaa !5
  store <8 x i8> <i8 42, i8 43, i8 44, i8 45, i8 46, i8 47, i8 48, i8 49>, ptr getelementptr inbounds (i8, ptr @base64Alphabet, i64 113), align 1, !tbaa !5
  store <16 x i8> <i8 26, i8 27, i8 28, i8 29, i8 30, i8 31, i8 32, i8 33, i8 34, i8 35, i8 36, i8 37, i8 38, i8 39, i8 40, i8 41>, ptr getelementptr inbounds (i8, ptr @base64Alphabet, i64 97), align 1, !tbaa !5
  store i8 61, ptr getelementptr inbounds (i8, ptr @base64Alphabet, i64 57), align 1, !tbaa !5
  store i8 60, ptr getelementptr inbounds (i8, ptr @base64Alphabet, i64 56), align 8, !tbaa !5
  store i8 59, ptr getelementptr inbounds (i8, ptr @base64Alphabet, i64 55), align 1, !tbaa !5
  store i8 62, ptr getelementptr inbounds (i8, ptr @base64Alphabet, i64 43), align 1, !tbaa !5
  store <8 x i8> <i8 63, i8 52, i8 53, i8 54, i8 55, i8 56, i8 57, i8 58>, ptr getelementptr inbounds (i8, ptr @base64Alphabet, i64 47), align 1, !tbaa !5
  store <16 x i8> <i8 65, i8 66, i8 67, i8 68, i8 69, i8 70, i8 71, i8 72, i8 73, i8 74, i8 75, i8 76, i8 77, i8 78, i8 79, i8 80>, ptr @lookUpBase64Alphabet, align 16, !tbaa !5
  store <16 x i8> <i8 81, i8 82, i8 83, i8 84, i8 85, i8 86, i8 87, i8 88, i8 89, i8 90, i8 97, i8 98, i8 99, i8 100, i8 101, i8 102>, ptr getelementptr inbounds (i8, ptr @lookUpBase64Alphabet, i64 16), align 16, !tbaa !5
  store <16 x i8> <i8 103, i8 104, i8 105, i8 106, i8 107, i8 108, i8 109, i8 110, i8 111, i8 112, i8 113, i8 114, i8 115, i8 116, i8 117, i8 118>, ptr getelementptr inbounds (i8, ptr @lookUpBase64Alphabet, i64 32), align 16, !tbaa !5
  store <16 x i8> <i8 119, i8 120, i8 121, i8 122, i8 48, i8 49, i8 50, i8 51, i8 52, i8 53, i8 54, i8 55, i8 56, i8 57, i8 43, i8 47>, ptr getelementptr inbounds (i8, ptr @lookUpBase64Alphabet, i64 48), align 16, !tbaa !5
  ret void
}

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

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

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


; Effective O3 passes: AggressiveInstCombinePass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass