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

@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

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

; Function Attrs: nounwind uwtable
define dso_local void @Program4_3() #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
  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
  store i32 0, ptr @errors, align 4, !tbaa !5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %41, %0
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 1000
  br i1 %8, label %9, label %44

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

10:                                               ; preds = %37, %9
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 1000
  br i1 %12, label %13, label %40

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

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

17:                                               ; preds = %14
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = call i32 @Classify(i32 noundef %18, i32 noundef %19, i32 noundef %20)
  store i32 %21, ptr %1, align 4, !tbaa !5
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = call i32 @Solution(i32 noundef %22, i32 noundef %23, i32 noundef %24)
  store i32 %25, ptr %2, align 4, !tbaa !5
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = icmp ne i32 %26, %27
  br i1 %28, label %29, label %32

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

32:                                               ; preds = %29, %17
  br label %33

33:                                               ; preds = %32
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %4, align 4, !tbaa !5
  br label %14, !llvm.loop !9

36:                                               ; preds = %14
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %5, align 4, !tbaa !5
  br label %10, !llvm.loop !11

40:                                               ; preds = %10
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %3, align 4, !tbaa !5
  br label %6, !llvm.loop !12

44:                                               ; preds = %6
  br label %45

45:                                               ; preds = %46, %44
  br label %46

46:                                               ; preds = %45
  br label %45
}

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"

@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

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

; Function Attrs: noreturn nounwind uwtable
define dso_local void @Program4_3() local_unnamed_addr #2 {
  store i32 0, ptr @errors, align 4, !tbaa !5
  br label %.preheader17

.preheader17:                                     ; preds = %0, %11
  %.01520 = phi i32 [ 0, %0 ], [ %12, %11 ]
  br label %.preheader16

.preheader16:                                     ; preds = %.preheader17, %9
  %.019 = phi i32 [ 0, %.preheader17 ], [ %10, %9 ]
  br label %1

1:                                                ; preds = %.preheader16, %7
  %.01418 = phi i32 [ 0, %.preheader16 ], [ %8, %7 ]
  %2 = tail call i32 @Classify(i32 noundef %.01520, i32 noundef %.019, i32 noundef %.01418)
  %3 = tail call i32 @Solution(i32 noundef %.01520, i32 noundef %.019, i32 noundef %.01418) #3
  %.not = icmp eq i32 %2, %3
  br i1 %.not, label %7, label %4

4:                                                ; preds = %1
  %5 = load i32, ptr @errors, align 4, !tbaa !5
  %6 = add nsw i32 %5, 1
  store i32 %6, ptr @errors, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %1, %4
  %8 = add nuw nsw i32 %.01418, 1
  %exitcond.not = icmp eq i32 %8, 1000
  br i1 %exitcond.not, label %9, label %1, !llvm.loop !9

9:                                                ; preds = %7
  %10 = add nuw nsw i32 %.019, 1
  %exitcond21.not = icmp eq i32 %10, 1000
  br i1 %exitcond21.not, label %11, label %.preheader16, !llvm.loop !11

11:                                               ; preds = %9
  %12 = add nuw nsw i32 %.01520, 1
  %exitcond22.not = icmp eq i32 %12, 1000
  br i1 %exitcond22.not, label %.preheader, label %.preheader17, !llvm.loop !12

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

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


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