; LLVM IR from div-bargali/Data-Structures-and-Algorithms :: C/Data-Structures/Arrays (addition_2x2_matrix)

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

@.str = external hidden unnamed_addr constant [42 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1

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

9:                                                ; preds = %30, %0
  %10 = load i32, ptr %5, align 4, !tbaa !5
  %11 = icmp sle i32 %10, 1
  br i1 %11, label %12, label %33

12:                                               ; preds = %9
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %26, %12
  %14 = load i32, ptr %6, align 4, !tbaa !5
  %15 = icmp sle i32 %14, 1
  br i1 %15, label %16, label %29

16:                                               ; preds = %13
  %17 = getelementptr inbounds [2 x [2 x i32]], ptr %2, i64 0, i64 0
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [2 x i32], ptr %17, i64 %19
  %21 = getelementptr inbounds [2 x i32], ptr %20, i64 0, i64 0
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds i32, ptr %21, i64 %23
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %24)
  br label %26

26:                                               ; preds = %16
  %27 = load i32, ptr %6, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %6, align 4, !tbaa !5
  br label %13, !llvm.loop !9

29:                                               ; preds = %13
  br label %30

30:                                               ; preds = %29
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %5, align 4, !tbaa !5
  br label %9, !llvm.loop !11

33:                                               ; preds = %9
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %56, %33
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = icmp sle i32 %36, 1
  br i1 %37, label %38, label %59

38:                                               ; preds = %35
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %52, %38
  %40 = load i32, ptr %6, align 4, !tbaa !5
  %41 = icmp sle i32 %40, 1
  br i1 %41, label %42, label %55

42:                                               ; preds = %39
  %43 = getelementptr inbounds [2 x [2 x i32]], ptr %3, i64 0, i64 0
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [2 x i32], ptr %43, i64 %45
  %47 = getelementptr inbounds [2 x i32], ptr %46, i64 0, i64 0
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i32, ptr %47, i64 %49
  %51 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %50)
  br label %52

52:                                               ; preds = %42
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %6, align 4, !tbaa !5
  br label %39, !llvm.loop !12

55:                                               ; preds = %39
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %5, align 4, !tbaa !5
  br label %35, !llvm.loop !13

59:                                               ; preds = %35
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %99, %59
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = icmp sle i32 %61, 1
  br i1 %62, label %63, label %102

63:                                               ; preds = %60
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %95, %63
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = icmp sle i32 %65, 1
  br i1 %66, label %67, label %98

67:                                               ; preds = %64
  %68 = getelementptr inbounds [2 x [2 x i32]], ptr %2, i64 0, i64 0
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [2 x i32], ptr %68, i64 %70
  %72 = getelementptr inbounds [2 x i32], ptr %71, i64 0, i64 0
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds i32, ptr %72, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = getelementptr inbounds [2 x [2 x i32]], ptr %3, i64 0, i64 0
  %78 = load i32, ptr %5, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [2 x i32], ptr %77, i64 %79
  %81 = getelementptr inbounds [2 x i32], ptr %80, i64 0, i64 0
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds i32, ptr %81, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = add nsw i32 %76, %85
  %87 = getelementptr inbounds [2 x [2 x i32]], ptr %4, i64 0, i64 0
  %88 = load i32, ptr %5, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [2 x i32], ptr %87, i64 %89
  %91 = getelementptr inbounds [2 x i32], ptr %90, i64 0, i64 0
  %92 = load i32, ptr %6, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds i32, ptr %91, i64 %93
  store i32 %86, ptr %94, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %67
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %6, align 4, !tbaa !5
  br label %64, !llvm.loop !14

98:                                               ; preds = %64
  br label %99

99:                                               ; preds = %98
  %100 = load i32, ptr %5, align 4, !tbaa !5
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %5, align 4, !tbaa !5
  br label %60, !llvm.loop !15

102:                                              ; preds = %60
  %103 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %131, %102
  %105 = load i32, ptr %5, align 4, !tbaa !5
  %106 = icmp sle i32 %105, 1
  br i1 %106, label %107, label %134

107:                                              ; preds = %104
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %108

108:                                              ; preds = %127, %107
  %109 = load i32, ptr %6, align 4, !tbaa !5
  %110 = icmp sle i32 %109, 1
  br i1 %110, label %111, label %130

111:                                              ; preds = %108
  %112 = getelementptr inbounds [2 x [2 x i32]], ptr %4, i64 0, i64 0
  %113 = load i32, ptr %5, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [2 x i32], ptr %112, i64 %114
  %116 = getelementptr inbounds [2 x i32], ptr %115, i64 0, i64 0
  %117 = load i32, ptr %6, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds i32, ptr %116, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %120)
  %122 = load i32, ptr %6, align 4, !tbaa !5
  %123 = icmp eq i32 %122, 1
  br i1 %123, label %124, label %126

124:                                              ; preds = %111
  %125 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  br label %126

126:                                              ; preds = %124, %111
  br label %127

127:                                              ; preds = %126
  %128 = load i32, ptr %6, align 4, !tbaa !5
  %129 = add nsw i32 %128, 1
  store i32 %129, ptr %6, align 4, !tbaa !5
  br label %108, !llvm.loop !16

130:                                              ; preds = %108
  br label %131

131:                                              ; preds = %130
  %132 = load i32, ptr %5, align 4, !tbaa !5
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr %5, align 4, !tbaa !5
  br label %104, !llvm.loop !17

134:                                              ; preds = %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #3
  ret i32 0
}

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

declare i32 @printf(ptr noundef, ...) #2

declare i32 @__isoc99_scanf(ptr noundef, ...) #2

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


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

@.str = external hidden unnamed_addr constant [42 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [2 x [2 x i32]], align 16
  %2 = alloca [2 x [2 x i32]], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #3
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1)
  %6 = getelementptr inbounds i8, ptr %1, i64 4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %6)
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %8)
  %10 = getelementptr inbounds i8, ptr %1, i64 12
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %10)
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %2)
  %14 = getelementptr inbounds i8, ptr %2, i64 4
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %14)
  %16 = getelementptr inbounds i8, ptr %2, i64 8
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %16)
  %18 = getelementptr inbounds i8, ptr %2, i64 12
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %18)
  %20 = load i32, ptr %1, align 16, !tbaa !5
  %21 = load i32, ptr %2, align 16, !tbaa !5
  %22 = add nsw i32 %21, %20
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = load i32, ptr %14, align 4, !tbaa !5
  %25 = load i32, ptr %8, align 8, !tbaa !5
  %26 = load i32, ptr %16, align 8, !tbaa !5
  %27 = add nsw i32 %26, %25
  %28 = load i32, ptr %10, align 4, !tbaa !5
  %29 = load i32, ptr %18, align 4, !tbaa !5
  %30 = add nsw i32 %29, %28
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %22)
  %33 = add nsw i32 %24, %23
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %33)
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %27)
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %30)
  %38 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #3
  ret i32 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

attributes #0 = { nofree 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 = { nofree nounwind "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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