; 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: nounwind uwtable
define dso_local i32 @PcapDataTransfer(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %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 5, 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 4, 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 %61

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

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

47:                                               ; preds = %25
  call void @PcapDumpRegisters()
  %48 = call i32 @XDcfgPollDone(i32 noundef 8192, i32 noundef 1000000000)
  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 = %47
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %61

53:                                               ; preds = %47
  %54 = load ptr, ptr @DcfgInstPtr, align 8, !tbaa !5
  %55 = call i32 @XDcfg_IntrGetStatus(ptr noundef %54)
  store i32 %55, ptr %13, align 4, !tbaa !9
  %56 = load i32, ptr %13, align 4, !tbaa !9
  %57 = and i32 %56, 7653440
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %60

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

60:                                               ; preds = %53
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %61

61:                                               ; preds = %60, %59, %52, %46, %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
  %62 = load i32, ptr %6, align 4
  ret i32 %62
}

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

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

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() #0

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

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) #1

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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
define dso_local range(i32 0, 2) i32 @PcapDataTransfer(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = tail call i32 @ClearPcapStatus()
  %.not12 = icmp eq i32 %6, 0
  br i1 %.not12, label %7, label %24

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

18:                                               ; preds = %7
  tail call void @PcapDumpRegisters()
  %19 = tail call i32 @XDcfgPollDone(i32 noundef 8192, i32 noundef 1000000000)
  %.not14 = icmp eq i32 %19, 0
  br i1 %.not14, 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
  %.not15 = icmp ne i32 %23, 0
  %. = zext i1 %.not15 to i32
  br label %24

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

; 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

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: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass