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

@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

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @ETHERNET_INITIALIZE_INSTANCE(i32 noundef %0) #2 {
  %2 = alloca i8, align 1
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %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 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp uge i32 %8, 1
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store i8 0, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %168

11:                                               ; preds = %1
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = zext i32 %12 to i64
  %14 = getelementptr inbounds [1 x %struct._ETHERNET_CPSW_INSTANCE], ptr @ETHERNET_CPSW_INSTANCES, i64 0, i64 %13
  store ptr %14, ptr %4, align 8, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %15, i32 0, i32 0
  %17 = load i8, ptr %16, align 8, !tbaa !11
  %18 = icmp ne i8 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %11
  store i8 0, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %168

20:                                               ; preds = %11
  %21 = load i32, ptr %3, align 4, !tbaa !5
  switch i32 %21, label %98 [
    i32 0, label %22
  ]

22:                                               ; preds = %20
  %23 = load ptr, ptr %4, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %23, i32 0, i32 1
  store i32 1242562560, ptr %24, align 4, !tbaa !13
  %25 = load ptr, ptr %4, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %25, i32 0, i32 2
  store i32 1242566656, ptr %26, align 8, !tbaa !14
  %27 = load ptr, ptr %4, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %27, i32 0, i32 3
  store i32 1242567168, ptr %28, align 4, !tbaa !15
  %29 = load ptr, ptr %4, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %29, i32 0, i32 4
  store i32 1242564608, ptr %30, align 8, !tbaa !16
  %31 = load ptr, ptr %4, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %31, i32 0, i32 5
  store i32 1242565888, ptr %32, align 4, !tbaa !17
  %33 = load ptr, ptr %4, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %33, i32 0, i32 6
  store i32 1242564864, ptr %34, align 8, !tbaa !18
  %35 = load ptr, ptr %4, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %35, i32 0, i32 7
  store i32 1242562816, ptr %36, align 4, !tbaa !19
  %37 = load ptr, ptr %4, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %37, i32 0, i32 8
  store i32 1242570752, ptr %38, align 8, !tbaa !20
  %39 = load ptr, ptr %4, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %39, i32 0, i32 9
  store i32 0, ptr %40, align 4, !tbaa !21
  %41 = load ptr, ptr %4, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %41, i32 0, i32 10
  store ptr null, ptr %42, align 8, !tbaa !22
  %43 = load ptr, ptr %4, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %43, i32 0, i32 11
  store ptr null, ptr %44, align 8, !tbaa !23
  %45 = load ptr, ptr %4, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %45, i32 0, i32 12
  store ptr null, ptr %46, align 8, !tbaa !24
  %47 = load ptr, ptr %4, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %47, i32 0, i32 13
  store ptr null, ptr %48, align 8, !tbaa !25
  %49 = load ptr, ptr %4, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %49, i32 0, i32 14
  store ptr null, ptr %50, align 8, !tbaa !26
  %51 = load ptr, ptr %4, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %51, i32 0, i32 15
  store ptr null, ptr %52, align 8, !tbaa !27
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %94, %22
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = icmp ule i32 %54, 1
  br i1 %55, label %56, label %97

56:                                               ; preds = %53
  %57 = load ptr, ptr %4, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %57, i32 0, i32 16
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = sub i32 %59, 1
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds [1 x %struct._ETHERNET_CPSW_PORT], ptr %58, i64 0, i64 %61
  store ptr %62, ptr %5, align 8, !tbaa !9
  %63 = load ptr, ptr %5, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %63, i32 0, i32 0
  store i8 0, ptr %64, align 4, !tbaa !28
  %65 = load ptr, ptr %5, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %65, i32 0, i32 1
  store i32 0, ptr %66, align 4, !tbaa !30
  %67 = load ptr, ptr %5, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %67, i32 0, i32 2
  store i32 0, ptr %68, align 4, !tbaa !31
  %69 = load ptr, ptr %5, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %69, i32 0, i32 3
  store i32 0, ptr %70, align 4, !tbaa !32
  %71 = load ptr, ptr %5, align 8, !tbaa !9
  %72 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %71, i32 0, i32 4
  store i8 0, ptr %72, align 4, !tbaa !33
  %73 = load ptr, ptr %5, align 8, !tbaa !9
  %74 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %73, i32 0, i32 5
  store i32 -1, ptr %74, align 4, !tbaa !34
  %75 = load ptr, ptr %5, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %75, i32 0, i32 6
  store i32 -1, ptr %76, align 4, !tbaa !35
  %77 = load i32, ptr %6, align 4, !tbaa !5
  switch i32 %77, label %92 [
    i32 1, label %78
    i32 2, label %85
  ]

78:                                               ; preds = %56
  %79 = load ptr, ptr %5, align 8, !tbaa !9
  %80 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %79, i32 0, i32 1
  store i32 1242563072, ptr %80, align 4, !tbaa !30
  %81 = load ptr, ptr %5, align 8, !tbaa !9
  %82 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %81, i32 0, i32 2
  store i32 1242566016, ptr %82, align 4, !tbaa !31
  %83 = load ptr, ptr %5, align 8, !tbaa !9
  %84 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %83, i32 0, i32 3
  store i32 0, ptr %84, align 4, !tbaa !32
  br label %93

85:                                               ; preds = %56
  %86 = load ptr, ptr %5, align 8, !tbaa !9
  %87 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %86, i32 0, i32 1
  store i32 1242563328, ptr %87, align 4, !tbaa !30
  %88 = load ptr, ptr %5, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %88, i32 0, i32 2
  store i32 1242566080, ptr %89, align 4, !tbaa !31
  %90 = load ptr, ptr %5, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %90, i32 0, i32 3
  store i32 1, ptr %91, align 4, !tbaa !32
  br label %93

92:                                               ; preds = %56
  store i8 0, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %168

93:                                               ; preds = %85, %78
  br label %94

94:                                               ; preds = %93
  %95 = load i32, ptr %6, align 4, !tbaa !5
  %96 = add i32 %95, 1
  store i32 %96, ptr %6, align 4, !tbaa !5
  br label %53, !llvm.loop !36

97:                                               ; preds = %53
  br label %99

98:                                               ; preds = %20
  store i8 0, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %168

99:                                               ; preds = %97
  call void @ETHERNET_HOOK_YIELD()
  %100 = load ptr, ptr %4, align 8, !tbaa !9
  %101 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %100, i32 0, i32 1
  %102 = load i32, ptr %101, align 4, !tbaa !13
  call void @CPSWSSReset(i32 noundef %102)
  %103 = load ptr, ptr %4, align 8, !tbaa !9
  %104 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %103, i32 0, i32 3
  %105 = load i32, ptr %104, align 4, !tbaa !15
  call void @CPSWWrReset(i32 noundef %105)
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %119, %99
  %107 = load i32, ptr %6, align 4, !tbaa !5
  %108 = icmp ule i32 %107, 1
  br i1 %108, label %109, label %122

109:                                              ; preds = %106
  %110 = load ptr, ptr %4, align 8, !tbaa !9
  %111 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %110, i32 0, i32 16
  %112 = load i32, ptr %6, align 4, !tbaa !5
  %113 = sub i32 %112, 1
  %114 = zext i32 %113 to i64
  %115 = getelementptr inbounds [1 x %struct._ETHERNET_CPSW_PORT], ptr %111, i64 0, i64 %114
  store ptr %115, ptr %5, align 8, !tbaa !9
  %116 = load ptr, ptr %5, align 8, !tbaa !9
  %117 = getelementptr inbounds %struct._ETHERNET_CPSW_PORT, ptr %116, i32 0, i32 2
  %118 = load i32, ptr %117, align 4, !tbaa !31
  call void @CPSWSlReset(i32 noundef %118)
  br label %119

119:                                              ; preds = %109
  %120 = load i32, ptr %6, align 4, !tbaa !5
  %121 = add i32 %120, 1
  store i32 %121, ptr %6, align 4, !tbaa !5
  br label %106, !llvm.loop !38

122:                                              ; preds = %106
  call void @ETHERNET_HOOK_YIELD()
  %123 = load ptr, ptr %4, align 8, !tbaa !9
  %124 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %123, i32 0, i32 4
  %125 = load i32, ptr %124, align 8, !tbaa !16
  call void @CPSWCPDMAReset(i32 noundef %125)
  %126 = load ptr, ptr %4, align 8, !tbaa !9
  %127 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %126, i32 0, i32 2
  %128 = load i32, ptr %127, align 8, !tbaa !14
  call void @MDIOInit(i32 noundef %128, i32 noundef 125000000, i32 noundef 1000000)
  call void @ETHERNET_HOOK_DELAY(i32 noundef 1)
  %129 = load ptr, ptr %4, align 8, !tbaa !9
  %130 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %129, i32 0, i32 5
  %131 = load i32, ptr %130, align 4, !tbaa !17
  call void @CPSWALEInit(i32 noundef %131)
  call void @ETHERNET_HOOK_YIELD()
  %132 = load ptr, ptr %4, align 8, !tbaa !9
  %133 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %132, i32 0, i32 5
  %134 = load i32, ptr %133, align 4, !tbaa !17
  call void @CPSWALEPortStateSet(i32 noundef %134, i32 noundef 0, i32 noundef 3)
  %135 = load ptr, ptr %4, align 8, !tbaa !9
  %136 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %135, i32 0, i32 5
  %137 = load i32, ptr %136, align 4, !tbaa !17
  call void @CPSWALEVLANAwareSet(i32 noundef %137)
  %138 = load ptr, ptr %4, align 8, !tbaa !9
  %139 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %138, i32 0, i32 7
  %140 = load i32, ptr %139, align 4, !tbaa !19
  call void @CPSWHostPortDualMacModeSet(i32 noundef %140)
  call void @ETHERNET_HOOK_YIELD()
  %141 = load ptr, ptr %4, align 8, !tbaa !9
  %142 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %141, i32 0, i32 1
  %143 = load i32, ptr %142, align 4, !tbaa !13
  call void @CPSWStatisticsEnable(i32 noundef %143)
  %144 = load i32, ptr %3, align 4, !tbaa !5
  %145 = call zeroext i8 @ETHERNET_CPDMA_INITIALIZE(i32 noundef %144)
  %146 = icmp ne i8 %145, 0
  br i1 %146, label %148, label %147

147:                                              ; preds = %122
  store i8 0, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %168

148:                                              ; preds = %122
  %149 = load ptr, ptr %4, align 8, !tbaa !9
  %150 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %149, i32 0, i32 4
  %151 = load i32, ptr %150, align 8, !tbaa !16
  %152 = load ptr, ptr %4, align 8, !tbaa !9
  %153 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %152, i32 0, i32 14
  %154 = load ptr, ptr %153, align 8, !tbaa !26
  %155 = ptrtoint ptr %154 to i32
  call void @CPSWCPDMARxHdrDescPtrWrite(i32 noundef %151, i32 noundef %155, i32 noundef 0)
  call void @ETHERNET_HOOK_YIELD()
  %156 = load i8, ptr @ETHERNET_POLLING_MODE, align 1, !tbaa !39
  %157 = icmp ne i8 %156, 0
  br i1 %157, label %165, label %158

158:                                              ; preds = %148
  %159 = load ptr, ptr %4, align 8, !tbaa !9
  %160 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %159, i32 0, i32 3
  %161 = load i32, ptr %160, align 4, !tbaa !15
  call void @CPSWWrCoreIntEnable(i32 noundef %161, i32 noundef 0, i32 noundef 0, i32 noundef 8)
  %162 = load ptr, ptr %4, align 8, !tbaa !9
  %163 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %162, i32 0, i32 3
  %164 = load i32, ptr %163, align 4, !tbaa !15
  call void @CPSWWrCoreIntEnable(i32 noundef %164, i32 noundef 0, i32 noundef 0, i32 noundef 4)
  br label %165

165:                                              ; preds = %158, %148
  %166 = load ptr, ptr %4, align 8, !tbaa !9
  %167 = getelementptr inbounds %struct._ETHERNET_CPSW_INSTANCE, ptr %166, i32 0, i32 0
  store i8 1, ptr %167, align 8, !tbaa !11
  store i8 1, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %168

168:                                              ; preds = %165, %147, %98, %92, %19, %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %169 = load i8, ptr %2, align 1
  ret i8 %169
}

declare void @CPSWSSReset(i32 noundef) #1

declare void @CPSWWrReset(i32 noundef) #1

declare void @CPSWSlReset(i32 noundef) #1

declare void @CPSWCPDMAReset(i32 noundef) #1

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

declare void @ETHERNET_HOOK_DELAY(i32 noundef) #1

declare void @CPSWALEInit(i32 noundef) #1

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

declare void @CPSWALEVLANAwareSet(i32 noundef) #1

declare void @CPSWHostPortDualMacModeSet(i32 noundef) #1

declare void @CPSWStatisticsEnable(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @ETHERNET_CPDMA_INITIALIZE(i32 noundef) #2

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

declare void @CPSWWrCoreIntEnable(i32 noundef, i32 noundef, 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 = !{!12, !7, i64 0}
!12 = !{!"_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}
!13 = !{!12, !6, i64 4}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !6, i64 12}
!16 = !{!12, !6, i64 16}
!17 = !{!12, !6, i64 20}
!18 = !{!12, !6, i64 24}
!19 = !{!12, !6, i64 28}
!20 = !{!12, !6, i64 32}
!21 = !{!12, !6, i64 36}
!22 = !{!12, !10, i64 40}
!23 = !{!12, !10, i64 48}
!24 = !{!12, !10, i64 56}
!25 = !{!12, !10, i64 64}
!26 = !{!12, !10, i64 72}
!27 = !{!12, !10, i64 80}
!28 = !{!29, !7, i64 0}
!29 = !{!"_ETHERNET_CPSW_PORT", !7, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !7, i64 16, !6, i64 20, !6, i64 24}
!30 = !{!29, !6, i64 4}
!31 = !{!29, !6, i64 8}
!32 = !{!29, !6, i64 12}
!33 = !{!29, !7, i64 16}
!34 = !{!29, !6, i64 20}
!35 = !{!29, !6, i64 24}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}
!38 = distinct !{!38, !37}
!39 = !{!7, !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"

%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

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @ETHERNET_INITIALIZE_INSTANCE(i32 noundef %0) local_unnamed_addr #1 {
  %.not = icmp eq i32 %0, 0
  %2 = load i8, ptr @ETHERNET_CPSW_INSTANCES, align 16
  %.not59 = icmp eq i8 %2, 0
  %or.cond = select i1 %.not, i1 %.not59, i1 false
  br i1 %or.cond, label %.critedge, label %24

.critedge:                                        ; preds = %1
  store <4 x i32> <i32 1242562560, i32 1242566656, i32 1242567168, i32 1242564608>, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 4), align 4, !tbaa !5
  store <4 x i32> <i32 1242565888, i32 1242564864, i32 1242562816, i32 1242570752>, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 20), align 4, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(53) getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 36), i8 0, i64 53, i1 false)
  store i8 0, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 104), align 8
  store i32 -1, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 108), align 4, !tbaa !9
  store i32 -1, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 112), align 16, !tbaa !11
  store i32 1242563072, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 92), align 4, !tbaa !12
  store i32 1242566016, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 96), align 16, !tbaa !13
  store i32 0, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 100), align 4, !tbaa !14
  tail call void @ETHERNET_HOOK_YIELD() #3
  %3 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 4), align 4, !tbaa !15
  tail call void @CPSWSSReset(i32 noundef %3) #3
  %4 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 12), align 4, !tbaa !18
  tail call void @CPSWWrReset(i32 noundef %4) #3
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 96), align 16, !tbaa !13
  tail call void @CPSWSlReset(i32 noundef %5) #3
  tail call void @ETHERNET_HOOK_YIELD() #3
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 16), align 16, !tbaa !19
  tail call void @CPSWCPDMAReset(i32 noundef %6) #3
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 8), align 8, !tbaa !20
  tail call void @MDIOInit(i32 noundef %7, i32 noundef 125000000, i32 noundef 1000000) #3
  tail call void @ETHERNET_HOOK_DELAY(i32 noundef 1) #3
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 20), align 4, !tbaa !21
  tail call void @CPSWALEInit(i32 noundef %8) #3
  tail call void @ETHERNET_HOOK_YIELD() #3
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 20), align 4, !tbaa !21
  tail call void @CPSWALEPortStateSet(i32 noundef %9, i32 noundef 0, i32 noundef 3) #3
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 20), align 4, !tbaa !21
  tail call void @CPSWALEVLANAwareSet(i32 noundef %10) #3
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 28), align 4, !tbaa !22
  tail call void @CPSWHostPortDualMacModeSet(i32 noundef %11) #3
  tail call void @ETHERNET_HOOK_YIELD() #3
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 4), align 4, !tbaa !15
  tail call void @CPSWStatisticsEnable(i32 noundef %12) #3
  %13 = tail call zeroext i8 @ETHERNET_CPDMA_INITIALIZE(i32 noundef 0)
  %.not60 = icmp eq i8 %13, 0
  br i1 %.not60, label %24, label %14

14:                                               ; preds = %.critedge
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 16), align 16, !tbaa !19
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 72), align 8, !tbaa !23
  %17 = ptrtoint ptr %16 to i64
  %18 = trunc i64 %17 to i32
  tail call void @CPSWCPDMARxHdrDescPtrWrite(i32 noundef %15, i32 noundef %18, i32 noundef 0) #3
  tail call void @ETHERNET_HOOK_YIELD() #3
  %19 = load i8, ptr @ETHERNET_POLLING_MODE, align 1, !tbaa !24
  %.not61 = icmp eq i8 %19, 0
  br i1 %.not61, label %20, label %23

20:                                               ; preds = %14
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 12), align 4, !tbaa !18
  tail call void @CPSWWrCoreIntEnable(i32 noundef %21, i32 noundef 0, i32 noundef 0, i32 noundef 8) #3
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @ETHERNET_CPSW_INSTANCES, i64 12), align 4, !tbaa !18
  tail call void @CPSWWrCoreIntEnable(i32 noundef %22, i32 noundef 0, i32 noundef 0, i32 noundef 4) #3
  br label %23

23:                                               ; preds = %20, %14
  store i8 1, ptr @ETHERNET_CPSW_INSTANCES, align 16, !tbaa !25
  br label %24

24:                                               ; preds = %.critedge, %1, %23
  %.057 = phi i8 [ 1, %23 ], [ 0, %1 ], [ 0, %.critedge ]
  ret i8 %.057
}

declare void @CPSWSSReset(i32 noundef) local_unnamed_addr #0

declare void @CPSWWrReset(i32 noundef) local_unnamed_addr #0

declare void @CPSWSlReset(i32 noundef) local_unnamed_addr #0

declare void @CPSWCPDMAReset(i32 noundef) local_unnamed_addr #0

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

declare void @ETHERNET_HOOK_DELAY(i32 noundef) local_unnamed_addr #0

declare void @CPSWALEInit(i32 noundef) local_unnamed_addr #0

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

declare void @CPSWALEVLANAwareSet(i32 noundef) local_unnamed_addr #0

declare void @CPSWHostPortDualMacModeSet(i32 noundef) local_unnamed_addr #0

declare void @CPSWStatisticsEnable(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @ETHERNET_CPDMA_INITIALIZE(i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !6, i64 20}
!10 = !{!"_ETHERNET_CPSW_PORT", !7, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !7, i64 16, !6, i64 20, !6, i64 24}
!11 = !{!10, !6, i64 24}
!12 = !{!10, !6, i64 4}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !6, i64 12}
!15 = !{!16, !6, i64 4}
!16 = !{!"_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, !17, i64 40, !17, i64 48, !17, i64 56, !17, i64 64, !17, i64 72, !17, i64 80, !7, i64 88}
!17 = !{!"any pointer", !7, i64 0}
!18 = !{!16, !6, i64 12}
!19 = !{!16, !6, i64 16}
!20 = !{!16, !6, i64 8}
!21 = !{!16, !6, i64 20}
!22 = !{!16, !6, i64 28}
!23 = !{!16, !17, i64 72}
!24 = !{!7, !7, i64 0}
!25 = !{!16, !7, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass