; LLVM IR from CactiLab/Sherloc-Cortex-M-CFVD :: Sherloc_runtime/evaluation/src/dijkstra (dijkstra_small)

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

@output_count = external dso_local global i32, align 4
@output = external dso_local global [100 x i32], align 16

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @dijkstra(i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @benchmark_dijkstra() #1 {
  %1 = alloca i32, align 4
  %2 = 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
  store i32 0, ptr @output_count, align 4, !tbaa !5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %23, %0
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = icmp slt i32 %4, 10
  br i1 %5, label %6, label %26

6:                                                ; preds = %3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %19, %6
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 10
  br i1 %9, label %10, label %22

10:                                               ; preds = %7
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = call i32 @dijkstra(i32 noundef %11, i32 noundef %12)
  %14 = load i32, ptr @output_count, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [100 x i32], ptr @output, i64 0, i64 %15
  store i32 %13, ptr %16, align 4, !tbaa !5
  %17 = load i32, ptr @output_count, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr @output_count, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %10
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %1, align 4, !tbaa !5
  br label %7, !llvm.loop !9

22:                                               ; preds = %7
  br label %23

23:                                               ; preds = %22
  %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 %3, !llvm.loop !11

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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}


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

@output_count = external dso_local local_unnamed_addr global i32, align 4
@output = external dso_local local_unnamed_addr global [100 x i32], align 16

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @benchmark_dijkstra() local_unnamed_addr #0 {
  store i32 0, ptr @output_count, align 4, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %0, %.preheader
  %.08 = phi i32 [ 0, %0 ], [ %51, %.preheader ]
  %1 = tail call i32 @dijkstra(i32 noundef 0, i32 noundef %.08)
  %2 = load i32, ptr @output_count, align 4, !tbaa !5
  %3 = sext i32 %2 to i64
  %4 = getelementptr inbounds [100 x i32], ptr @output, i64 0, i64 %3
  store i32 %1, ptr %4, align 4, !tbaa !5
  %5 = add nsw i32 %2, 1
  store i32 %5, ptr @output_count, align 4, !tbaa !5
  %6 = tail call i32 @dijkstra(i32 noundef 1, i32 noundef %.08)
  %7 = load i32, ptr @output_count, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [100 x i32], ptr @output, i64 0, i64 %8
  store i32 %6, ptr %9, align 4, !tbaa !5
  %10 = add nsw i32 %7, 1
  store i32 %10, ptr @output_count, align 4, !tbaa !5
  %11 = tail call i32 @dijkstra(i32 noundef 2, i32 noundef %.08)
  %12 = load i32, ptr @output_count, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [100 x i32], ptr @output, i64 0, i64 %13
  store i32 %11, ptr %14, align 4, !tbaa !5
  %15 = add nsw i32 %12, 1
  store i32 %15, ptr @output_count, align 4, !tbaa !5
  %16 = tail call i32 @dijkstra(i32 noundef 3, i32 noundef %.08)
  %17 = load i32, ptr @output_count, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [100 x i32], ptr @output, i64 0, i64 %18
  store i32 %16, ptr %19, align 4, !tbaa !5
  %20 = add nsw i32 %17, 1
  store i32 %20, ptr @output_count, align 4, !tbaa !5
  %21 = tail call i32 @dijkstra(i32 noundef 4, i32 noundef %.08)
  %22 = load i32, ptr @output_count, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [100 x i32], ptr @output, i64 0, i64 %23
  store i32 %21, ptr %24, align 4, !tbaa !5
  %25 = add nsw i32 %22, 1
  store i32 %25, ptr @output_count, align 4, !tbaa !5
  %26 = tail call i32 @dijkstra(i32 noundef 5, i32 noundef %.08)
  %27 = load i32, ptr @output_count, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [100 x i32], ptr @output, i64 0, i64 %28
  store i32 %26, ptr %29, align 4, !tbaa !5
  %30 = add nsw i32 %27, 1
  store i32 %30, ptr @output_count, align 4, !tbaa !5
  %31 = tail call i32 @dijkstra(i32 noundef 6, i32 noundef %.08)
  %32 = load i32, ptr @output_count, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [100 x i32], ptr @output, i64 0, i64 %33
  store i32 %31, ptr %34, align 4, !tbaa !5
  %35 = add nsw i32 %32, 1
  store i32 %35, ptr @output_count, align 4, !tbaa !5
  %36 = tail call i32 @dijkstra(i32 noundef 7, i32 noundef %.08)
  %37 = load i32, ptr @output_count, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100 x i32], ptr @output, i64 0, i64 %38
  store i32 %36, ptr %39, align 4, !tbaa !5
  %40 = add nsw i32 %37, 1
  store i32 %40, ptr @output_count, align 4, !tbaa !5
  %41 = tail call i32 @dijkstra(i32 noundef 8, i32 noundef %.08)
  %42 = load i32, ptr @output_count, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [100 x i32], ptr @output, i64 0, i64 %43
  store i32 %41, ptr %44, align 4, !tbaa !5
  %45 = add nsw i32 %42, 1
  store i32 %45, ptr @output_count, align 4, !tbaa !5
  %46 = tail call i32 @dijkstra(i32 noundef 9, i32 noundef %.08)
  %47 = load i32, ptr @output_count, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [100 x i32], ptr @output, i64 0, i64 %48
  store i32 %46, ptr %49, align 4, !tbaa !5
  %50 = add nsw i32 %47, 1
  store i32 %50, ptr @output_count, align 4, !tbaa !5
  %51 = add nuw nsw i32 %.08, 1
  %exitcond.not = icmp eq i32 %51, 10
  br i1 %exitcond.not, label %52, label %.preheader, !llvm.loop !9

52:                                               ; preds = %.preheader
  ret i32 0
}

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

!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"}


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