; LLVM IR from FrancesoM/Bisc8FX :: sdk_projects/bisc8_platform/zynq_fsbl (image_mover)

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ValidateParition(i32 noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [16 x i8], align 16
  %9 = alloca [16 x i8], align 16
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %13 = load i32, ptr %7, align 4, !tbaa !5
  %14 = getelementptr inbounds [16 x i8], ptr %8, i64 0, i64 0
  %15 = call i32 @GetPartitionChecksum(i32 noundef %13, ptr noundef %14)
  store i32 %15, ptr %10, align 4, !tbaa !5
  %16 = load i32, ptr %10, align 4, !tbaa !5
  %17 = zext i32 %16 to i64
  %18 = icmp ne i64 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %3
  store i32 1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %67

20:                                               ; preds = %3
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %25, %20
  %22 = load i32, ptr %11, align 4, !tbaa !5
  %23 = icmp ult i32 %22, 16
  br i1 %23, label %24, label %28

24:                                               ; preds = %21
  br label %25

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

28:                                               ; preds = %21
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = getelementptr inbounds [16 x i8], ptr %9, i64 0, i64 0
  %32 = call i32 @CalcPartitionChecksum(i32 noundef %29, i32 noundef %30, ptr noundef %31)
  store i32 %32, ptr %10, align 4, !tbaa !5
  %33 = load i32, ptr %10, align 4, !tbaa !5
  %34 = zext i32 %33 to i64
  %35 = icmp ne i64 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %28
  store i32 1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %67

37:                                               ; preds = %28
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %42, %37
  %39 = load i32, ptr %11, align 4, !tbaa !5
  %40 = icmp ult i32 %39, 16
  br i1 %40, label %41, label %45

41:                                               ; preds = %38
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %11, align 4, !tbaa !5
  %44 = add i32 %43, 1
  store i32 %44, ptr %11, align 4, !tbaa !5
  br label %38, !llvm.loop !11

45:                                               ; preds = %38
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %63, %45
  %47 = load i32, ptr %11, align 4, !tbaa !5
  %48 = icmp ult i32 %47, 16
  br i1 %48, label %49, label %66

49:                                               ; preds = %46
  %50 = load i32, ptr %11, align 4, !tbaa !5
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds [16 x i8], ptr %8, i64 0, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !12
  %54 = zext i8 %53 to i32
  %55 = load i32, ptr %11, align 4, !tbaa !5
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds [16 x i8], ptr %9, i64 0, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !12
  %59 = zext i8 %58 to i32
  %60 = icmp ne i32 %54, %59
  br i1 %60, label %61, label %62

61:                                               ; preds = %49
  store i32 1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %67

62:                                               ; preds = %49
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %11, align 4, !tbaa !5
  %65 = add i32 %64, 1
  store i32 %65, ptr %11, align 4, !tbaa !5
  br label %46, !llvm.loop !13

66:                                               ; preds = %46
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %67

67:                                               ; preds = %66, %61, %36, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #2
  %68 = load i32, ptr %4, align 4
  ret i32 %68
}

; 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 @GetPartitionChecksum(i32 noundef, ptr noundef) #1

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

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}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !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"

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ValidateParition(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = alloca [16 x i8], align 16
  %5 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #2
  %6 = call i32 @GetPartitionChecksum(i32 noundef %2, ptr noundef nonnull %4)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %.preheader18.preheader, label %.loopexit

.preheader18.preheader:                           ; preds = %3
  %7 = call i32 @CalcPartitionChecksum(i32 noundef %0, i32 noundef %1, ptr noundef nonnull %5)
  %.not15 = icmp eq i32 %7, 0
  br i1 %.not15, label %.preheader17.preheader, label %.loopexit

.preheader17.preheader:                           ; preds = %.preheader18.preheader
  %8 = load i8, ptr %4, align 16, !tbaa !5
  %9 = load i8, ptr %5, align 16, !tbaa !5
  %.not16 = icmp eq i8 %8, %9
  br i1 %.not16, label %.preheader.1, label %.loopexit

.preheader.1:                                     ; preds = %.preheader17.preheader
  %10 = getelementptr inbounds i8, ptr %4, i64 1
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %5, i64 1
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %.not16.1 = icmp eq i8 %11, %13
  br i1 %.not16.1, label %.preheader.2, label %.loopexit

.preheader.2:                                     ; preds = %.preheader.1
  %14 = getelementptr inbounds i8, ptr %4, i64 2
  %15 = load i8, ptr %14, align 2, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %5, i64 2
  %17 = load i8, ptr %16, align 2, !tbaa !5
  %.not16.2 = icmp eq i8 %15, %17
  br i1 %.not16.2, label %.preheader.3, label %.loopexit

.preheader.3:                                     ; preds = %.preheader.2
  %18 = getelementptr inbounds i8, ptr %4, i64 3
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %5, i64 3
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %.not16.3 = icmp eq i8 %19, %21
  br i1 %.not16.3, label %.preheader.4, label %.loopexit

.preheader.4:                                     ; preds = %.preheader.3
  %22 = getelementptr inbounds i8, ptr %4, i64 4
  %23 = load i8, ptr %22, align 4, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %5, i64 4
  %25 = load i8, ptr %24, align 4, !tbaa !5
  %.not16.4 = icmp eq i8 %23, %25
  br i1 %.not16.4, label %.preheader.5, label %.loopexit

.preheader.5:                                     ; preds = %.preheader.4
  %26 = getelementptr inbounds i8, ptr %4, i64 5
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %5, i64 5
  %29 = load i8, ptr %28, align 1, !tbaa !5
  %.not16.5 = icmp eq i8 %27, %29
  br i1 %.not16.5, label %.preheader.6, label %.loopexit

.preheader.6:                                     ; preds = %.preheader.5
  %30 = getelementptr inbounds i8, ptr %4, i64 6
  %31 = load i8, ptr %30, align 2, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %5, i64 6
  %33 = load i8, ptr %32, align 2, !tbaa !5
  %.not16.6 = icmp eq i8 %31, %33
  br i1 %.not16.6, label %.preheader.7, label %.loopexit

.preheader.7:                                     ; preds = %.preheader.6
  %34 = getelementptr inbounds i8, ptr %4, i64 7
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %5, i64 7
  %37 = load i8, ptr %36, align 1, !tbaa !5
  %.not16.7 = icmp eq i8 %35, %37
  br i1 %.not16.7, label %.preheader.8, label %.loopexit

.preheader.8:                                     ; preds = %.preheader.7
  %38 = getelementptr inbounds i8, ptr %4, i64 8
  %39 = load i8, ptr %38, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %5, i64 8
  %41 = load i8, ptr %40, align 8, !tbaa !5
  %.not16.8 = icmp eq i8 %39, %41
  br i1 %.not16.8, label %.preheader.9, label %.loopexit

.preheader.9:                                     ; preds = %.preheader.8
  %42 = getelementptr inbounds i8, ptr %4, i64 9
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %5, i64 9
  %45 = load i8, ptr %44, align 1, !tbaa !5
  %.not16.9 = icmp eq i8 %43, %45
  br i1 %.not16.9, label %.preheader.10, label %.loopexit

.preheader.10:                                    ; preds = %.preheader.9
  %46 = getelementptr inbounds i8, ptr %4, i64 10
  %47 = load i8, ptr %46, align 2, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %5, i64 10
  %49 = load i8, ptr %48, align 2, !tbaa !5
  %.not16.10 = icmp eq i8 %47, %49
  br i1 %.not16.10, label %.preheader.11, label %.loopexit

.preheader.11:                                    ; preds = %.preheader.10
  %50 = getelementptr inbounds i8, ptr %4, i64 11
  %51 = load i8, ptr %50, align 1, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %5, i64 11
  %53 = load i8, ptr %52, align 1, !tbaa !5
  %.not16.11 = icmp eq i8 %51, %53
  br i1 %.not16.11, label %.preheader.12, label %.loopexit

.preheader.12:                                    ; preds = %.preheader.11
  %54 = getelementptr inbounds i8, ptr %4, i64 12
  %55 = load i8, ptr %54, align 4, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %5, i64 12
  %57 = load i8, ptr %56, align 4, !tbaa !5
  %.not16.12 = icmp eq i8 %55, %57
  br i1 %.not16.12, label %.preheader.13, label %.loopexit

.preheader.13:                                    ; preds = %.preheader.12
  %58 = getelementptr inbounds i8, ptr %4, i64 13
  %59 = load i8, ptr %58, align 1, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %5, i64 13
  %61 = load i8, ptr %60, align 1, !tbaa !5
  %.not16.13 = icmp eq i8 %59, %61
  br i1 %.not16.13, label %.preheader.14, label %.loopexit

.preheader.14:                                    ; preds = %.preheader.13
  %62 = getelementptr inbounds i8, ptr %4, i64 14
  %63 = load i8, ptr %62, align 2, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %5, i64 14
  %65 = load i8, ptr %64, align 2, !tbaa !5
  %.not16.14 = icmp eq i8 %63, %65
  br i1 %.not16.14, label %.preheader.15, label %.loopexit

.preheader.15:                                    ; preds = %.preheader.14
  %66 = getelementptr inbounds i8, ptr %4, i64 15
  %67 = load i8, ptr %66, align 1, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %5, i64 15
  %69 = load i8, ptr %68, align 1, !tbaa !5
  %.not16.15 = icmp ne i8 %67, %69
  %spec.select = zext i1 %.not16.15 to i32
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.15, %.preheader17.preheader, %.preheader.1, %.preheader.2, %.preheader.3, %.preheader.4, %.preheader.5, %.preheader.6, %.preheader.7, %.preheader.8, %.preheader.9, %.preheader.10, %.preheader.11, %.preheader.12, %.preheader.13, %.preheader.14, %.preheader18.preheader, %3
  %.014 = phi i32 [ 1, %3 ], [ 1, %.preheader18.preheader ], [ 1, %.preheader17.preheader ], [ 1, %.preheader.1 ], [ 1, %.preheader.2 ], [ 1, %.preheader.3 ], [ 1, %.preheader.4 ], [ 1, %.preheader.5 ], [ 1, %.preheader.6 ], [ 1, %.preheader.7 ], [ 1, %.preheader.8 ], [ 1, %.preheader.9 ], [ 1, %.preheader.10 ], [ 1, %.preheader.11 ], [ 1, %.preheader.12 ], [ 1, %.preheader.13 ], [ 1, %.preheader.14 ], [ %spec.select, %.preheader.15 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #2
  ret i32 %.014
}

; Function Attrs: mustprogress 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 @GetPartitionChecksum(i32 noundef, ptr noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress 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"}


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