; LLVM IR from lfarcaro/ARINC653_ARMV7A_Z7000 :: ARINC653_ARMV7A_Z7000.sw/MEASURE/src/Algorithms (algorithm_dijkstra1)

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

@algorithm_dijkstra1_checksum = external dso_local global i32, align 4
@algorithm_dijkstra1_AdjMatrix = external dso_local global [50 x [50 x i8]], align 16
@algorithm_dijkstra1_queueCount = external dso_local global i32, align 4
@algorithm_dijkstra1_queueNext = external dso_local global i32, align 4
@algorithm_dijkstra1_queueHead = external dso_local global ptr, align 8

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

4:                                                ; preds = %27, %0
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = icmp slt i32 %5, 50
  br i1 %6, label %7, label %30

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

8:                                                ; preds = %23, %7
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 50
  br i1 %10, label %11, label %26

11:                                               ; preds = %8
  %12 = load volatile i32, ptr %3, align 4, !tbaa !5
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [50 x [50 x i8]], ptr @algorithm_dijkstra1_AdjMatrix, i64 0, i64 %14
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [50 x i8], ptr %15, i64 0, i64 %17
  %19 = load i8, ptr %18, align 1, !tbaa !9
  %20 = zext i8 %19 to i32
  %21 = xor i32 %20, %12
  %22 = trunc i32 %21 to i8
  store i8 %22, ptr %18, align 1, !tbaa !9
  br label %23

23:                                               ; preds = %11
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !10

26:                                               ; preds = %8
  br label %27

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

30:                                               ; preds = %4
  store i32 0, ptr @algorithm_dijkstra1_queueCount, align 4, !tbaa !5
  store i32 0, ptr @algorithm_dijkstra1_queueNext, align 4, !tbaa !5
  store ptr null, ptr @algorithm_dijkstra1_queueHead, align 8, !tbaa !13
  store i32 0, ptr @algorithm_dijkstra1_checksum, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  ret void
}

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

; 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 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}


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

@algorithm_dijkstra1_checksum = external dso_local local_unnamed_addr global i32, align 4
@algorithm_dijkstra1_AdjMatrix = external dso_local local_unnamed_addr global [50 x [50 x i8]], align 16
@algorithm_dijkstra1_queueCount = external dso_local local_unnamed_addr global i32, align 4
@algorithm_dijkstra1_queueNext = external dso_local local_unnamed_addr global i32, align 4
@algorithm_dijkstra1_queueHead = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: nofree norecurse nounwind memory(readwrite, argmem: none) uwtable
define dso_local void @ALGORITHM_DIJKSTRA1_INITIALIZE() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1)
  store volatile i32 0, ptr %1, align 4, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %0, %11
  %indvars.iv10 = phi i64 [ 0, %0 ], [ %indvars.iv.next11, %11 ]
  br label %2

2:                                                ; preds = %2, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next.1, %2 ]
  %.0..0..0..0. = load volatile i32, ptr %1, align 4, !tbaa !5
  %3 = getelementptr inbounds [50 x [50 x i8]], ptr @algorithm_dijkstra1_AdjMatrix, i64 0, i64 %indvars.iv10, i64 %indvars.iv
  %4 = load i8, ptr %3, align 2, !tbaa !9
  %5 = trunc i32 %.0..0..0..0. to i8
  %6 = xor i8 %4, %5
  store i8 %6, ptr %3, align 2, !tbaa !9
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %.0..0..0..0..1 = load volatile i32, ptr %1, align 4, !tbaa !5
  %7 = getelementptr inbounds [50 x [50 x i8]], ptr @algorithm_dijkstra1_AdjMatrix, i64 0, i64 %indvars.iv10, i64 %indvars.iv.next
  %8 = load i8, ptr %7, align 1, !tbaa !9
  %9 = trunc i32 %.0..0..0..0..1 to i8
  %10 = xor i8 %8, %9
  store i8 %10, ptr %7, align 1, !tbaa !9
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 50
  br i1 %exitcond.not.1, label %11, label %2, !llvm.loop !10

11:                                               ; preds = %2
  %indvars.iv.next11 = add nuw nsw i64 %indvars.iv10, 1
  %exitcond13.not = icmp eq i64 %indvars.iv.next11, 50
  br i1 %exitcond13.not, label %12, label %.preheader, !llvm.loop !12

12:                                               ; preds = %11
  store i32 0, ptr @algorithm_dijkstra1_queueCount, align 4, !tbaa !5
  store i32 0, ptr @algorithm_dijkstra1_queueNext, align 4, !tbaa !5
  store ptr null, ptr @algorithm_dijkstra1_queueHead, align 8, !tbaa !13
  store i32 0, ptr @algorithm_dijkstra1_checksum, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1)
  ret void
}

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

; 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 norecurse nounwind memory(readwrite, argmem: none) 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) }

!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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}


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