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

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

@DcfgInstPtr = external dso_local 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: nounwind uwtable
declare dso_local i32 @ClearPcapStatus() #1

declare i32 @XDcfg_Transfer(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @PcapDumpRegisters() #1

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

declare i32 @XDcfg_IntrGetStatus(ptr noundef) #2

; 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 @PcapLoadPartition(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 1, ptr %14, align 4, !tbaa !9
  %16 = load i32, ptr %11, align 4, !tbaa !9
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %5
  store i32 2, ptr %14, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %18, %5
  %20 = call i32 @ClearPcapStatus()
  store i32 %20, ptr %12, align 4, !tbaa !9
  %21 = load i32, ptr %12, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = icmp ne i64 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %19
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %73

25:                                               ; preds = %19
  store ptr inttoptr (i64 4294967295 to ptr), ptr %8, align 8, !tbaa !5
  %26 = call i32 @FabricInit()
  store i32 %26, ptr %12, align 4, !tbaa !9
  %27 = load i32, ptr %12, align 4, !tbaa !9
  %28 = zext i32 %27 to i64
  %29 = icmp ne i64 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %25
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %73

31:                                               ; preds = %25
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = ptrtoint ptr %32 to i32
  %34 = or i32 %33, 1
  %35 = zext i32 %34 to i64
  %36 = inttoptr i64 %35 to ptr
  store ptr %36, ptr %7, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = ptrtoint ptr %37 to i32
  %39 = or i32 %38, 1
  %40 = zext i32 %39 to i64
  %41 = inttoptr i64 %40 to ptr
  store ptr %41, ptr %8, align 8, !tbaa !5
  %42 = load ptr, ptr @DcfgInstPtr, align 8, !tbaa !5
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load i32, ptr %9, align 4, !tbaa !9
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = load i32, ptr %10, align 4, !tbaa !9
  %47 = load i32, ptr %14, align 4, !tbaa !9
  %48 = call i32 @XDcfg_Transfer(ptr noundef %42, ptr noundef %43, i32 noundef %44, ptr noundef %45, i32 noundef %46, i32 noundef %47)
  store i32 %48, ptr %12, align 4, !tbaa !9
  %49 = load i32, ptr %12, align 4, !tbaa !9
  %50 = zext i32 %49 to i64
  %51 = icmp ne i64 %50, 0
  br i1 %51, label %52, label %53

52:                                               ; preds = %31
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %73

53:                                               ; preds = %31
  call void @PcapDumpRegisters()
  %54 = call i32 @XDcfgPollDone(i32 noundef 8192, i32 noundef 1000000000)
  store i32 %54, ptr %12, align 4, !tbaa !9
  %55 = load i32, ptr %12, align 4, !tbaa !9
  %56 = zext i32 %55 to i64
  %57 = icmp ne i64 %56, 0
  br i1 %57, label %58, label %59

58:                                               ; preds = %53
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %73

59:                                               ; preds = %53
  %60 = call i32 @XDcfgPollDone(i32 noundef 4, i32 noundef 1000000000)
  store i32 %60, ptr %12, align 4, !tbaa !9
  %61 = load i32, ptr %12, align 4, !tbaa !9
  %62 = zext i32 %61 to i64
  %63 = icmp ne i64 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %59
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %73

65:                                               ; preds = %59
  %66 = load ptr, ptr @DcfgInstPtr, align 8, !tbaa !5
  %67 = call i32 @XDcfg_IntrGetStatus(ptr noundef %66)
  store i32 %67, ptr %13, align 4, !tbaa !9
  %68 = load i32, ptr %13, align 4, !tbaa !9
  %69 = and i32 %68, 7653440
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %72

71:                                               ; preds = %65
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %73

72:                                               ; preds = %65
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %73

73:                                               ; preds = %72, %71, %64, %58, %52, %30, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %74 = load i32, ptr %6, align 4
  ret i32 %74
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @FabricInit() #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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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"

@DcfgInstPtr = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
declare dso_local i32 @ClearPcapStatus() local_unnamed_addr #0

declare i32 @XDcfg_Transfer(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @PcapDumpRegisters() local_unnamed_addr #0

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

declare i32 @XDcfg_IntrGetStatus(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @PcapLoadPartition(ptr noundef %0, ptr nocapture noundef readnone %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %.not = icmp eq i32 %4, 0
  %spec.store.select = select i1 %.not, i32 1, i32 2
  %6 = tail call i32 @ClearPcapStatus()
  %.not14 = icmp eq i32 %6, 0
  br i1 %.not14, label %7, label %24

7:                                                ; preds = %5
  %8 = tail call i32 @FabricInit()
  %.not15 = icmp eq i32 %8, 0
  br i1 %.not15, label %9, label %24

9:                                                ; preds = %7
  %10 = ptrtoint ptr %0 to i64
  %11 = and i64 %10, 4294967294
  %12 = or disjoint i64 %11, 1
  %13 = inttoptr i64 %12 to ptr
  %14 = load ptr, ptr @DcfgInstPtr, align 8, !tbaa !5
  %15 = tail call i32 @XDcfg_Transfer(ptr noundef %14, ptr noundef nonnull %13, i32 noundef %2, ptr noundef nonnull inttoptr (i64 4294967295 to ptr), i32 noundef %3, i32 noundef %spec.store.select) #2
  %.not16 = icmp eq i32 %15, 0
  br i1 %.not16, label %16, label %24

16:                                               ; preds = %9
  tail call void @PcapDumpRegisters()
  %17 = tail call i32 @XDcfgPollDone(i32 noundef 8192, i32 noundef 1000000000)
  %.not17 = icmp eq i32 %17, 0
  br i1 %.not17, label %18, label %24

18:                                               ; preds = %16
  %19 = tail call i32 @XDcfgPollDone(i32 noundef 4, i32 noundef 1000000000)
  %.not18 = icmp eq i32 %19, 0
  br i1 %.not18, label %20, label %24

20:                                               ; preds = %18
  %21 = load ptr, ptr @DcfgInstPtr, align 8, !tbaa !5
  %22 = tail call i32 @XDcfg_IntrGetStatus(ptr noundef %21) #2
  %23 = and i32 %22, 7653440
  %.not19 = icmp ne i32 %23, 0
  %. = zext i1 %.not19 to i32
  br label %24

24:                                               ; preds = %20, %18, %16, %9, %7, %5
  %.0 = phi i32 [ 1, %5 ], [ 1, %7 ], [ 1, %9 ], [ 1, %16 ], [ 1, %18 ], [ %., %20 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @FabricInit() local_unnamed_addr #0

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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass