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

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

@strings = external dso_local global [5 x ptr], align 16

; Function Attrs: nounwind uwtable
declare dso_local i32 @levenshtein_distance(ptr noundef, ptr 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @benchmark_levenshtein() #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, 5
  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, 5
  br i1 %10, label %11, label %26

11:                                               ; preds = %8
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [5 x ptr], ptr @strings, i64 0, i64 %13
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [5 x ptr], ptr @strings, i64 0, i64 %17
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = call i32 @levenshtein_distance(ptr noundef %15, ptr noundef %19)
  %21 = load volatile i32, ptr %3, align 4, !tbaa !5
  %22 = add i32 %21, %20
  store volatile i32 %22, ptr %3, align 4, !tbaa !5
  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 !11

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 !13

30:                                               ; preds = %4
  %31 = load volatile i32, ptr %3, 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 i32 %31
}

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


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

@strings = external dso_local local_unnamed_addr global [5 x ptr], align 16

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

; 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

; Function Attrs: nounwind uwtable
define dso_local i32 @benchmark_levenshtein() local_unnamed_addr #0 {
.preheader:
  %0 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0)
  store volatile i32 0, ptr %0, align 4, !tbaa !5
  %1 = load ptr, ptr @strings, align 16, !tbaa !9
  %2 = tail call i32 @levenshtein_distance(ptr noundef %1, ptr noundef %1)
  %.0..0..0..0. = load volatile i32, ptr %0, align 4, !tbaa !5
  %3 = add i32 %.0..0..0..0., %2
  store volatile i32 %3, ptr %0, align 4, !tbaa !5
  %4 = load ptr, ptr @strings, align 16, !tbaa !9
  %5 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 8), align 8, !tbaa !9
  %6 = tail call i32 @levenshtein_distance(ptr noundef %4, ptr noundef %5)
  %.0..0..0..0..1 = load volatile i32, ptr %0, align 4, !tbaa !5
  %7 = add i32 %.0..0..0..0..1, %6
  store volatile i32 %7, ptr %0, align 4, !tbaa !5
  %8 = load ptr, ptr @strings, align 16, !tbaa !9
  %9 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 16), align 16, !tbaa !9
  %10 = tail call i32 @levenshtein_distance(ptr noundef %8, ptr noundef %9)
  %.0..0..0..0..2 = load volatile i32, ptr %0, align 4, !tbaa !5
  %11 = add i32 %.0..0..0..0..2, %10
  store volatile i32 %11, ptr %0, align 4, !tbaa !5
  %12 = load ptr, ptr @strings, align 16, !tbaa !9
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 24), align 8, !tbaa !9
  %14 = tail call i32 @levenshtein_distance(ptr noundef %12, ptr noundef %13)
  %.0..0..0..0..3 = load volatile i32, ptr %0, align 4, !tbaa !5
  %15 = add i32 %.0..0..0..0..3, %14
  store volatile i32 %15, ptr %0, align 4, !tbaa !5
  %16 = load ptr, ptr @strings, align 16, !tbaa !9
  %17 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 32), align 16, !tbaa !9
  %18 = tail call i32 @levenshtein_distance(ptr noundef %16, ptr noundef %17)
  %.0..0..0..0..4 = load volatile i32, ptr %0, align 4, !tbaa !5
  %19 = add i32 %.0..0..0..0..4, %18
  store volatile i32 %19, ptr %0, align 4, !tbaa !5
  %20 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 8), align 8, !tbaa !9
  %21 = load ptr, ptr @strings, align 16, !tbaa !9
  %22 = tail call i32 @levenshtein_distance(ptr noundef %20, ptr noundef %21)
  %.0..0..0..0..112 = load volatile i32, ptr %0, align 4, !tbaa !5
  %23 = add i32 %.0..0..0..0..112, %22
  store volatile i32 %23, ptr %0, align 4, !tbaa !5
  %24 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 8), align 8, !tbaa !9
  %25 = tail call i32 @levenshtein_distance(ptr noundef %24, ptr noundef %24)
  %.0..0..0..0..1.1 = load volatile i32, ptr %0, align 4, !tbaa !5
  %26 = add i32 %.0..0..0..0..1.1, %25
  store volatile i32 %26, ptr %0, align 4, !tbaa !5
  %27 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 8), align 8, !tbaa !9
  %28 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 16), align 16, !tbaa !9
  %29 = tail call i32 @levenshtein_distance(ptr noundef %27, ptr noundef %28)
  %.0..0..0..0..2.1 = load volatile i32, ptr %0, align 4, !tbaa !5
  %30 = add i32 %.0..0..0..0..2.1, %29
  store volatile i32 %30, ptr %0, align 4, !tbaa !5
  %31 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 8), align 8, !tbaa !9
  %32 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 24), align 8, !tbaa !9
  %33 = tail call i32 @levenshtein_distance(ptr noundef %31, ptr noundef %32)
  %.0..0..0..0..3.1 = load volatile i32, ptr %0, align 4, !tbaa !5
  %34 = add i32 %.0..0..0..0..3.1, %33
  store volatile i32 %34, ptr %0, align 4, !tbaa !5
  %35 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 8), align 8, !tbaa !9
  %36 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 32), align 16, !tbaa !9
  %37 = tail call i32 @levenshtein_distance(ptr noundef %35, ptr noundef %36)
  %.0..0..0..0..4.1 = load volatile i32, ptr %0, align 4, !tbaa !5
  %38 = add i32 %.0..0..0..0..4.1, %37
  store volatile i32 %38, ptr %0, align 4, !tbaa !5
  %39 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 16), align 16, !tbaa !9
  %40 = load ptr, ptr @strings, align 16, !tbaa !9
  %41 = tail call i32 @levenshtein_distance(ptr noundef %39, ptr noundef %40)
  %.0..0..0..0..213 = load volatile i32, ptr %0, align 4, !tbaa !5
  %42 = add i32 %.0..0..0..0..213, %41
  store volatile i32 %42, ptr %0, align 4, !tbaa !5
  %43 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 16), align 16, !tbaa !9
  %44 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 8), align 8, !tbaa !9
  %45 = tail call i32 @levenshtein_distance(ptr noundef %43, ptr noundef %44)
  %.0..0..0..0..1.2 = load volatile i32, ptr %0, align 4, !tbaa !5
  %46 = add i32 %.0..0..0..0..1.2, %45
  store volatile i32 %46, ptr %0, align 4, !tbaa !5
  %47 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 16), align 16, !tbaa !9
  %48 = tail call i32 @levenshtein_distance(ptr noundef %47, ptr noundef %47)
  %.0..0..0..0..2.2 = load volatile i32, ptr %0, align 4, !tbaa !5
  %49 = add i32 %.0..0..0..0..2.2, %48
  store volatile i32 %49, ptr %0, align 4, !tbaa !5
  %50 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 16), align 16, !tbaa !9
  %51 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 24), align 8, !tbaa !9
  %52 = tail call i32 @levenshtein_distance(ptr noundef %50, ptr noundef %51)
  %.0..0..0..0..3.2 = load volatile i32, ptr %0, align 4, !tbaa !5
  %53 = add i32 %.0..0..0..0..3.2, %52
  store volatile i32 %53, ptr %0, align 4, !tbaa !5
  %54 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 16), align 16, !tbaa !9
  %55 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 32), align 16, !tbaa !9
  %56 = tail call i32 @levenshtein_distance(ptr noundef %54, ptr noundef %55)
  %.0..0..0..0..4.2 = load volatile i32, ptr %0, align 4, !tbaa !5
  %57 = add i32 %.0..0..0..0..4.2, %56
  store volatile i32 %57, ptr %0, align 4, !tbaa !5
  %58 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 24), align 8, !tbaa !9
  %59 = load ptr, ptr @strings, align 16, !tbaa !9
  %60 = tail call i32 @levenshtein_distance(ptr noundef %58, ptr noundef %59)
  %.0..0..0..0..314 = load volatile i32, ptr %0, align 4, !tbaa !5
  %61 = add i32 %.0..0..0..0..314, %60
  store volatile i32 %61, ptr %0, align 4, !tbaa !5
  %62 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 24), align 8, !tbaa !9
  %63 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 8), align 8, !tbaa !9
  %64 = tail call i32 @levenshtein_distance(ptr noundef %62, ptr noundef %63)
  %.0..0..0..0..1.3 = load volatile i32, ptr %0, align 4, !tbaa !5
  %65 = add i32 %.0..0..0..0..1.3, %64
  store volatile i32 %65, ptr %0, align 4, !tbaa !5
  %66 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 24), align 8, !tbaa !9
  %67 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 16), align 16, !tbaa !9
  %68 = tail call i32 @levenshtein_distance(ptr noundef %66, ptr noundef %67)
  %.0..0..0..0..2.3 = load volatile i32, ptr %0, align 4, !tbaa !5
  %69 = add i32 %.0..0..0..0..2.3, %68
  store volatile i32 %69, ptr %0, align 4, !tbaa !5
  %70 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 24), align 8, !tbaa !9
  %71 = tail call i32 @levenshtein_distance(ptr noundef %70, ptr noundef %70)
  %.0..0..0..0..3.3 = load volatile i32, ptr %0, align 4, !tbaa !5
  %72 = add i32 %.0..0..0..0..3.3, %71
  store volatile i32 %72, ptr %0, align 4, !tbaa !5
  %73 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 24), align 8, !tbaa !9
  %74 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 32), align 16, !tbaa !9
  %75 = tail call i32 @levenshtein_distance(ptr noundef %73, ptr noundef %74)
  %.0..0..0..0..4.3 = load volatile i32, ptr %0, align 4, !tbaa !5
  %76 = add i32 %.0..0..0..0..4.3, %75
  store volatile i32 %76, ptr %0, align 4, !tbaa !5
  %77 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 32), align 16, !tbaa !9
  %78 = load ptr, ptr @strings, align 16, !tbaa !9
  %79 = tail call i32 @levenshtein_distance(ptr noundef %77, ptr noundef %78)
  %.0..0..0..0..415 = load volatile i32, ptr %0, align 4, !tbaa !5
  %80 = add i32 %.0..0..0..0..415, %79
  store volatile i32 %80, ptr %0, align 4, !tbaa !5
  %81 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 32), align 16, !tbaa !9
  %82 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 8), align 8, !tbaa !9
  %83 = tail call i32 @levenshtein_distance(ptr noundef %81, ptr noundef %82)
  %.0..0..0..0..1.4 = load volatile i32, ptr %0, align 4, !tbaa !5
  %84 = add i32 %.0..0..0..0..1.4, %83
  store volatile i32 %84, ptr %0, align 4, !tbaa !5
  %85 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 32), align 16, !tbaa !9
  %86 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 16), align 16, !tbaa !9
  %87 = tail call i32 @levenshtein_distance(ptr noundef %85, ptr noundef %86)
  %.0..0..0..0..2.4 = load volatile i32, ptr %0, align 4, !tbaa !5
  %88 = add i32 %.0..0..0..0..2.4, %87
  store volatile i32 %88, ptr %0, align 4, !tbaa !5
  %89 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 32), align 16, !tbaa !9
  %90 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 24), align 8, !tbaa !9
  %91 = tail call i32 @levenshtein_distance(ptr noundef %89, ptr noundef %90)
  %.0..0..0..0..3.4 = load volatile i32, ptr %0, align 4, !tbaa !5
  %92 = add i32 %.0..0..0..0..3.4, %91
  store volatile i32 %92, ptr %0, align 4, !tbaa !5
  %93 = load ptr, ptr getelementptr inbounds (i8, ptr @strings, i64 32), align 16, !tbaa !9
  %94 = tail call i32 @levenshtein_distance(ptr noundef %93, ptr noundef %93)
  %.0..0..0..0..4.4 = load volatile i32, ptr %0, align 4, !tbaa !5
  %95 = add i32 %.0..0..0..0..4.4, %94
  store volatile i32 %95, ptr %0, align 4, !tbaa !5
  %.0..0..0..0.1 = load volatile i32, ptr %0, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %0)
  ret i32 %.0..0..0..0.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 = { 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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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