; LLVM IR from tastangh/TI-RSLK-Texas-Instruments-Robotics-System-The-Maze-Edition :: tirslk_maze_1_00_00/Lab04_SoftwareDesign (Lab04_SoftwareDesignmain)

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

@CornerCases = external dso_local constant [18 x i32], align 16
@errors = external dso_local global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local i32 @Classify(i32 noundef, i32 noundef, i32 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: nounwind uwtable
define dso_local void @Program4_2() #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
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr @errors, align 4, !tbaa !5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %56, %0
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 18
  br i1 %11, label %12, label %59

12:                                               ; preds = %9
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [18 x i32], ptr @CornerCases, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  store i32 %16, ptr %6, align 4, !tbaa !5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %52, %12
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 18
  br i1 %19, label %20, label %55

20:                                               ; preds = %17
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [18 x i32], ptr @CornerCases, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  store i32 %24, ptr %8, align 4, !tbaa !5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %48, %20
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = icmp slt i32 %26, 18
  br i1 %27, label %28, label %51

28:                                               ; preds = %25
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [18 x i32], ptr @CornerCases, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  store i32 %32, ptr %7, align 4, !tbaa !5
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = load i32, ptr %7, align 4, !tbaa !5
  %36 = call i32 @Classify(i32 noundef %33, i32 noundef %34, i32 noundef %35)
  store i32 %36, ptr %1, align 4, !tbaa !5
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = load i32, ptr %8, align 4, !tbaa !5
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = call i32 @Solution(i32 noundef %37, i32 noundef %38, i32 noundef %39)
  store i32 %40, ptr %2, align 4, !tbaa !5
  %41 = load i32, ptr %1, align 4, !tbaa !5
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = icmp ne i32 %41, %42
  br i1 %43, label %44, label %47

44:                                               ; preds = %28
  %45 = load i32, ptr @errors, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr @errors, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %44, %28
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %5, align 4, !tbaa !5
  br label %25, !llvm.loop !9

51:                                               ; preds = %25
  br label %52

52:                                               ; preds = %51
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %4, align 4, !tbaa !5
  br label %17, !llvm.loop !11

55:                                               ; preds = %17
  br label %56

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

59:                                               ; preds = %9
  br label %60

60:                                               ; preds = %61, %59
  br label %61

61:                                               ; preds = %60
  br label %60
}

declare i32 @Solution(i32 noundef, i32 noundef, i32 noundef) #2

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}


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

@CornerCases = external dso_local local_unnamed_addr constant [18 x i32], align 16
@errors = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local i32 @Classify(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind uwtable
define dso_local void @Program4_2() local_unnamed_addr #1 {
  store i32 0, ptr @errors, align 4, !tbaa !5
  %.pre.pre = load i32, ptr @CornerCases, align 16, !tbaa !5
  %1 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 4), align 4
  %2 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 8), align 8
  %3 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 12), align 4
  %4 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 16), align 16
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 20), align 4
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 24), align 8
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 28), align 4
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 32), align 16
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 36), align 4
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 40), align 8
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 44), align 4
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 48), align 16
  %13 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 52), align 4
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 56), align 8
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 60), align 4
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 64), align 16
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @CornerCases, i64 68), align 4
  br label %18

18:                                               ; preds = %0, %132
  %indvars.iv24 = phi i64 [ 0, %0 ], [ %indvars.iv.next25, %132 ]
  %19 = getelementptr inbounds [18 x i32], ptr @CornerCases, i64 0, i64 %indvars.iv24
  %20 = load i32, ptr %19, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %18, %131
  %indvars.iv = phi i64 [ 0, %18 ], [ %indvars.iv.next, %131 ]
  %22 = getelementptr inbounds [18 x i32], ptr @CornerCases, i64 0, i64 %indvars.iv
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %.pre.pre)
  %25 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %.pre.pre) #3
  %.not = icmp eq i32 %24, %25
  br i1 %.not, label %29, label %26

26:                                               ; preds = %21
  %27 = load i32, ptr @errors, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr @errors, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %21, %26
  %30 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %1)
  %31 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %1) #3
  %.not.1 = icmp eq i32 %30, %31
  br i1 %.not.1, label %35, label %32

32:                                               ; preds = %29
  %33 = load i32, ptr @errors, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr @errors, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %32, %29
  %36 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %2)
  %37 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %2) #3
  %.not.2 = icmp eq i32 %36, %37
  br i1 %.not.2, label %41, label %38

38:                                               ; preds = %35
  %39 = load i32, ptr @errors, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr @errors, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %38, %35
  %42 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %3)
  %43 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %3) #3
  %.not.3 = icmp eq i32 %42, %43
  br i1 %.not.3, label %47, label %44

44:                                               ; preds = %41
  %45 = load i32, ptr @errors, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr @errors, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %44, %41
  %48 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %4)
  %49 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %4) #3
  %.not.4 = icmp eq i32 %48, %49
  br i1 %.not.4, label %53, label %50

50:                                               ; preds = %47
  %51 = load i32, ptr @errors, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr @errors, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %50, %47
  %54 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %5)
  %55 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %5) #3
  %.not.5 = icmp eq i32 %54, %55
  br i1 %.not.5, label %59, label %56

56:                                               ; preds = %53
  %57 = load i32, ptr @errors, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr @errors, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %56, %53
  %60 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %6)
  %61 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %6) #3
  %.not.6 = icmp eq i32 %60, %61
  br i1 %.not.6, label %65, label %62

62:                                               ; preds = %59
  %63 = load i32, ptr @errors, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr @errors, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %62, %59
  %66 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %7)
  %67 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %7) #3
  %.not.7 = icmp eq i32 %66, %67
  br i1 %.not.7, label %71, label %68

68:                                               ; preds = %65
  %69 = load i32, ptr @errors, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr @errors, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %68, %65
  %72 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %8)
  %73 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %8) #3
  %.not.8 = icmp eq i32 %72, %73
  br i1 %.not.8, label %77, label %74

74:                                               ; preds = %71
  %75 = load i32, ptr @errors, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr @errors, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %74, %71
  %78 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %9)
  %79 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %9) #3
  %.not.9 = icmp eq i32 %78, %79
  br i1 %.not.9, label %83, label %80

80:                                               ; preds = %77
  %81 = load i32, ptr @errors, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr @errors, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %80, %77
  %84 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %10)
  %85 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %10) #3
  %.not.10 = icmp eq i32 %84, %85
  br i1 %.not.10, label %89, label %86

86:                                               ; preds = %83
  %87 = load i32, ptr @errors, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr @errors, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %86, %83
  %90 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %11)
  %91 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %11) #3
  %.not.11 = icmp eq i32 %90, %91
  br i1 %.not.11, label %95, label %92

92:                                               ; preds = %89
  %93 = load i32, ptr @errors, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr @errors, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %92, %89
  %96 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %12)
  %97 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %12) #3
  %.not.12 = icmp eq i32 %96, %97
  br i1 %.not.12, label %101, label %98

98:                                               ; preds = %95
  %99 = load i32, ptr @errors, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr @errors, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %98, %95
  %102 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %13)
  %103 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %13) #3
  %.not.13 = icmp eq i32 %102, %103
  br i1 %.not.13, label %107, label %104

104:                                              ; preds = %101
  %105 = load i32, ptr @errors, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr @errors, align 4, !tbaa !5
  br label %107

107:                                              ; preds = %104, %101
  %108 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %14)
  %109 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %14) #3
  %.not.14 = icmp eq i32 %108, %109
  br i1 %.not.14, label %113, label %110

110:                                              ; preds = %107
  %111 = load i32, ptr @errors, align 4, !tbaa !5
  %112 = add nsw i32 %111, 1
  store i32 %112, ptr @errors, align 4, !tbaa !5
  br label %113

113:                                              ; preds = %110, %107
  %114 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %15)
  %115 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %15) #3
  %.not.15 = icmp eq i32 %114, %115
  br i1 %.not.15, label %119, label %116

116:                                              ; preds = %113
  %117 = load i32, ptr @errors, align 4, !tbaa !5
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr @errors, align 4, !tbaa !5
  br label %119

119:                                              ; preds = %116, %113
  %120 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %16)
  %121 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %16) #3
  %.not.16 = icmp eq i32 %120, %121
  br i1 %.not.16, label %125, label %122

122:                                              ; preds = %119
  %123 = load i32, ptr @errors, align 4, !tbaa !5
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr @errors, align 4, !tbaa !5
  br label %125

125:                                              ; preds = %122, %119
  %126 = tail call i32 @Classify(i32 noundef %20, i32 noundef %23, i32 noundef %17)
  %127 = tail call i32 @Solution(i32 noundef %20, i32 noundef %23, i32 noundef %17) #3
  %.not.17 = icmp eq i32 %126, %127
  br i1 %.not.17, label %131, label %128

128:                                              ; preds = %125
  %129 = load i32, ptr @errors, align 4, !tbaa !5
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr @errors, align 4, !tbaa !5
  br label %131

131:                                              ; preds = %128, %125
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 18
  br i1 %exitcond.not, label %132, label %21, !llvm.loop !9

132:                                              ; preds = %131
  %indvars.iv.next25 = add nuw nsw i64 %indvars.iv24, 1
  %exitcond27.not = icmp eq i64 %indvars.iv.next25, 18
  br i1 %exitcond27.not, label %.preheader, label %18, !llvm.loop !11

.preheader:                                       ; preds = %132, %.preheader
  br label %.preheader
}

declare i32 @Solution(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

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 = { noreturn 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 #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}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass