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

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

%struct.ScoreboardElement = type { i8, i8, i8, i32 }

@.str = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @printscores() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @UART0_OutString(ptr noundef @.str)
  %3 = call ptr @Scoreboard_Get()
  store ptr %3, ptr %1, align 8, !tbaa !5
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %4

4:                                                ; preds = %32, %0
  %5 = load i32, ptr %2, align 4, !tbaa !9
  %6 = icmp slt i32 %5, 5
  br i1 %6, label %7, label %35

7:                                                ; preds = %4
  %8 = load ptr, ptr %1, align 8, !tbaa !5
  %9 = load i32, ptr %2, align 4, !tbaa !9
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds %struct.ScoreboardElement, ptr %8, i64 %10
  %12 = getelementptr inbounds %struct.ScoreboardElement, ptr %11, i32 0, i32 0
  %13 = load i8, ptr %12, align 4, !tbaa !11
  call void @UART0_OutChar(i8 noundef signext %13)
  %14 = load ptr, ptr %1, align 8, !tbaa !5
  %15 = load i32, ptr %2, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds %struct.ScoreboardElement, ptr %14, i64 %16
  %18 = getelementptr inbounds %struct.ScoreboardElement, ptr %17, i32 0, i32 1
  %19 = load i8, ptr %18, align 1, !tbaa !13
  call void @UART0_OutChar(i8 noundef signext %19)
  %20 = load ptr, ptr %1, align 8, !tbaa !5
  %21 = load i32, ptr %2, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds %struct.ScoreboardElement, ptr %20, i64 %22
  %24 = getelementptr inbounds %struct.ScoreboardElement, ptr %23, i32 0, i32 2
  %25 = load i8, ptr %24, align 2, !tbaa !14
  call void @UART0_OutChar(i8 noundef signext %25)
  call void @UART0_OutChar(i8 noundef signext 32)
  call void @UART0_OutChar(i8 noundef signext 32)
  %26 = load ptr, ptr %1, align 8, !tbaa !5
  %27 = load i32, ptr %2, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds %struct.ScoreboardElement, ptr %26, i64 %28
  %30 = getelementptr inbounds %struct.ScoreboardElement, ptr %29, i32 0, i32 3
  %31 = load i32, ptr %30, align 4, !tbaa !15
  call void @UART0_OutUDec(i32 noundef %31)
  call void @UART0_OutChar(i8 noundef signext 13)
  call void @UART0_OutChar(i8 noundef signext 10)
  br label %32

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

35:                                               ; preds = %4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret void
}

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

declare void @UART0_OutString(ptr noundef) #2

declare ptr @Scoreboard_Get() #2

declare void @UART0_OutChar(i8 noundef signext) #2

declare void @UART0_OutUDec(i32 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 = !{!"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 = !{!12, !7, i64 0}
!12 = !{!"ScoreboardElement", !7, i64 0, !7, i64 1, !7, i64 2, !10, i64 4}
!13 = !{!12, !7, i64 1}
!14 = !{!12, !7, i64 2}
!15 = !{!12, !10, i64 4}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; 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 [15 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @printscores() local_unnamed_addr #0 {
  tail call void @UART0_OutString(ptr noundef nonnull @.str) #2
  %1 = tail call ptr @Scoreboard_Get() #2
  %2 = load i8, ptr %1, align 4, !tbaa !5
  tail call void @UART0_OutChar(i8 noundef signext %2) #2
  %3 = getelementptr inbounds i8, ptr %1, i64 1
  %4 = load i8, ptr %3, align 1, !tbaa !10
  tail call void @UART0_OutChar(i8 noundef signext %4) #2
  %5 = getelementptr inbounds i8, ptr %1, i64 2
  %6 = load i8, ptr %5, align 2, !tbaa !11
  tail call void @UART0_OutChar(i8 noundef signext %6) #2
  tail call void @UART0_OutChar(i8 noundef signext 32) #2
  tail call void @UART0_OutChar(i8 noundef signext 32) #2
  %7 = getelementptr inbounds i8, ptr %1, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !12
  tail call void @UART0_OutUDec(i32 noundef %8) #2
  tail call void @UART0_OutChar(i8 noundef signext 13) #2
  tail call void @UART0_OutChar(i8 noundef signext 10) #2
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load i8, ptr %9, align 4, !tbaa !5
  tail call void @UART0_OutChar(i8 noundef signext %10) #2
  %11 = getelementptr inbounds i8, ptr %1, i64 9
  %12 = load i8, ptr %11, align 1, !tbaa !10
  tail call void @UART0_OutChar(i8 noundef signext %12) #2
  %13 = getelementptr inbounds i8, ptr %1, i64 10
  %14 = load i8, ptr %13, align 2, !tbaa !11
  tail call void @UART0_OutChar(i8 noundef signext %14) #2
  tail call void @UART0_OutChar(i8 noundef signext 32) #2
  tail call void @UART0_OutChar(i8 noundef signext 32) #2
  %15 = getelementptr inbounds i8, ptr %1, i64 12
  %16 = load i32, ptr %15, align 4, !tbaa !12
  tail call void @UART0_OutUDec(i32 noundef %16) #2
  tail call void @UART0_OutChar(i8 noundef signext 13) #2
  tail call void @UART0_OutChar(i8 noundef signext 10) #2
  %17 = getelementptr inbounds i8, ptr %1, i64 16
  %18 = load i8, ptr %17, align 4, !tbaa !5
  tail call void @UART0_OutChar(i8 noundef signext %18) #2
  %19 = getelementptr inbounds i8, ptr %1, i64 17
  %20 = load i8, ptr %19, align 1, !tbaa !10
  tail call void @UART0_OutChar(i8 noundef signext %20) #2
  %21 = getelementptr inbounds i8, ptr %1, i64 18
  %22 = load i8, ptr %21, align 2, !tbaa !11
  tail call void @UART0_OutChar(i8 noundef signext %22) #2
  tail call void @UART0_OutChar(i8 noundef signext 32) #2
  tail call void @UART0_OutChar(i8 noundef signext 32) #2
  %23 = getelementptr inbounds i8, ptr %1, i64 20
  %24 = load i32, ptr %23, align 4, !tbaa !12
  tail call void @UART0_OutUDec(i32 noundef %24) #2
  tail call void @UART0_OutChar(i8 noundef signext 13) #2
  tail call void @UART0_OutChar(i8 noundef signext 10) #2
  %25 = getelementptr inbounds i8, ptr %1, i64 24
  %26 = load i8, ptr %25, align 4, !tbaa !5
  tail call void @UART0_OutChar(i8 noundef signext %26) #2
  %27 = getelementptr inbounds i8, ptr %1, i64 25
  %28 = load i8, ptr %27, align 1, !tbaa !10
  tail call void @UART0_OutChar(i8 noundef signext %28) #2
  %29 = getelementptr inbounds i8, ptr %1, i64 26
  %30 = load i8, ptr %29, align 2, !tbaa !11
  tail call void @UART0_OutChar(i8 noundef signext %30) #2
  tail call void @UART0_OutChar(i8 noundef signext 32) #2
  tail call void @UART0_OutChar(i8 noundef signext 32) #2
  %31 = getelementptr inbounds i8, ptr %1, i64 28
  %32 = load i32, ptr %31, align 4, !tbaa !12
  tail call void @UART0_OutUDec(i32 noundef %32) #2
  tail call void @UART0_OutChar(i8 noundef signext 13) #2
  tail call void @UART0_OutChar(i8 noundef signext 10) #2
  %33 = getelementptr inbounds i8, ptr %1, i64 32
  %34 = load i8, ptr %33, align 4, !tbaa !5
  tail call void @UART0_OutChar(i8 noundef signext %34) #2
  %35 = getelementptr inbounds i8, ptr %1, i64 33
  %36 = load i8, ptr %35, align 1, !tbaa !10
  tail call void @UART0_OutChar(i8 noundef signext %36) #2
  %37 = getelementptr inbounds i8, ptr %1, i64 34
  %38 = load i8, ptr %37, align 2, !tbaa !11
  tail call void @UART0_OutChar(i8 noundef signext %38) #2
  tail call void @UART0_OutChar(i8 noundef signext 32) #2
  tail call void @UART0_OutChar(i8 noundef signext 32) #2
  %39 = getelementptr inbounds i8, ptr %1, i64 36
  %40 = load i32, ptr %39, align 4, !tbaa !12
  tail call void @UART0_OutUDec(i32 noundef %40) #2
  tail call void @UART0_OutChar(i8 noundef signext 13) #2
  tail call void @UART0_OutChar(i8 noundef signext 10) #2
  ret void
}

declare void @UART0_OutString(ptr noundef) local_unnamed_addr #1

declare ptr @Scoreboard_Get() local_unnamed_addr #1

declare void @UART0_OutChar(i8 noundef signext) local_unnamed_addr #1

declare void @UART0_OutUDec(i32 noundef) local_unnamed_addr #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 = { "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 = { 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, !7, i64 0}
!6 = !{!"ScoreboardElement", !7, i64 0, !7, i64 1, !7, i64 2, !9, i64 4}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!6, !7, i64 1}
!11 = !{!6, !7, i64 2}
!12 = !{!6, !9, i64 4}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass