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

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

@c = external hidden global i16, align 2
@d = external hidden global i64, align 8
@e = external hidden global i32, align 4
@output = external hidden global [200 x i64], align 16
@__const.verify_benchmark_edn.exp_output = external hidden unnamed_addr constant <{ [101 x i64], [99 x i64] }>, 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @verify_benchmark_edn(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [200 x i64], align 16
  %9 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 10243, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 -441886230, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 -441886230, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1600, ptr %8) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %8, ptr align 16 @__const.verify_benchmark_edn.exp_output, i64 1600, i1 false)
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %25, %1
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 200
  br i1 %12, label %13, label %28

13:                                               ; preds = %10
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [200 x i64], ptr @output, i64 0, i64 %15
  %17 = load i64, ptr %16, align 8, !tbaa !9
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [200 x i64], ptr %8, i64 0, i64 %19
  %21 = load i64, ptr %20, align 8, !tbaa !9
  %22 = icmp ne i64 %17, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %13
  store i32 0, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %44

24:                                               ; preds = %13
  br label %25

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

28:                                               ; preds = %10
  %29 = load i16, ptr @c, align 2, !tbaa !13
  %30 = sext i16 %29 to i32
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = icmp ne i32 %30, %31
  br i1 %32, label %42, label %33

33:                                               ; preds = %28
  %34 = load i64, ptr @d, align 8, !tbaa !9
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = icmp ne i64 %34, %36
  br i1 %37, label %42, label %38

38:                                               ; preds = %33
  %39 = load i32, ptr @e, align 4, !tbaa !5
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = icmp ne i32 %39, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %38, %33, %28
  store i32 0, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %44

43:                                               ; preds = %38
  store i32 1, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %44

44:                                               ; preds = %43, %42, %23
  call void @llvm.lifetime.end.p0(i64 1600, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %45 = load i32, ptr %2, align 4
  ret i32 %45
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !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"

@c = external hidden local_unnamed_addr global i16, align 2
@d = external hidden local_unnamed_addr global i64, align 8
@e = external hidden local_unnamed_addr global i32, align 4
@output = external hidden local_unnamed_addr global [200 x i64], align 16
@__const.verify_benchmark_edn.exp_output = external hidden unnamed_addr constant <{ [101 x i64], [99 x i64] }>, align 16

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 2) i32 @verify_benchmark_edn(i32 noundef %0) local_unnamed_addr #0 {
  br label %23

2:                                                ; preds = %23
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %3 = getelementptr inbounds [200 x i64], ptr @output, i64 0, i64 %indvars.iv.next
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds [200 x i64], ptr @__const.verify_benchmark_edn.exp_output, i64 0, i64 %indvars.iv.next
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %.not11.1 = icmp eq i64 %4, %6
  br i1 %.not11.1, label %7, label %.loopexit

7:                                                ; preds = %2
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %8 = getelementptr inbounds [200 x i64], ptr @output, i64 0, i64 %indvars.iv.next.1
  %9 = load i64, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds [200 x i64], ptr @__const.verify_benchmark_edn.exp_output, i64 0, i64 %indvars.iv.next.1
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %.not11.2 = icmp eq i64 %9, %11
  br i1 %.not11.2, label %12, label %.loopexit

12:                                               ; preds = %7
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %13 = getelementptr inbounds [200 x i64], ptr @output, i64 0, i64 %indvars.iv.next.2
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds [200 x i64], ptr @__const.verify_benchmark_edn.exp_output, i64 0, i64 %indvars.iv.next.2
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %.not11.3 = icmp eq i64 %14, %16
  br i1 %.not11.3, label %17, label %.loopexit

17:                                               ; preds = %12
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %18 = getelementptr inbounds [200 x i64], ptr @output, i64 0, i64 %indvars.iv.next.3
  %19 = load i64, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds [200 x i64], ptr @__const.verify_benchmark_edn.exp_output, i64 0, i64 %indvars.iv.next.3
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %.not11.4 = icmp eq i64 %19, %21
  br i1 %.not11.4, label %22, label %.loopexit

22:                                               ; preds = %17
  %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv, 5
  %exitcond.not.4 = icmp eq i64 %indvars.iv.next.4, 200
  br i1 %exitcond.not.4, label %28, label %23, !llvm.loop !9

23:                                               ; preds = %22, %1
  %indvars.iv = phi i64 [ 0, %1 ], [ %indvars.iv.next.4, %22 ]
  %24 = getelementptr inbounds [200 x i64], ptr @output, i64 0, i64 %indvars.iv
  %25 = load i64, ptr %24, align 8, !tbaa !5
  %26 = getelementptr inbounds [200 x i64], ptr @__const.verify_benchmark_edn.exp_output, i64 0, i64 %indvars.iv
  %27 = load i64, ptr %26, align 8, !tbaa !5
  %.not11 = icmp eq i64 %25, %27
  br i1 %.not11, label %2, label %.loopexit

28:                                               ; preds = %22
  %29 = load i16, ptr @c, align 2, !tbaa !11
  %.not = icmp eq i16 %29, 10243
  %30 = load i64, ptr @d, align 8
  %.not9 = icmp eq i64 %30, -441886230
  %or.cond = select i1 %.not, i1 %.not9, i1 false
  %31 = load i32, ptr @e, align 4
  %.not10 = icmp eq i32 %31, -441886230
  %or.cond12 = select i1 %or.cond, i1 %.not10, i1 false
  %spec.select = zext i1 %or.cond12 to i32
  br label %.loopexit

.loopexit:                                        ; preds = %23, %2, %7, %12, %17, %28
  %.0 = phi i32 [ %spec.select, %28 ], [ 0, %17 ], [ 0, %12 ], [ 0, %7 ], [ 0, %2 ], [ 0, %23 ]
  ret i32 %.0
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: none, inaccessiblemem: 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" }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}


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