; LLVM IR from MinhasKamal/AlgorithmImplementations :: playWithNumbers/pascalTriangle (EasyPascalTriangle)

; 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 [27 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = 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 [50 x [50 x i32]], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 10000, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %6 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3)
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %61, %0
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = icmp sle i32 %9, %10
  br i1 %11, label %12, label %64

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

13:                                               ; preds = %57, %12
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %17, label %60

17:                                               ; preds = %13
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %24, label %20

20:                                               ; preds = %17
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = icmp eq i32 %21, %22
  br i1 %23, label %24, label %31

24:                                               ; preds = %20, %17
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [50 x [50 x i32]], ptr %2, i64 0, i64 %26
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [50 x i32], ptr %27, i64 0, i64 %29
  store i32 1, ptr %30, align 4, !tbaa !5
  br label %56

31:                                               ; preds = %20
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = sub nsw i32 %32, 1
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [50 x [50 x i32]], ptr %2, i64 0, i64 %34
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [50 x i32], ptr %35, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = sub nsw i32 %40, 1
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [50 x [50 x i32]], ptr %2, i64 0, i64 %42
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = sub nsw i32 %44, 1
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [50 x i32], ptr %43, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = add nsw i32 %39, %48
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [50 x [50 x i32]], ptr %2, i64 0, i64 %51
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [50 x i32], ptr %52, i64 0, i64 %54
  store i32 %49, ptr %55, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %31, %24
  br label %57

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

60:                                               ; preds = %13
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %4, align 4, !tbaa !5
  br label %8, !llvm.loop !11

64:                                               ; preds = %8
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %100, %64
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = load i32, ptr %3, align 4, !tbaa !5
  %68 = icmp sle i32 %66, %67
  br i1 %68, label %69, label %103

69:                                               ; preds = %65
  %70 = load i32, ptr %3, align 4, !tbaa !5
  %71 = load i32, ptr %4, align 4, !tbaa !5
  %72 = sub nsw i32 %70, %71
  store i32 %72, ptr %5, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %78, %69
  %74 = load i32, ptr %5, align 4, !tbaa !5
  %75 = icmp sgt i32 %74, 0
  br i1 %75, label %76, label %81

76:                                               ; preds = %73
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %78

78:                                               ; preds = %76
  %79 = load i32, ptr %5, align 4, !tbaa !5
  %80 = add nsw i32 %79, -1
  store i32 %80, ptr %5, align 4, !tbaa !5
  br label %73, !llvm.loop !12

81:                                               ; preds = %73
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %95, %81
  %83 = load i32, ptr %5, align 4, !tbaa !5
  %84 = load i32, ptr %4, align 4, !tbaa !5
  %85 = icmp slt i32 %83, %84
  br i1 %85, label %86, label %98

86:                                               ; preds = %82
  %87 = load i32, ptr %4, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [50 x [50 x i32]], ptr %2, i64 0, i64 %88
  %90 = load i32, ptr %5, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [50 x i32], ptr %89, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %93)
  br label %95

95:                                               ; preds = %86
  %96 = load i32, ptr %5, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %5, align 4, !tbaa !5
  br label %82, !llvm.loop !13

98:                                               ; preds = %82
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %100

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

103:                                              ; preds = %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 10000, 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}


; 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 [27 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = 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 [50 x [50 x i32]], align 16
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 10000, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2)
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %.not33 = icmp slt i32 %5, 0
  br i1 %.not33, label %._crit_edge44, label %.preheader31.preheader

.preheader31.preheader:                           ; preds = %0
  %6 = add nuw i32 %5, 1
  %wide.trip.count51 = zext i32 %6 to i64
  br label %.preheader31

.preheader31:                                     ; preds = %.preheader31.preheader, %._crit_edge
  %indvars.iv48 = phi i64 [ 0, %.preheader31.preheader ], [ %indvars.iv.next49, %._crit_edge ]
  %7 = add nsw i64 %indvars.iv48, -1
  %.not45 = icmp eq i64 %indvars.iv48, 0
  br i1 %.not45, label %._crit_edge, label %8

8:                                                ; preds = %.preheader31
  %9 = add nsw i64 %indvars.iv48, -1
  %10 = getelementptr inbounds [50 x [50 x i32]], ptr %1, i64 0, i64 %indvars.iv48, i64 0
  store i32 1, ptr %10, align 8
  %exitcond.peel.not = icmp eq i64 %indvars.iv48, 1
  br i1 %exitcond.peel.not, label %._crit_edge, label %.peel.next.preheader

.peel.next.preheader:                             ; preds = %8
  %xtraiter = and i64 %7, 1
  %11 = icmp eq i64 %indvars.iv48, 2
  br i1 %11, label %._crit_edge.loopexit.unr-lcssa, label %.peel.next.preheader.new

.peel.next.preheader.new:                         ; preds = %.peel.next.preheader
  %unroll_iter = and i64 %7, -2
  br label %.peel.next

.preheader30:                                     ; preds = %._crit_edge
  br i1 %.not33, label %._crit_edge44, label %.lr.ph43

.peel.next:                                       ; preds = %.peel.next, %.peel.next.preheader.new
  %indvars.iv = phi i64 [ 1, %.peel.next.preheader.new ], [ %indvars.iv.next.1, %.peel.next ]
  %niter = phi i64 [ 0, %.peel.next.preheader.new ], [ %niter.next.1, %.peel.next ]
  %12 = add nsw i64 %indvars.iv, -1
  %13 = getelementptr inbounds [50 x [50 x i32]], ptr %1, i64 0, i64 %9, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = getelementptr inbounds [50 x [50 x i32]], ptr %1, i64 0, i64 %9, i64 %indvars.iv
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = add nsw i32 %14, %16
  %18 = getelementptr inbounds [50 x [50 x i32]], ptr %1, i64 0, i64 %indvars.iv48, i64 %indvars.iv
  store i32 %17, ptr %18, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = getelementptr inbounds [50 x [50 x i32]], ptr %1, i64 0, i64 %9, i64 %indvars.iv.next
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = add nsw i32 %16, %20
  %22 = getelementptr inbounds [50 x [50 x i32]], ptr %1, i64 0, i64 %indvars.iv48, i64 %indvars.iv.next
  store i32 %21, ptr %22, align 4
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.peel.next, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.peel.next, %.peel.next.preheader
  %indvars.iv.unr = phi i64 [ 1, %.peel.next.preheader ], [ %indvars.iv.next.1, %.peel.next ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.peel.next.epil

.peel.next.epil:                                  ; preds = %._crit_edge.loopexit.unr-lcssa
  %23 = add nsw i64 %indvars.iv.unr, -1
  %24 = getelementptr inbounds [50 x [50 x i32]], ptr %1, i64 0, i64 %9, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = getelementptr inbounds [50 x [50 x i32]], ptr %1, i64 0, i64 %9, i64 %indvars.iv.unr
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = add nsw i32 %25, %27
  %29 = getelementptr inbounds [50 x [50 x i32]], ptr %1, i64 0, i64 %indvars.iv48, i64 %indvars.iv.unr
  store i32 %28, ptr %29, align 4
  br label %._crit_edge

._crit_edge:                                      ; preds = %.peel.next.epil, %._crit_edge.loopexit.unr-lcssa, %8, %.preheader31
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %exitcond52.not = icmp eq i64 %indvars.iv.next49, %wide.trip.count51
  br i1 %exitcond52.not, label %.preheader30, label %.preheader31, !llvm.loop !12

.lr.ph43:                                         ; preds = %.preheader30, %._crit_edge40
  %indvars.iv57 = phi i64 [ %indvars.iv.next58, %._crit_edge40 ], [ 0, %.preheader30 ]
  %30 = phi i32 [ %41, %._crit_edge40 ], [ %5, %.preheader30 ]
  %31 = trunc nuw nsw i64 %indvars.iv57 to i32
  %32 = sub nsw i32 %30, %31
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %.lr.ph37, label %.preheader

.preheader:                                       ; preds = %.lr.ph37, %.lr.ph43
  %.not = icmp eq i64 %indvars.iv57, 0
  br i1 %.not, label %._crit_edge40, label %.lr.ph39

.lr.ph37:                                         ; preds = %.lr.ph43, %.lr.ph37
  %.135 = phi i32 [ %35, %.lr.ph37 ], [ %32, %.lr.ph43 ]
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %35 = add nsw i32 %.135, -1
  %36 = icmp ugt i32 %.135, 1
  br i1 %36, label %.lr.ph37, label %.preheader, !llvm.loop !13

.lr.ph39:                                         ; preds = %.preheader, %.lr.ph39
  %indvars.iv53 = phi i64 [ %indvars.iv.next54, %.lr.ph39 ], [ 0, %.preheader ]
  %37 = getelementptr inbounds [50 x [50 x i32]], ptr %1, i64 0, i64 %indvars.iv57, i64 %indvars.iv53
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %38)
  %indvars.iv.next54 = add nuw nsw i64 %indvars.iv53, 1
  %exitcond56.not = icmp eq i64 %indvars.iv.next54, %indvars.iv57
  br i1 %exitcond56.not, label %._crit_edge40, label %.lr.ph39, !llvm.loop !14

._crit_edge40:                                    ; preds = %.lr.ph39, %.preheader
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %indvars.iv.next58 = add nuw nsw i64 %indvars.iv57, 1
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %.not29.not = icmp slt i64 %indvars.iv57, %42
  br i1 %.not29.not, label %.lr.ph43, label %._crit_edge44, !llvm.loop !15

._crit_edge44:                                    ; preds = %._crit_edge40, %0, %.preheader30
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 10000, 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"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.peeled.count", i32 1}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}


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