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

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

@eccblocks = external hidden constant [640 x i8], align 16
@neccblk1 = external dso_local global i8, align 1
@neccblk2 = external dso_local global i8, align 1
@datablkw = external dso_local global i8, align 1

; 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 @initecc(i8 noundef zeroext, i8 noundef zeroext) #1

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

7:                                                ; preds = %52, %2
  %8 = load i8, ptr %6, align 1, !tbaa !5
  %9 = zext i8 %8 to i32
  %10 = icmp slt i32 %9, 40
  br i1 %10, label %11, label %55

11:                                               ; preds = %7
  %12 = load i8, ptr %3, align 1, !tbaa !5
  %13 = zext i8 %12 to i32
  %14 = sub nsw i32 %13, 1
  %15 = mul nsw i32 %14, 4
  %16 = load i8, ptr %6, align 1, !tbaa !5
  %17 = zext i8 %16 to i32
  %18 = sub nsw i32 %17, 1
  %19 = mul nsw i32 %18, 16
  %20 = add nsw i32 %15, %19
  store i32 %20, ptr %5, align 4, !tbaa !8
  %21 = load i32, ptr %5, align 4, !tbaa !8
  %22 = add i32 %21, 1
  store i32 %22, ptr %5, align 4, !tbaa !8
  %23 = zext i32 %21 to i64
  %24 = getelementptr inbounds [640 x i8], ptr @eccblocks, i64 0, i64 %23
  %25 = load i8, ptr %24, align 1, !tbaa !5
  store i8 %25, ptr @neccblk1, align 1, !tbaa !5
  %26 = load i32, ptr %5, align 4, !tbaa !8
  %27 = add i32 %26, 1
  store i32 %27, ptr %5, align 4, !tbaa !8
  %28 = zext i32 %26 to i64
  %29 = getelementptr inbounds [640 x i8], ptr @eccblocks, i64 0, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !5
  store i8 %30, ptr @neccblk2, align 1, !tbaa !5
  %31 = load i32, ptr %5, align 4, !tbaa !8
  %32 = add i32 %31, 1
  store i32 %32, ptr %5, align 4, !tbaa !8
  %33 = zext i32 %31 to i64
  %34 = getelementptr inbounds [640 x i8], ptr @eccblocks, i64 0, i64 %33
  %35 = load i8, ptr %34, align 1, !tbaa !5
  store i8 %35, ptr @datablkw, align 1, !tbaa !5
  %36 = load i32, ptr %4, align 4, !tbaa !8
  %37 = load i8, ptr @datablkw, align 1, !tbaa !5
  %38 = zext i8 %37 to i32
  %39 = load i8, ptr @neccblk1, align 1, !tbaa !5
  %40 = zext i8 %39 to i32
  %41 = load i8, ptr @neccblk2, align 1, !tbaa !5
  %42 = zext i8 %41 to i32
  %43 = add nsw i32 %40, %42
  %44 = mul nsw i32 %38, %43
  %45 = load i8, ptr @neccblk2, align 1, !tbaa !5
  %46 = zext i8 %45 to i32
  %47 = add nsw i32 %44, %46
  %48 = sub nsw i32 %47, 3
  %49 = icmp ult i32 %36, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %11
  br label %55

51:                                               ; preds = %11
  br label %52

52:                                               ; preds = %51
  %53 = load i8, ptr %6, align 1, !tbaa !5
  %54 = add i8 %53, 1
  store i8 %54, ptr %6, align 1, !tbaa !5
  br label %7, !llvm.loop !10

55:                                               ; preds = %50, %7
  %56 = load i8, ptr %3, align 1, !tbaa !5
  %57 = load i8, ptr %6, align 1, !tbaa !5
  %58 = call i32 @initecc(i8 noundef zeroext %56, i8 noundef zeroext %57)
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %58
}

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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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"

@eccblocks = external hidden local_unnamed_addr constant [640 x i8], align 16
@neccblk1 = external dso_local local_unnamed_addr global i8, align 1
@neccblk2 = external dso_local local_unnamed_addr global i8, align 1
@datablkw = external dso_local local_unnamed_addr global i8, align 1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @initeccsize(i8 noundef zeroext %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = zext i8 %0 to i64
  %4 = shl nuw nsw i64 %3, 2
  br label %5

5:                                                ; preds = %2, %28
  %indvars.iv16 = phi i64 [ 1, %2 ], [ %indvars.iv.next17, %28 ]
  %6 = shl nuw nsw i64 %indvars.iv16, 4
  %7 = add nuw nsw i64 %6, %4
  %8 = add nuw i64 %7, 4294967276
  %9 = and i64 %8, 4294967292
  %10 = getelementptr inbounds [640 x i8], ptr @eccblocks, i64 0, i64 %9
  %11 = load i8, ptr %10, align 4, !tbaa !5
  %12 = add nuw i64 %7, 4294967277
  %13 = and i64 %12, 4294967293
  %14 = getelementptr inbounds [640 x i8], ptr @eccblocks, i64 0, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = add nuw i64 %7, 4294967278
  %17 = and i64 %16, 4294967294
  %18 = getelementptr inbounds [640 x i8], ptr @eccblocks, i64 0, i64 %17
  %19 = load i8, ptr %18, align 2, !tbaa !5
  %20 = zext i8 %19 to i32
  %21 = zext i8 %11 to i32
  %22 = zext i8 %15 to i32
  %23 = add nuw nsw i32 %22, %21
  %24 = mul nuw nsw i32 %23, %20
  %25 = add nsw i32 %22, -3
  %26 = add nsw i32 %25, %24
  %27 = icmp ugt i32 %26, %1
  br i1 %27, label %.split.loop.exit, label %28

28:                                               ; preds = %5
  %indvars.iv.next17 = add nuw nsw i64 %indvars.iv16, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next17, 40
  br i1 %exitcond.not, label %.split.loop.exit21, label %5, !llvm.loop !8

.split.loop.exit:                                 ; preds = %5
  %29 = trunc i64 %indvars.iv16 to i8
  br label %.split.loop.exit21

.split.loop.exit21:                               ; preds = %28, %.split.loop.exit
  %.0.lcssa = phi i8 [ %29, %.split.loop.exit ], [ 40, %28 ]
  store i8 %11, ptr @neccblk1, align 1, !tbaa !5
  store i8 %15, ptr @neccblk2, align 1, !tbaa !5
  store i8 %19, ptr @datablkw, align 1, !tbaa !5
  %30 = tail call i32 @initecc(i8 noundef zeroext %0, i8 noundef zeroext %.0.lcssa)
  ret i32 %30
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass