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

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

@MoveImage = external global ptr, align 8

; 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
define dso_local i32 @HeaderChecksum(i32 noundef %0) #1 {
  %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
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %23, %1
  %9 = load i32, ptr %5, align 4, !tbaa !5
  %10 = icmp ult i32 %9, 10
  br i1 %10, label %11, label %26

11:                                               ; preds = %8
  %12 = load ptr, ptr @MoveImage, align 8, !tbaa !9
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = add i32 %13, 32
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = mul i32 %15, 4
  %17 = add i32 %14, %16
  %18 = ptrtoint ptr %6 to i32
  %19 = call i32 %12(i32 noundef %17, i32 noundef %18, i32 noundef 4)
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = add i32 %21, %20
  store i32 %22, ptr %4, align 4, !tbaa !5
  br label %23

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

26:                                               ; preds = %8
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = xor i32 %27, -1
  store i32 %28, ptr %4, align 4, !tbaa !5
  %29 = load ptr, ptr @MoveImage, align 8, !tbaa !9
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = add i32 %30, 72
  %32 = ptrtoint ptr %6 to i32
  %33 = call i32 %29(i32 noundef %31, i32 noundef %32, i32 noundef 4)
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = icmp ne i32 %34, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %26
  store i32 1, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %39

38:                                               ; preds = %26
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %39

39:                                               ; preds = %38, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %40 = load i32, ptr %2, align 4
  ret i32 %40
}

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

@MoveImage = external local_unnamed_addr global ptr, align 8

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

; 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
define dso_local range(i32 0, 2) i32 @HeaderChecksum(i32 noundef %0) local_unnamed_addr #1 {
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #2
  store i32 0, ptr %2, align 4, !tbaa !5
  %3 = add i32 %0, 32
  %4 = ptrtoint ptr %2 to i64
  %5 = trunc i64 %4 to i32
  %6 = load ptr, ptr @MoveImage, align 8, !tbaa !9
  %7 = call i32 %6(i32 noundef %3, i32 noundef %5, i32 noundef 4) #2
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = load ptr, ptr @MoveImage, align 8, !tbaa !9
  %10 = add i32 %0, 36
  %11 = call i32 %9(i32 noundef %10, i32 noundef %5, i32 noundef 4) #2
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = add i32 %12, %8
  %14 = load ptr, ptr @MoveImage, align 8, !tbaa !9
  %15 = add i32 %0, 40
  %16 = call i32 %14(i32 noundef %15, i32 noundef %5, i32 noundef 4) #2
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = add i32 %17, %13
  %19 = load ptr, ptr @MoveImage, align 8, !tbaa !9
  %20 = add i32 %0, 44
  %21 = call i32 %19(i32 noundef %20, i32 noundef %5, i32 noundef 4) #2
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = add i32 %22, %18
  %24 = load ptr, ptr @MoveImage, align 8, !tbaa !9
  %25 = add i32 %0, 48
  %26 = call i32 %24(i32 noundef %25, i32 noundef %5, i32 noundef 4) #2
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = add i32 %27, %23
  %29 = load ptr, ptr @MoveImage, align 8, !tbaa !9
  %30 = add i32 %0, 52
  %31 = call i32 %29(i32 noundef %30, i32 noundef %5, i32 noundef 4) #2
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = add i32 %32, %28
  %34 = load ptr, ptr @MoveImage, align 8, !tbaa !9
  %35 = add i32 %0, 56
  %36 = call i32 %34(i32 noundef %35, i32 noundef %5, i32 noundef 4) #2
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = add i32 %37, %33
  %39 = load ptr, ptr @MoveImage, align 8, !tbaa !9
  %40 = add i32 %0, 60
  %41 = call i32 %39(i32 noundef %40, i32 noundef %5, i32 noundef 4) #2
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = add i32 %42, %38
  %44 = load ptr, ptr @MoveImage, align 8, !tbaa !9
  %45 = add i32 %0, 64
  %46 = call i32 %44(i32 noundef %45, i32 noundef %5, i32 noundef 4) #2
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = add i32 %47, %43
  %49 = load ptr, ptr @MoveImage, align 8, !tbaa !9
  %50 = add i32 %0, 68
  %51 = call i32 %49(i32 noundef %50, i32 noundef %5, i32 noundef 4) #2
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = add i32 %52, %48
  %54 = load ptr, ptr @MoveImage, align 8, !tbaa !9
  %55 = add i32 %0, 72
  %56 = call i32 %54(i32 noundef %55, i32 noundef %5, i32 noundef 4) #2
  %57 = load i32, ptr %2, align 4, !tbaa !5
  %58 = xor i32 %57, %53
  %.not = icmp ne i32 %58, -1
  %. = zext i1 %.not to i32
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #2
  ret i32 %.
}

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 = !{!"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: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass