; LLVM IR from lfarcaro/ARINC653_ARMV7A_AM335X :: ARINC653_PORT (ethernet)

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

%struct._ETHERNET_CPSW_INSTANCE = type { i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, [1 x %struct._ETHERNET_CPSW_PORT] }
%struct._ETHERNET_CPSW_PORT = type { i8, i32, i32, i32, i8, i32, i32 }
%struct._ETHERNET_CPDMA_BUFFERDESCRIPTOR = type { ptr, i32, i32, i32 }

@ETHERNET_CPSW_INSTANCES = external hidden global [1 x %struct._ETHERNET_CPSW_INSTANCE], align 16
@ETHERNET_POLLING_MODE = external hidden 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

declare void @ETHERNET_HOOK_YIELD() #1

declare void @ETHERNET_HOOK_DELAY(i32 noundef) #1

declare void @CPSWCPDMARxHdrDescPtrWrite(i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ETHERNET_RECEIVEPACKET(i32 noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i8 noundef zeroext %5) #2 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i8, align 1
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store i32 %0, ptr %8, align 4, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !5
  store i32 %4, ptr %12, align 4, !tbaa !5
  store i8 %5, ptr %13, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %21 = load i8, ptr @ETHERNET_POLLING_MODE, align 1, !tbaa !11
  %22 = icmp ne i8 %21, 0
  br i1 %22, label %24, label %23

23:                                               ; preds = %6
  store i32 0, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %183

24:                                               ; preds = %6
  %25 = load i32, ptr %8, align 4, !tbaa !5
  %26 = icmp uge i32 %25, 1
  br i1 %26, label %27, label %28

27:                                               ; preds = %24
  store i32 0, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %183

28:                                               ; preds = %24
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds [1 x %struct._ETHERNET_CPSW_INSTANCE], ptr @ETHERNET_CPSW_INSTANCES, i64 0, i64 %30
  store ptr %31, ptr %14, align 8, !tbaa !9
  %32 = load ptr, ptr %14, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %32, i32 0, i32 0
  %34 = load i8, ptr %33, align 8, !tbaa !12
  %35 = icmp ne i8 %34, 0
  br i1 %35, label %37, label %36

36:                                               ; preds = %28
  store i32 0, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %183

37:                                               ; preds = %28
  %38 = load i32, ptr %12, align 4, !tbaa !5
  %39 = icmp uge i32 %38, 10
  br i1 %39, label %40, label %43

40:                                               ; preds = %37
  %41 = load i32, ptr %12, align 4, !tbaa !5
  %42 = udiv i32 %41, 10
  br label %44

43:                                               ; preds = %37
  br label %44

44:                                               ; preds = %43, %40
  %45 = phi i32 [ %42, %40 ], [ 0, %43 ]
  store i32 %45, ptr %19, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %64, %44
  br label %47

47:                                               ; preds = %46
  call void @ETHERNET_HOOK_DELAY(i32 noundef 10)
  %48 = load ptr, ptr %14, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %48, i32 0, i32 4
  %50 = load i32, ptr %49, align 8, !tbaa !14
  %51 = call i32 @CPSWCPDMARxIntStatRawGet(i32 noundef %50, i32 noundef 1, i32 noundef 0)
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %47
  br label %65

54:                                               ; preds = %47
  %55 = load i32, ptr %19, align 4, !tbaa !5
  %56 = icmp ugt i32 %55, 0
  br i1 %56, label %57, label %64

57:                                               ; preds = %54
  %58 = load i32, ptr %19, align 4, !tbaa !5
  %59 = add i32 %58, -1
  store i32 %59, ptr %19, align 4, !tbaa !5
  %60 = load i32, ptr %19, align 4, !tbaa !5
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %63

62:                                               ; preds = %57
  store i32 0, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %183

63:                                               ; preds = %57
  br label %64

64:                                               ; preds = %63, %54
  call void @ETHERNET_HOOK_YIELD()
  br label %46

65:                                               ; preds = %53
  %66 = load i8, ptr %13, align 1, !tbaa !11
  %67 = icmp ne i8 %66, 0
  br i1 %67, label %68, label %69

68:                                               ; preds = %65
  call void @ETHERNET_HOOK_ENTERCRITICALSECTION()
  br label %69

69:                                               ; preds = %68, %65
  %70 = load ptr, ptr %14, align 8, !tbaa !9
  %71 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %70, i32 0, i32 14
  %72 = load ptr, ptr %71, align 8, !tbaa !15
  store ptr %72, ptr %15, align 8, !tbaa !9
  %73 = load ptr, ptr %15, align 8, !tbaa !9
  %74 = getelementptr inbounds %struct._ETHERNET_CPDMA_BUFFERDESCRIPTOR, ptr %73, i32 0, i32 3
  %75 = load volatile i32, ptr %74, align 8, !tbaa !16
  %76 = and i32 %75, 536870912
  %77 = icmp eq i32 %76, 536870912
  br i1 %77, label %78, label %83

78:                                               ; preds = %69
  %79 = load i8, ptr %13, align 1, !tbaa !11
  %80 = icmp ne i8 %79, 0
  br i1 %80, label %81, label %82

81:                                               ; preds = %78
  call void @ETHERNET_HOOK_EXITCRITICALSECTION()
  br label %82

82:                                               ; preds = %81, %78
  store i32 0, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %183

83:                                               ; preds = %69
  %84 = load ptr, ptr %15, align 8, !tbaa !9
  %85 = getelementptr inbounds %struct._ETHERNET_CPDMA_BUFFERDESCRIPTOR, ptr %84, i32 0, i32 3
  %86 = load volatile i32, ptr %85, align 8, !tbaa !16
  %87 = and i32 %86, 458752
  %88 = lshr i32 %87, 16
  %89 = load ptr, ptr %9, align 8, !tbaa !9
  store i32 %88, ptr %89, align 4, !tbaa !5
  %90 = load ptr, ptr %15, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct._ETHERNET_CPDMA_BUFFERDESCRIPTOR, ptr %90, i32 0, i32 3
  %92 = load volatile i32, ptr %91, align 8, !tbaa !16
  %93 = and i32 %92, 2047
  store i32 %93, ptr %17, align 4, !tbaa !5
  %94 = load ptr, ptr %15, align 8, !tbaa !9
  %95 = getelementptr inbounds %struct._ETHERNET_CPDMA_BUFFERDESCRIPTOR, ptr %94, i32 0, i32 3
  %96 = load volatile i32, ptr %95, align 8, !tbaa !16
  %97 = and i32 %96, 67108864
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %102

99:                                               ; preds = %83
  %100 = load i32, ptr %17, align 4, !tbaa !5
  %101 = sub i32 %100, 4
  store i32 %101, ptr %17, align 4, !tbaa !5
  br label %102

102:                                              ; preds = %99, %83
  %103 = load i32, ptr %17, align 4, !tbaa !5
  %104 = load i32, ptr %11, align 4, !tbaa !5
  %105 = icmp ule i32 %103, %104
  br i1 %105, label %106, label %138

106:                                              ; preds = %102
  %107 = load ptr, ptr %15, align 8, !tbaa !9
  %108 = getelementptr inbounds %struct._ETHERNET_CPDMA_BUFFERDESCRIPTOR, ptr %107, i32 0, i32 3
  %109 = load volatile i32, ptr %108, align 8, !tbaa !16
  %110 = and i32 %109, -1073741824
  %111 = icmp eq i32 %110, -1073741824
  br i1 %111, label %112, label %136

112:                                              ; preds = %106
  %113 = load ptr, ptr %15, align 8, !tbaa !9
  %114 = getelementptr inbounds %struct._ETHERNET_CPDMA_BUFFERDESCRIPTOR, ptr %113, i32 0, i32 1
  %115 = load volatile i32, ptr %114, align 8, !tbaa !18
  %116 = zext i32 %115 to i64
  %117 = inttoptr i64 %116 to ptr
  store ptr %117, ptr %16, align 8, !tbaa !9
  store i32 0, ptr %18, align 4, !tbaa !5
  br label %118

118:                                              ; preds = %132, %112
  %119 = load i32, ptr %18, align 4, !tbaa !5
  %120 = load i32, ptr %17, align 4, !tbaa !5
  %121 = icmp ult i32 %119, %120
  br i1 %121, label %122, label %135

122:                                              ; preds = %118
  %123 = load ptr, ptr %16, align 8, !tbaa !9
  %124 = load i32, ptr %18, align 4, !tbaa !5
  %125 = zext i32 %124 to i64
  %126 = getelementptr inbounds i8, ptr %123, i64 %125
  %127 = load i8, ptr %126, align 1, !tbaa !11
  %128 = load ptr, ptr %10, align 8, !tbaa !9
  %129 = load i32, ptr %18, align 4, !tbaa !5
  %130 = zext i32 %129 to i64
  %131 = getelementptr inbounds i8, ptr %128, i64 %130
  store i8 %127, ptr %131, align 1, !tbaa !11
  br label %132

132:                                              ; preds = %122
  %133 = load i32, ptr %18, align 4, !tbaa !5
  %134 = add i32 %133, 1
  store i32 %134, ptr %18, align 4, !tbaa !5
  br label %118, !llvm.loop !19

135:                                              ; preds = %118
  br label %137

136:                                              ; preds = %106
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %137

137:                                              ; preds = %136, %135
  br label %139

138:                                              ; preds = %102
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %139

139:                                              ; preds = %138, %137
  %140 = load ptr, ptr %15, align 8, !tbaa !9
  %141 = getelementptr inbounds %struct._ETHERNET_CPDMA_BUFFERDESCRIPTOR, ptr %140, i32 0, i32 2
  store volatile i32 1514, ptr %141, align 4, !tbaa !21
  %142 = load ptr, ptr %15, align 8, !tbaa !9
  %143 = getelementptr inbounds %struct._ETHERNET_CPDMA_BUFFERDESCRIPTOR, ptr %142, i32 0, i32 3
  store volatile i32 536870912, ptr %143, align 8, !tbaa !16
  %144 = load ptr, ptr %14, align 8, !tbaa !9
  %145 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %144, i32 0, i32 4
  %146 = load i32, ptr %145, align 8, !tbaa !14
  %147 = load ptr, ptr %15, align 8, !tbaa !9
  %148 = ptrtoint ptr %147 to i32
  call void @CPSWCPDMARxCPWrite(i32 noundef %146, i32 noundef 0, i32 noundef %148)
  %149 = load ptr, ptr %15, align 8, !tbaa !9
  %150 = load ptr, ptr %14, align 8, !tbaa !9
  %151 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %150, i32 0, i32 15
  %152 = load ptr, ptr %151, align 8, !tbaa !22
  %153 = getelementptr inbounds %struct._ETHERNET_CPDMA_BUFFERDESCRIPTOR, ptr %152, i32 0, i32 0
  store volatile ptr %149, ptr %153, align 8, !tbaa !23
  %154 = load ptr, ptr %15, align 8, !tbaa !9
  %155 = load ptr, ptr %14, align 8, !tbaa !9
  %156 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %155, i32 0, i32 15
  store ptr %154, ptr %156, align 8, !tbaa !22
  %157 = load ptr, ptr %15, align 8, !tbaa !9
  %158 = getelementptr inbounds %struct._ETHERNET_CPDMA_BUFFERDESCRIPTOR, ptr %157, i32 0, i32 0
  %159 = load volatile ptr, ptr %158, align 8, !tbaa !23
  %160 = load ptr, ptr %14, align 8, !tbaa !9
  %161 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %160, i32 0, i32 14
  store ptr %159, ptr %161, align 8, !tbaa !15
  %162 = load ptr, ptr %15, align 8, !tbaa !9
  %163 = getelementptr inbounds %struct._ETHERNET_CPDMA_BUFFERDESCRIPTOR, ptr %162, i32 0, i32 0
  store volatile ptr null, ptr %163, align 8, !tbaa !23
  %164 = load ptr, ptr %14, align 8, !tbaa !9
  %165 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %164, i32 0, i32 4
  %166 = load i32, ptr %165, align 8, !tbaa !14
  %167 = call i32 @CPSWCPDMARxHdrDescPtrRead(i32 noundef %166, i32 noundef 0)
  %168 = icmp eq i32 %167, 0
  br i1 %168, label %169, label %177

169:                                              ; preds = %139
  %170 = load ptr, ptr %14, align 8, !tbaa !9
  %171 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %170, i32 0, i32 4
  %172 = load i32, ptr %171, align 8, !tbaa !14
  %173 = load ptr, ptr %14, align 8, !tbaa !9
  %174 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %173, i32 0, i32 15
  %175 = load ptr, ptr %174, align 8, !tbaa !22
  %176 = ptrtoint ptr %175 to i32
  call void @CPSWCPDMARxHdrDescPtrWrite(i32 noundef %172, i32 noundef %176, i32 noundef 0)
  br label %177

177:                                              ; preds = %169, %139
  %178 = load i8, ptr %13, align 1, !tbaa !11
  %179 = icmp ne i8 %178, 0
  br i1 %179, label %180, label %181

180:                                              ; preds = %177
  call void @ETHERNET_HOOK_EXITCRITICALSECTION()
  br label %181

181:                                              ; preds = %180, %177
  %182 = load i32, ptr %17, align 4, !tbaa !5
  store i32 %182, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %183

183:                                              ; preds = %181, %82, %62, %36, %27, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %184 = load i32, ptr %7, align 4
  ret i32 %184
}

declare i32 @CPSWCPDMARxIntStatRawGet(i32 noundef, i32 noundef, i32 noundef) #1

declare void @ETHERNET_HOOK_ENTERCRITICALSECTION() #1

declare void @ETHERNET_HOOK_EXITCRITICALSECTION() #1

declare void @CPSWCPDMARxCPWrite(i32 noundef, i32 noundef, i32 noundef) #1

declare i32 @CPSWCPDMARxHdrDescPtrRead(i32 noundef, i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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 = !{!"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 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"_ETHERNET_CPSW_INSTANCE", !7, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !7, i64 88}
!14 = !{!13, !6, i64 16}
!15 = !{!13, !10, i64 72}
!16 = !{!17, !6, i64 16}
!17 = !{!"_ETHERNET_CPDMA_BUFFERDESCRIPTOR", !10, i64 0, !6, i64 8, !6, i64 12, !6, i64 16}
!18 = !{!17, !6, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!17, !6, i64 12}
!22 = !{!13, !10, i64 80}
!23 = !{!17, !10, 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"

%struct._ETHERNET_CPSW_INSTANCE = type { i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, [1 x %struct._ETHERNET_CPSW_PORT] }
%struct._ETHERNET_CPSW_PORT = type { i8, i32, i32, i32, i8, i32, i32 }

@ETHERNET_CPSW_INSTANCES = external hidden local_unnamed_addr global [1 x %struct._ETHERNET_CPSW_INSTANCE], align 16
@ETHERNET_POLLING_MODE = external hidden local_unnamed_addr global i8, align 1

declare void @ETHERNET_HOOK_YIELD() local_unnamed_addr #0

declare void @ETHERNET_HOOK_DELAY(i32 noundef) local_unnamed_addr #0

declare void @CPSWCPDMARxHdrDescPtrWrite(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @ETHERNET_RECEIVEPACKET(i32 noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2, i32 noundef %3, i32 noundef %4, i8 noundef zeroext %5) local_unnamed_addr #1 {
  %7 = ptrtoint ptr %2 to i64
  %8 = load i8, ptr @ETHERNET_POLLING_MODE, align 1, !tbaa !5
  %.not = icmp eq i8 %8, 0
  %.not52 = icmp ne i32 %0, 0
  %or.cond.not63 = or i1 %.not52, %.not
  %9 = load i8, ptr @ETHERNET_CPSW_INSTANCES, align 16
  %.not53 = icmp eq i8 %9, 0
  %or.cond60 = select i1 %or.cond.not63, i1 true, i1 %.not53
  br i1 %or.cond60, label %.loopexit64, label %10

10:                                               ; preds = %6
  tail call void @ETHERNET_HOOK_DELAY(i32 noundef 10) #2
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 16), align 16, !tbaa !8
  %12 = tail call i32 @CPSWCPDMARxIntStatRawGet(i32 noundef %11, i32 noundef 1, i32 noundef 0) #2
  %.not5465 = icmp eq i32 %12, 0
  br i1 %.not5465, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %10
  %13 = udiv i32 %4, 10
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %17
  %.066 = phi i32 [ %.1, %17 ], [ %13, %.lr.ph.preheader ]
  %.not55 = icmp eq i32 %.066, 0
  br i1 %.not55, label %17, label %14

14:                                               ; preds = %.lr.ph
  %15 = add nsw i32 %.066, -1
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %.loopexit64, label %17

17:                                               ; preds = %14, %.lr.ph
  %.1 = phi i32 [ %15, %14 ], [ 0, %.lr.ph ]
  tail call void @ETHERNET_HOOK_YIELD() #2
  tail call void @ETHERNET_HOOK_DELAY(i32 noundef 10) #2
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 16), align 16, !tbaa !8
  %19 = tail call i32 @CPSWCPDMARxIntStatRawGet(i32 noundef %18, i32 noundef 1, i32 noundef 0) #2
  %.not54 = icmp eq i32 %19, 0
  br i1 %.not54, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %17, %10
  %.not56 = icmp eq i8 %5, 0
  br i1 %.not56, label %20, label %.thread

20:                                               ; preds = %._crit_edge
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 72), align 8, !tbaa !12
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  %23 = load volatile i32, ptr %22, align 8, !tbaa !13
  %24 = and i32 %23, 536870912
  %.not57 = icmp eq i32 %24, 0
  br i1 %.not57, label %29, label %.loopexit64

.thread:                                          ; preds = %._crit_edge
  tail call void @ETHERNET_HOOK_ENTERCRITICALSECTION() #2
  %25 = load ptr, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 72), align 8, !tbaa !12
  %26 = getelementptr inbounds i8, ptr %25, i64 16
  %27 = load volatile i32, ptr %26, align 8, !tbaa !13
  %28 = and i32 %27, 536870912
  %.not5761 = icmp eq i32 %28, 0
  br i1 %.not5761, label %29, label %.loopexit64.sink.split

29:                                               ; preds = %.thread, %20
  %30 = phi ptr [ %26, %.thread ], [ %22, %20 ]
  %31 = phi ptr [ %25, %.thread ], [ %21, %20 ]
  %32 = load volatile i32, ptr %30, align 8, !tbaa !13
  %33 = lshr i32 %32, 16
  %34 = and i32 %33, 7
  store i32 %34, ptr %1, align 4, !tbaa !15
  %35 = load volatile i32, ptr %30, align 8, !tbaa !13
  %36 = and i32 %35, 2047
  %37 = load volatile i32, ptr %30, align 8, !tbaa !13
  %38 = and i32 %37, 67108864
  %.not58 = icmp eq i32 %38, 0
  %39 = add nsw i32 %36, -4
  %spec.select = select i1 %.not58, i32 %36, i32 %39
  %.not59 = icmp ugt i32 %spec.select, %3
  br i1 %.not59, label %.loopexit, label %40

40:                                               ; preds = %29
  %41 = load volatile i32, ptr %30, align 8, !tbaa !13
  %42 = icmp ugt i32 %41, -1073741825
  br i1 %42, label %43, label %.loopexit

43:                                               ; preds = %40
  %44 = getelementptr inbounds i8, ptr %31, i64 8
  %45 = load volatile i32, ptr %44, align 8, !tbaa !16
  %46 = zext i32 %45 to i64
  %47 = inttoptr i64 %46 to ptr
  %.not70 = icmp eq i32 %spec.select, 0
  br i1 %.not70, label %.loopexit, label %iter.check

iter.check:                                       ; preds = %43
  %wide.trip.count = zext i32 %spec.select to i64
  %min.iters.check = icmp ult i32 %spec.select, 8
  %48 = sub i64 %7, %46
  %diff.check = icmp ult i64 %48, 32
  %or.cond = select i1 %min.iters.check, i1 true, i1 %diff.check
  br i1 %or.cond, label %.lr.ph69.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %iter.check
  %min.iters.check72 = icmp ult i32 %spec.select, 32
  br i1 %min.iters.check72, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %n.vec = and i64 %wide.trip.count, 4294967264
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %49 = getelementptr inbounds i8, ptr %47, i64 %index
  %50 = getelementptr inbounds i8, ptr %49, i64 16
  %wide.load = load <16 x i8>, ptr %49, align 1, !tbaa !5
  %wide.load73 = load <16 x i8>, ptr %50, align 1, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %2, i64 %index
  %52 = getelementptr inbounds i8, ptr %51, i64 16
  store <16 x i8> %wide.load, ptr %51, align 1, !tbaa !5
  store <16 x i8> %wide.load73, ptr %52, align 1, !tbaa !5
  %index.next = add nuw i64 %index, 32
  %53 = icmp eq i64 %index.next, %n.vec
  br i1 %53, label %middle.block, label %vector.body, !llvm.loop !17

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.loopexit, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  %n.vec.remaining = and i64 %wide.trip.count, 24
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  br i1 %min.epilog.iters.check, label %.lr.ph69.preheader, label %vec.epilog.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.vec75 = and i64 %wide.trip.count, 4294967288
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index76 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next78, %vec.epilog.vector.body ]
  %54 = getelementptr inbounds i8, ptr %47, i64 %index76
  %wide.load77 = load <8 x i8>, ptr %54, align 1, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %2, i64 %index76
  store <8 x i8> %wide.load77, ptr %55, align 1, !tbaa !5
  %index.next78 = add nuw i64 %index76, 8
  %56 = icmp eq i64 %index.next78, %n.vec75
  br i1 %56, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !21

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n79 = icmp eq i64 %n.vec75, %wide.trip.count
  br i1 %cmp.n79, label %.loopexit, label %.lr.ph69.preheader

.lr.ph69.preheader:                               ; preds = %vec.epilog.middle.block, %iter.check, %vec.epilog.iter.check
  %indvars.iv.ph = phi i64 [ 0, %iter.check ], [ %n.vec, %vec.epilog.iter.check ], [ %n.vec75, %vec.epilog.middle.block ]
  %xtraiter = and i64 %wide.trip.count, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph69.prol.loopexit, label %.lr.ph69.prol

.lr.ph69.prol:                                    ; preds = %.lr.ph69.preheader, %.lr.ph69.prol
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %.lr.ph69.prol ], [ %indvars.iv.ph, %.lr.ph69.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph69.prol ], [ 0, %.lr.ph69.preheader ]
  %57 = getelementptr inbounds i8, ptr %47, i64 %indvars.iv.prol
  %58 = load i8, ptr %57, align 1, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %2, i64 %indvars.iv.prol
  store i8 %58, ptr %59, align 1, !tbaa !5
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph69.prol.loopexit, label %.lr.ph69.prol, !llvm.loop !22

.lr.ph69.prol.loopexit:                           ; preds = %.lr.ph69.prol, %.lr.ph69.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %.lr.ph69.preheader ], [ %indvars.iv.next.prol, %.lr.ph69.prol ]
  %60 = sub nsw i64 %indvars.iv.ph, %wide.trip.count
  %61 = icmp ugt i64 %60, -4
  br i1 %61, label %.loopexit, label %.lr.ph69

.lr.ph69:                                         ; preds = %.lr.ph69.prol.loopexit, %.lr.ph69
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %.lr.ph69 ], [ %indvars.iv.unr, %.lr.ph69.prol.loopexit ]
  %62 = getelementptr inbounds i8, ptr %47, i64 %indvars.iv
  %63 = load i8, ptr %62, align 1, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %2, i64 %indvars.iv
  store i8 %63, ptr %64, align 1, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %65 = getelementptr inbounds i8, ptr %47, i64 %indvars.iv.next
  %66 = load i8, ptr %65, align 1, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %2, i64 %indvars.iv.next
  store i8 %66, ptr %67, align 1, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %68 = getelementptr inbounds i8, ptr %47, i64 %indvars.iv.next.1
  %69 = load i8, ptr %68, align 1, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %2, i64 %indvars.iv.next.1
  store i8 %69, ptr %70, align 1, !tbaa !5
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %71 = getelementptr inbounds i8, ptr %47, i64 %indvars.iv.next.2
  %72 = load i8, ptr %71, align 1, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %2, i64 %indvars.iv.next.2
  store i8 %72, ptr %73, align 1, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, %wide.trip.count
  br i1 %exitcond.not.3, label %.loopexit, label %.lr.ph69, !llvm.loop !24

.loopexit:                                        ; preds = %.lr.ph69.prol.loopexit, %.lr.ph69, %middle.block, %vec.epilog.middle.block, %43, %29, %40
  %.147 = phi i32 [ 0, %40 ], [ 0, %29 ], [ 0, %43 ], [ %spec.select, %vec.epilog.middle.block ], [ %spec.select, %middle.block ], [ %spec.select, %.lr.ph69 ], [ %spec.select, %.lr.ph69.prol.loopexit ]
  %74 = getelementptr inbounds i8, ptr %31, i64 12
  store volatile i32 1514, ptr %74, align 4, !tbaa !25
  store volatile i32 536870912, ptr %30, align 8, !tbaa !13
  %75 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 16), align 16, !tbaa !8
  %76 = ptrtoint ptr %31 to i64
  %77 = trunc i64 %76 to i32
  tail call void @CPSWCPDMARxCPWrite(i32 noundef %75, i32 noundef 0, i32 noundef %77) #2
  %78 = load ptr, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 80), align 16, !tbaa !26
  store volatile ptr %31, ptr %78, align 8, !tbaa !27
  store ptr %31, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 80), align 16, !tbaa !26
  %79 = load volatile ptr, ptr %31, align 8, !tbaa !27
  store ptr %79, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 72), align 8, !tbaa !12
  store volatile ptr null, ptr %31, align 8, !tbaa !27
  %80 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 16), align 16, !tbaa !8
  %81 = tail call i32 @CPSWCPDMARxHdrDescPtrRead(i32 noundef %80, i32 noundef 0) #2
  %82 = icmp eq i32 %81, 0
  br i1 %82, label %83, label %88

83:                                               ; preds = %.loopexit
  %84 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 16), align 16, !tbaa !8
  %85 = load ptr, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 80), align 16, !tbaa !26
  %86 = ptrtoint ptr %85 to i64
  %87 = trunc i64 %86 to i32
  tail call void @CPSWCPDMARxHdrDescPtrWrite(i32 noundef %84, i32 noundef %87, i32 noundef 0) #2
  br label %88

88:                                               ; preds = %83, %.loopexit
  br i1 %.not56, label %.loopexit64, label %.loopexit64.sink.split

.loopexit64.sink.split:                           ; preds = %88, %.thread
  %.048.ph = phi i32 [ 0, %.thread ], [ %.147, %88 ]
  tail call void @ETHERNET_HOOK_EXITCRITICALSECTION() #2
  br label %.loopexit64

.loopexit64:                                      ; preds = %14, %.loopexit64.sink.split, %20, %88, %6
  %.048 = phi i32 [ 0, %6 ], [ %.147, %88 ], [ 0, %20 ], [ %.048.ph, %.loopexit64.sink.split ], [ 0, %14 ]
  ret i32 %.048
}

declare i32 @CPSWCPDMARxIntStatRawGet(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare void @ETHERNET_HOOK_ENTERCRITICALSECTION() local_unnamed_addr #0

declare void @ETHERNET_HOOK_EXITCRITICALSECTION() local_unnamed_addr #0

declare void @CPSWCPDMARxCPWrite(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare i32 @CPSWCPDMARxHdrDescPtrRead(i32 noundef, i32 noundef) local_unnamed_addr #0

attributes #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 = { 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, !10, i64 16}
!9 = !{!"_ETHERNET_CPSW_INSTANCE", !6, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !6, i64 88}
!10 = !{!"int", !6, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!9, !11, i64 72}
!13 = !{!14, !10, i64 16}
!14 = !{!"_ETHERNET_CPDMA_BUFFERDESCRIPTOR", !11, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!15 = !{!10, !10, i64 0}
!16 = !{!14, !10, i64 8}
!17 = distinct !{!17, !18, !19, !20}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!"llvm.loop.isvectorized", i32 1}
!20 = !{!"llvm.loop.unroll.runtime.disable"}
!21 = distinct !{!21, !18, !19, !20}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.unroll.disable"}
!24 = distinct !{!24, !18, !19}
!25 = !{!14, !10, i64 12}
!26 = !{!9, !11, i64 80}
!27 = !{!14, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass