; LLVM IR from HarshCasper/NeoAlgo :: C/cryptography (Hill_Cipher)

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

@get_ciphertext_matrix.encrypted = external hidden global [100 x i8], align 16

; Function Attrs: nounwind uwtable
declare dso_local void @get_key_matrix(ptr noundef, ptr noundef) #0

; 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

; Function Attrs: nounwind uwtable
declare dso_local void @get_plaintext_matrix(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @get_ciphertext_matrix(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [3 x [3 x i32]], align 16
  %8 = alloca [3 x [1 x i32]], align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 36, ptr %7) #2
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds [3 x [3 x i32]], ptr %7, i64 0, i64 0
  call void @get_key_matrix(ptr noundef %20, ptr noundef %21)
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds [3 x [1 x i32]], ptr %8, i64 0, i64 0
  call void @get_plaintext_matrix(ptr noundef %22, ptr noundef %23)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %45, %3
  %25 = load i32, ptr %9, align 4, !tbaa !9
  %26 = icmp slt i32 %25, 3
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  br label %48

28:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %41, %28
  %30 = load i32, ptr %11, align 4, !tbaa !9
  %31 = icmp slt i32 %30, 1
  br i1 %31, label %33, label %32

32:                                               ; preds = %29
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  br label %44

33:                                               ; preds = %29
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load i32, ptr %9, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [1 x i32], ptr %34, i64 %36
  %38 = load i32, ptr %11, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1 x i32], ptr %37, i64 0, i64 %39
  store i32 0, ptr %40, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %33
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %11, align 4, !tbaa !9
  br label %29, !llvm.loop !11

44:                                               ; preds = %32
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %9, align 4, !tbaa !9
  br label %24, !llvm.loop !13

48:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %96, %48
  %50 = load i32, ptr %12, align 4, !tbaa !9
  %51 = icmp slt i32 %50, 3
  br i1 %51, label %53, label %52

52:                                               ; preds = %49
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  br label %99

53:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %92, %53
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = icmp slt i32 %55, 1
  br i1 %56, label %58, label %57

57:                                               ; preds = %54
  store i32 11, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  br label %95

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

59:                                               ; preds = %88, %58
  %60 = load i32, ptr %14, align 4, !tbaa !9
  %61 = icmp slt i32 %60, 3
  br i1 %61, label %63, label %62

62:                                               ; preds = %59
  store i32 14, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  br label %91

63:                                               ; preds = %59
  %64 = load i32, ptr %12, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [3 x [3 x i32]], ptr %7, i64 0, i64 %65
  %67 = load i32, ptr %14, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [3 x i32], ptr %66, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !9
  %71 = load i32, ptr %14, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [3 x [1 x i32]], ptr %8, i64 0, i64 %72
  %74 = load i32, ptr %13, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1 x i32], ptr %73, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !9
  %78 = mul nsw i32 %70, %77
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = load i32, ptr %12, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [1 x i32], ptr %79, i64 %81
  %83 = load i32, ptr %13, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [1 x i32], ptr %82, i64 0, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !9
  %87 = add nsw i32 %86, %78
  store i32 %87, ptr %85, align 4, !tbaa !9
  br label %88

88:                                               ; preds = %63
  %89 = load i32, ptr %14, align 4, !tbaa !9
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %14, align 4, !tbaa !9
  br label %59, !llvm.loop !14

91:                                               ; preds = %62
  br label %92

92:                                               ; preds = %91
  %93 = load i32, ptr %13, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %13, align 4, !tbaa !9
  br label %54, !llvm.loop !15

95:                                               ; preds = %57
  br label %96

96:                                               ; preds = %95
  %97 = load i32, ptr %12, align 4, !tbaa !9
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %12, align 4, !tbaa !9
  br label %49, !llvm.loop !16

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

100:                                              ; preds = %130, %99
  %101 = load i32, ptr %15, align 4, !tbaa !9
  %102 = icmp slt i32 %101, 3
  br i1 %102, label %104, label %103

103:                                              ; preds = %100
  store i32 17, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  br label %133

104:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %105

105:                                              ; preds = %126, %104
  %106 = load i32, ptr %16, align 4, !tbaa !9
  %107 = icmp slt i32 %106, 1
  br i1 %107, label %109, label %108

108:                                              ; preds = %105
  store i32 20, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  br label %129

109:                                              ; preds = %105
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = load i32, ptr %15, align 4, !tbaa !9
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [1 x i32], ptr %110, i64 %112
  %114 = load i32, ptr %16, align 4, !tbaa !9
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [1 x i32], ptr %113, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !9
  %118 = srem i32 %117, 26
  %119 = load ptr, ptr %6, align 8, !tbaa !5
  %120 = load i32, ptr %15, align 4, !tbaa !9
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [1 x i32], ptr %119, i64 %121
  %123 = load i32, ptr %16, align 4, !tbaa !9
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [1 x i32], ptr %122, i64 0, i64 %124
  store i32 %118, ptr %125, align 4, !tbaa !9
  br label %126

126:                                              ; preds = %109
  %127 = load i32, ptr %16, align 4, !tbaa !9
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr %16, align 4, !tbaa !9
  br label %105, !llvm.loop !17

129:                                              ; preds = %108
  br label %130

130:                                              ; preds = %129
  %131 = load i32, ptr %15, align 4, !tbaa !9
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %15, align 4, !tbaa !9
  br label %100, !llvm.loop !18

133:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #2
  store i32 0, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #2
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %134

134:                                              ; preds = %162, %133
  %135 = load i32, ptr %18, align 4, !tbaa !9
  %136 = icmp slt i32 %135, 3
  br i1 %136, label %138, label %137

137:                                              ; preds = %134
  store i32 23, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #2
  br label %165

138:                                              ; preds = %134
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #2
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %139

139:                                              ; preds = %158, %138
  %140 = load i32, ptr %19, align 4, !tbaa !9
  %141 = icmp slt i32 %140, 1
  br i1 %141, label %143, label %142

142:                                              ; preds = %139
  store i32 26, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #2
  br label %161

143:                                              ; preds = %139
  %144 = load ptr, ptr %6, align 8, !tbaa !5
  %145 = load i32, ptr %18, align 4, !tbaa !9
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [1 x i32], ptr %144, i64 %146
  %148 = load i32, ptr %19, align 4, !tbaa !9
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [1 x i32], ptr %147, i64 0, i64 %149
  %151 = load i32, ptr %150, align 4, !tbaa !9
  %152 = add nsw i32 %151, 97
  %153 = trunc i32 %152 to i8
  %154 = load i32, ptr %17, align 4, !tbaa !9
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %17, align 4, !tbaa !9
  %156 = sext i32 %154 to i64
  %157 = getelementptr inbounds [100 x i8], ptr @get_ciphertext_matrix.encrypted, i64 0, i64 %156
  store i8 %153, ptr %157, align 1, !tbaa !19
  br label %158

158:                                              ; preds = %143
  %159 = load i32, ptr %19, align 4, !tbaa !9
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %19, align 4, !tbaa !9
  br label %139, !llvm.loop !20

161:                                              ; preds = %142
  br label %162

162:                                              ; preds = %161
  %163 = load i32, ptr %18, align 4, !tbaa !9
  %164 = add nsw i32 %163, 1
  store i32 %164, ptr %18, align 4, !tbaa !9
  br label %134, !llvm.loop !21

165:                                              ; preds = %137
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #2
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 36, ptr %7) #2
  ret ptr @get_ciphertext_matrix.encrypted
}

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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}


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

@get_ciphertext_matrix.encrypted = external hidden global [100 x i8], align 16

; Function Attrs: nounwind uwtable
declare dso_local void @get_key_matrix(ptr noundef, ptr noundef) local_unnamed_addr #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local void @get_plaintext_matrix(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef nonnull ptr @get_ciphertext_matrix(ptr noundef %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
.preheader54.preheader:
  %3 = alloca [3 x [3 x i32]], align 16
  %4 = alloca [3 x [1 x i32]], align 4
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %3) #2
  call void @get_key_matrix(ptr noundef %1, ptr noundef nonnull %3)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #2
  call void @get_plaintext_matrix(ptr noundef %0, ptr noundef nonnull %4)
  %5 = load i32, ptr %3, align 16, !tbaa !5
  %6 = load i32, ptr %4, align 4, !tbaa !5
  %7 = mul nsw i32 %6, %5
  %8 = getelementptr inbounds i8, ptr %3, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %4, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = mul nsw i32 %11, %9
  %13 = add nsw i32 %7, %12
  %14 = getelementptr inbounds i8, ptr %3, i64 8
  %15 = load i32, ptr %14, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %4, i64 8
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = mul nsw i32 %17, %15
  %19 = add nsw i32 %13, %18
  %20 = getelementptr inbounds i8, ptr %2, i64 4
  %21 = getelementptr inbounds i8, ptr %3, i64 12
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = mul nsw i32 %6, %22
  %24 = getelementptr inbounds i8, ptr %3, i64 16
  %25 = load i32, ptr %24, align 16, !tbaa !5
  %26 = mul nsw i32 %11, %25
  %27 = add nsw i32 %23, %26
  %28 = getelementptr inbounds i8, ptr %3, i64 20
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = mul nsw i32 %17, %29
  %31 = add nsw i32 %27, %30
  %32 = getelementptr inbounds i8, ptr %2, i64 8
  %33 = getelementptr inbounds i8, ptr %3, i64 24
  %34 = load i32, ptr %33, align 8, !tbaa !5
  %35 = mul nsw i32 %6, %34
  %36 = getelementptr inbounds i8, ptr %3, i64 28
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = mul nsw i32 %11, %37
  %39 = add nsw i32 %35, %38
  %40 = getelementptr inbounds i8, ptr %3, i64 32
  %41 = load i32, ptr %40, align 16, !tbaa !5
  %42 = mul nsw i32 %17, %41
  %43 = add nsw i32 %39, %42
  %44 = srem i32 %19, 26
  store i32 %44, ptr %2, align 4, !tbaa !5
  %45 = srem i32 %31, 26
  store i32 %45, ptr %20, align 4, !tbaa !5
  %46 = srem i32 %43, 26
  store i32 %46, ptr %32, align 4, !tbaa !5
  %47 = trunc nsw i32 %44 to i8
  %48 = add nsw i8 %47, 97
  store i8 %48, ptr @get_ciphertext_matrix.encrypted, align 16, !tbaa !9
  %49 = trunc nsw i32 %45 to i8
  %50 = add nsw i8 %49, 97
  store i8 %50, ptr getelementptr inbounds (i8, ptr @get_ciphertext_matrix.encrypted, i64 1), align 1, !tbaa !9
  %51 = trunc nsw i32 %46 to i8
  %52 = add nsw i8 %51, 97
  store i8 %52, ptr getelementptr inbounds (i8, ptr @get_ciphertext_matrix.encrypted, i64 2), align 2, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #2
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %3) #2
  ret ptr @get_ciphertext_matrix.encrypted
}

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 = { mustprogress 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}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass