; LLVM IR from narke/Aragveli :: src/extra/drivers (rtl8139)

; 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.rtl8139_dev = type { i8, i16, i64, i32, [6 x i8], ptr, i64, ptr, i64 }
%struct.pci_device = type { i8, i8, i8, i16, i16, i16 }

@rtl8139_device = external dso_local global %struct.rtl8139_dev, align 8
@pci_rtl8139_device = external dso_local global %struct.pci_device, align 2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @out32(i16 noundef zeroext, i64 noundef) #1

; 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 void @rtl8139_setup() #2 {
  %1 = alloca %struct.pci_device, align 2
  %2 = alloca { i64, i16 }, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 10, ptr %1) #7
  %8 = call { i64, i16 } @pci_device_lookup(i16 noundef zeroext 4332, i16 noundef zeroext -32455)
  store { i64, i16 } %8, ptr %2, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %1, ptr align 8 %2, i64 10, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 @pci_rtl8139_device, ptr align 2 %1, i64 10, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 10, ptr %1) #7
  %9 = load i16, ptr getelementptr inbounds (%struct.pci_device, ptr @pci_rtl8139_device, i32 0, i32 3), align 2, !tbaa !11
  %10 = zext i16 %9 to i32
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %17

12:                                               ; preds = %0
  %13 = load i16, ptr getelementptr inbounds (%struct.pci_device, ptr @pci_rtl8139_device, i32 0, i32 4), align 2, !tbaa !13
  %14 = zext i16 %13 to i32
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %12
  br label %126

17:                                               ; preds = %12, %0
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  %18 = load i8, ptr @pci_rtl8139_device, align 2, !tbaa !14
  %19 = load i8, ptr getelementptr inbounds (%struct.pci_device, ptr @pci_rtl8139_device, i32 0, i32 1), align 1, !tbaa !15
  %20 = load i8, ptr getelementptr inbounds (%struct.pci_device, ptr @pci_rtl8139_device, i32 0, i32 2), align 2, !tbaa !16
  %21 = call i64 @pci_config_read_dword(i8 noundef zeroext %18, i8 noundef zeroext %19, i8 noundef zeroext %20, i8 noundef zeroext 4)
  store i64 %21, ptr %3, align 8, !tbaa !17
  %22 = load i64, ptr %3, align 8, !tbaa !17
  %23 = or i64 %22, 4
  store i64 %23, ptr %3, align 8, !tbaa !17
  %24 = load i8, ptr @pci_rtl8139_device, align 2, !tbaa !14
  %25 = load i8, ptr getelementptr inbounds (%struct.pci_device, ptr @pci_rtl8139_device, i32 0, i32 1), align 1, !tbaa !15
  %26 = load i8, ptr getelementptr inbounds (%struct.pci_device, ptr @pci_rtl8139_device, i32 0, i32 2), align 2, !tbaa !16
  %27 = load i64, ptr %3, align 8, !tbaa !17
  call void @pci_config_write_dword(i8 noundef zeroext %24, i8 noundef zeroext %25, i8 noundef zeroext %26, i8 noundef zeroext 4, i64 noundef %27)
  store volatile i64 0, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 8), align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  %28 = load i8, ptr @pci_rtl8139_device, align 2, !tbaa !14
  %29 = load i8, ptr getelementptr inbounds (%struct.pci_device, ptr @pci_rtl8139_device, i32 0, i32 1), align 1, !tbaa !15
  %30 = load i8, ptr getelementptr inbounds (%struct.pci_device, ptr @pci_rtl8139_device, i32 0, i32 2), align 2, !tbaa !16
  %31 = call i64 @pci_config_read_dword(i8 noundef zeroext %28, i8 noundef zeroext %29, i8 noundef zeroext %30, i8 noundef zeroext 16)
  store i64 %31, ptr %4, align 8, !tbaa !17
  %32 = load i64, ptr %4, align 8, !tbaa !17
  %33 = and i64 %32, -4
  %34 = trunc i64 %33 to i16
  store i16 %34, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 1), align 2, !tbaa !23
  %35 = load i16, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 1), align 2, !tbaa !23
  %36 = zext i16 %35 to i32
  %37 = add nsw i32 %36, 82
  %38 = trunc i32 %37 to i16
  call void @out8(i16 noundef zeroext %38, i8 noundef zeroext 0)
  %39 = load i16, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 1), align 2, !tbaa !23
  %40 = zext i16 %39 to i32
  %41 = add nsw i32 %40, 55
  %42 = trunc i32 %41 to i16
  call void @out8(i16 noundef zeroext %42, i8 noundef zeroext 16)
  br label %43

43:                                               ; preds = %52, %17
  %44 = load i16, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 1), align 2, !tbaa !23
  %45 = zext i16 %44 to i32
  %46 = add nsw i32 %45, 55
  %47 = trunc i32 %46 to i16
  %48 = call zeroext i8 @in8(i16 noundef zeroext %47)
  %49 = zext i8 %48 to i32
  %50 = and i32 %49, 16
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %53

52:                                               ; preds = %43
  br label %43, !llvm.loop !24

53:                                               ; preds = %43
  %54 = call ptr @malloc(i64 noundef 9708) #8
  store ptr %54, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 5), align 8, !tbaa !26
  %55 = load ptr, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 5), align 8, !tbaa !26
  %56 = icmp ne ptr %55, null
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  store i32 1, ptr %5, align 4
  br label %124

58:                                               ; preds = %53
  %59 = load ptr, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 5), align 8, !tbaa !26
  call void @llvm.memset.p0.i64(ptr align 1 %59, i8 0, i64 9708, i1 false)
  %60 = load i16, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 1), align 2, !tbaa !23
  %61 = zext i16 %60 to i32
  %62 = add nsw i32 %61, 48
  %63 = trunc i32 %62 to i16
  %64 = load ptr, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 5), align 8, !tbaa !26
  %65 = ptrtoint ptr %64 to i64
  call void @out32(i16 noundef zeroext %63, i64 noundef %65)
  %66 = load i16, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 1), align 2, !tbaa !23
  %67 = zext i16 %66 to i32
  %68 = add nsw i32 %67, 56
  %69 = trunc i32 %68 to i16
  call void @out32(i16 noundef zeroext %69, i64 noundef 0)
  %70 = load i16, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 1), align 2, !tbaa !23
  %71 = zext i16 %70 to i32
  %72 = add nsw i32 %71, 58
  %73 = trunc i32 %72 to i16
  call void @out32(i16 noundef zeroext %73, i64 noundef 0)
  store i64 0, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 6), align 8, !tbaa !27
  %74 = call ptr @malloc(i64 noundef 6144) #8
  store ptr %74, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 7), align 8, !tbaa !28
  %75 = load ptr, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 7), align 8, !tbaa !28
  %76 = icmp ne ptr %75, null
  br i1 %76, label %78, label %77

77:                                               ; preds = %58
  store i32 1, ptr %5, align 4
  br label %124

78:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 0, ptr %6, align 4, !tbaa !29
  br label %79

79:                                               ; preds = %97, %78
  %80 = load i32, ptr %6, align 4, !tbaa !29
  %81 = icmp slt i32 %80, 4
  br i1 %81, label %83, label %82

82:                                               ; preds = %79
  store i32 4, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %100

83:                                               ; preds = %79
  %84 = load i16, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 1), align 2, !tbaa !23
  %85 = zext i16 %84 to i32
  %86 = add nsw i32 %85, 32
  %87 = load i32, ptr %6, align 4, !tbaa !29
  %88 = mul nsw i32 %87, 4
  %89 = add nsw i32 %86, %88
  %90 = trunc i32 %89 to i16
  %91 = load ptr, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 7), align 8, !tbaa !28
  %92 = load i32, ptr %6, align 4, !tbaa !29
  %93 = mul nsw i32 1536, %92
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds i8, ptr %91, i64 %94
  %96 = ptrtoint ptr %95 to i64
  call void @out32(i16 noundef zeroext %90, i64 noundef %96)
  br label %97

97:                                               ; preds = %83
  %98 = load i32, ptr %6, align 4, !tbaa !29
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %6, align 4, !tbaa !29
  br label %79, !llvm.loop !30

100:                                              ; preds = %82
  %101 = load i16, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 1), align 2, !tbaa !23
  %102 = zext i16 %101 to i32
  %103 = add nsw i32 %102, 60
  %104 = trunc i32 %103 to i16
  call void @out16(i16 noundef zeroext %104, i16 noundef zeroext 13)
  %105 = load i16, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 1), align 2, !tbaa !23
  %106 = zext i16 %105 to i32
  %107 = add nsw i32 %106, 68
  %108 = trunc i32 %107 to i16
  call void @out32(i16 noundef zeroext %108, i64 noundef 143)
  %109 = load i16, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 1), align 2, !tbaa !23
  %110 = zext i16 %109 to i32
  %111 = add nsw i32 %110, 76
  %112 = trunc i32 %111 to i16
  call void @out32(i16 noundef zeroext %112, i64 noundef 0)
  %113 = load i16, ptr getelementptr inbounds (%struct.rtl8139_dev, ptr @rtl8139_device, i32 0, i32 1), align 2, !tbaa !23
  %114 = zext i16 %113 to i32
  %115 = add nsw i32 %114, 55
  %116 = trunc i32 %115 to i16
  call void @out8(i16 noundef zeroext %116, i8 noundef zeroext 12)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %117 = load i8, ptr @pci_rtl8139_device, align 2, !tbaa !14
  %118 = load i8, ptr getelementptr inbounds (%struct.pci_device, ptr @pci_rtl8139_device, i32 0, i32 1), align 1, !tbaa !15
  %119 = load i8, ptr getelementptr inbounds (%struct.pci_device, ptr @pci_rtl8139_device, i32 0, i32 2), align 2, !tbaa !16
  %120 = call i64 @pci_config_read_dword(i8 noundef zeroext %117, i8 noundef zeroext %118, i8 noundef zeroext %119, i8 noundef zeroext 60)
  %121 = and i64 %120, 255
  store i64 %121, ptr %7, align 8, !tbaa !17
  %122 = load i64, ptr %7, align 8, !tbaa !17
  %123 = call i32 @x86_irq_set_routine(i64 noundef %122, ptr noundef @packet_handler)
  call void @read_mac_address()
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  store i32 0, ptr %5, align 4
  br label %124

124:                                              ; preds = %100, %77, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  %125 = load i32, ptr %5, align 4
  switch i32 %125, label %127 [
    i32 0, label %126
    i32 1, label %126
  ]

126:                                              ; preds = %124, %124, %16
  ret void

127:                                              ; preds = %124
  unreachable
}

declare { i64, i16 } @pci_device_lookup(i16 noundef zeroext, i16 noundef zeroext) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

declare i64 @pci_config_read_dword(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) #3

declare void @pci_config_write_dword(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i64 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @out8(i16 noundef zeroext, i8 noundef zeroext) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i8 @in8(i16 noundef zeroext) #1

; Function Attrs: allocsize(0)
declare ptr @malloc(i64 noundef) #5

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @out16(i16 noundef zeroext, i16 noundef zeroext) #1

declare i32 @x86_irq_set_routine(i64 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @packet_handler(i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @read_mac_address() #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 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 = { "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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { allocsize(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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { allocsize(0) }

!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 = !{i64 0, i64 1, !6, i64 1, i64 1, !6, i64 2, i64 1, !6, i64 4, i64 2, !9, i64 6, i64 2, !9, i64 8, i64 2, !9}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"pci_device", !7, i64 0, !7, i64 1, !7, i64 2, !10, i64 4, !10, i64 6, !10, i64 8}
!13 = !{!12, !10, i64 6}
!14 = !{!12, !7, i64 0}
!15 = !{!12, !7, i64 1}
!16 = !{!12, !7, i64 2}
!17 = !{!18, !18, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!20, !18, i64 56}
!20 = !{!"rtl8139_dev", !7, i64 0, !10, i64 2, !18, i64 8, !21, i64 16, !7, i64 20, !22, i64 32, !18, i64 40, !22, i64 48, !18, i64 56}
!21 = !{!"int", !7, i64 0}
!22 = !{!"any pointer", !7, i64 0}
!23 = !{!20, !10, i64 2}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!20, !22, i64 32}
!27 = !{!20, !18, i64 40}
!28 = !{!20, !22, i64 48}
!29 = !{!21, !21, i64 0}
!30 = distinct !{!30, !25}


; 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.rtl8139_dev = type { i8, i16, i64, i32, [6 x i8], ptr, i64, ptr, i64 }
%struct.pci_device = type { i8, i8, i8, i16, i16, i16 }

@rtl8139_device = external dso_local global %struct.rtl8139_dev, align 8
@pci_rtl8139_device = external dso_local local_unnamed_addr global %struct.pci_device, align 2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @out32(i16 noundef zeroext, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @rtl8139_setup() local_unnamed_addr #1 {
  %1 = tail call { i64, i16 } @pci_device_lookup(i16 noundef zeroext 4332, i16 noundef zeroext -32455) #5
  %.fca.0.extract = extractvalue { i64, i16 } %1, 0
  %.fca.1.extract = extractvalue { i64, i16 } %1, 1
  store i64 %.fca.0.extract, ptr @pci_rtl8139_device, align 2
  store i16 %.fca.1.extract, ptr getelementptr inbounds (i8, ptr @pci_rtl8139_device, i64 8), align 2, !tbaa !5
  %or.cond = icmp ult i64 %.fca.0.extract, 4294967296
  br i1 %or.cond, label %69, label %2

2:                                                ; preds = %0
  %3 = lshr i64 %.fca.0.extract, 16
  %4 = trunc i64 %3 to i8
  %5 = lshr i64 %.fca.0.extract, 8
  %6 = trunc i64 %5 to i8
  %7 = trunc i64 %.fca.0.extract to i8
  %8 = tail call i64 @pci_config_read_dword(i8 noundef zeroext %7, i8 noundef zeroext %6, i8 noundef zeroext %4, i8 noundef zeroext 4) #5
  %9 = or i64 %8, 4
  %10 = load i8, ptr @pci_rtl8139_device, align 2, !tbaa !9
  %11 = load i8, ptr getelementptr inbounds (i8, ptr @pci_rtl8139_device, i64 1), align 1, !tbaa !11
  %12 = load i8, ptr getelementptr inbounds (i8, ptr @pci_rtl8139_device, i64 2), align 2, !tbaa !12
  tail call void @pci_config_write_dword(i8 noundef zeroext %10, i8 noundef zeroext %11, i8 noundef zeroext %12, i8 noundef zeroext 4, i64 noundef %9) #5
  store volatile i64 0, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 56), align 8, !tbaa !13
  %13 = load i8, ptr @pci_rtl8139_device, align 2, !tbaa !9
  %14 = load i8, ptr getelementptr inbounds (i8, ptr @pci_rtl8139_device, i64 1), align 1, !tbaa !11
  %15 = load i8, ptr getelementptr inbounds (i8, ptr @pci_rtl8139_device, i64 2), align 2, !tbaa !12
  %16 = tail call i64 @pci_config_read_dword(i8 noundef zeroext %13, i8 noundef zeroext %14, i8 noundef zeroext %15, i8 noundef zeroext 16) #5
  %17 = trunc i64 %16 to i16
  %18 = and i16 %17, -4
  store i16 %18, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %19 = add i16 %18, 82
  tail call void @out8(i16 noundef zeroext %19, i8 noundef zeroext 0)
  %20 = load i16, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %21 = add i16 %20, 55
  tail call void @out8(i16 noundef zeroext %21, i8 noundef zeroext 16)
  br label %22

22:                                               ; preds = %22, %2
  %23 = load i16, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %24 = add i16 %23, 55
  %25 = tail call zeroext i8 @in8(i16 noundef zeroext %24)
  %26 = and i8 %25, 16
  %.not = icmp eq i8 %26, 0
  br i1 %.not, label %27, label %22, !llvm.loop !19

27:                                               ; preds = %22
  %calloc = tail call dereferenceable_or_null(9708) ptr @calloc(i64 1, i64 9708)
  store ptr %calloc, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 32), align 8, !tbaa !21
  %.not12 = icmp eq ptr %calloc, null
  br i1 %.not12, label %69, label %28

28:                                               ; preds = %27
  %29 = load i16, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %30 = add i16 %29, 48
  %31 = ptrtoint ptr %calloc to i64
  tail call void @out32(i16 noundef zeroext %30, i64 noundef %31)
  %32 = load i16, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %33 = add i16 %32, 56
  tail call void @out32(i16 noundef zeroext %33, i64 noundef 0)
  %34 = load i16, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %35 = add i16 %34, 58
  tail call void @out32(i16 noundef zeroext %35, i64 noundef 0)
  store i64 0, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 40), align 8, !tbaa !22
  %36 = tail call dereferenceable_or_null(6144) ptr @malloc(i64 noundef 6144) #6
  store ptr %36, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 48), align 8, !tbaa !23
  %.not13 = icmp eq ptr %36, null
  br i1 %.not13, label %69, label %.preheader.preheader

.preheader.preheader:                             ; preds = %28
  %37 = load i16, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %38 = add i16 %37, 32
  %39 = ptrtoint ptr %36 to i64
  tail call void @out32(i16 noundef zeroext %38, i64 noundef %39)
  %40 = load i16, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %41 = add i16 %40, 36
  %42 = load ptr, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 48), align 8, !tbaa !23
  %43 = getelementptr inbounds i8, ptr %42, i64 1536
  %44 = ptrtoint ptr %43 to i64
  tail call void @out32(i16 noundef zeroext %41, i64 noundef %44)
  %45 = load i16, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %46 = add i16 %45, 40
  %47 = load ptr, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 48), align 8, !tbaa !23
  %48 = getelementptr inbounds i8, ptr %47, i64 3072
  %49 = ptrtoint ptr %48 to i64
  tail call void @out32(i16 noundef zeroext %46, i64 noundef %49)
  %50 = load i16, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %51 = add i16 %50, 44
  %52 = load ptr, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 48), align 8, !tbaa !23
  %53 = getelementptr inbounds i8, ptr %52, i64 4608
  %54 = ptrtoint ptr %53 to i64
  tail call void @out32(i16 noundef zeroext %51, i64 noundef %54)
  %55 = load i16, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %56 = add i16 %55, 60
  tail call void @out16(i16 noundef zeroext %56, i16 noundef zeroext 13)
  %57 = load i16, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %58 = add i16 %57, 68
  tail call void @out32(i16 noundef zeroext %58, i64 noundef 143)
  %59 = load i16, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %60 = add i16 %59, 76
  tail call void @out32(i16 noundef zeroext %60, i64 noundef 0)
  %61 = load i16, ptr getelementptr inbounds (i8, ptr @rtl8139_device, i64 2), align 2, !tbaa !18
  %62 = add i16 %61, 55
  tail call void @out8(i16 noundef zeroext %62, i8 noundef zeroext 12)
  %63 = load i8, ptr @pci_rtl8139_device, align 2, !tbaa !9
  %64 = load i8, ptr getelementptr inbounds (i8, ptr @pci_rtl8139_device, i64 1), align 1, !tbaa !11
  %65 = load i8, ptr getelementptr inbounds (i8, ptr @pci_rtl8139_device, i64 2), align 2, !tbaa !12
  %66 = tail call i64 @pci_config_read_dword(i8 noundef zeroext %63, i8 noundef zeroext %64, i8 noundef zeroext %65, i8 noundef zeroext 60) #5
  %67 = and i64 %66, 255
  %68 = tail call i32 @x86_irq_set_routine(i64 noundef %67, ptr noundef nonnull @packet_handler) #5
  tail call void @read_mac_address()
  br label %69

69:                                               ; preds = %.preheader.preheader, %27, %28, %0
  ret void
}

declare { i64, i16 } @pci_device_lookup(i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #2

declare i64 @pci_config_read_dword(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #2

declare void @pci_config_write_dword(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @out8(i16 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i8 @in8(i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @out16(i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #0

declare i32 @x86_irq_set_routine(i64 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @packet_handler(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @read_mac_address() local_unnamed_addr #1

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #4

attributes #0 = { inlinehint 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 = { 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #5 = { nounwind }
attributes #6 = { allocsize(0) }

!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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 0}
!10 = !{!"pci_device", !7, i64 0, !7, i64 1, !7, i64 2, !6, i64 4, !6, i64 6, !6, i64 8}
!11 = !{!10, !7, i64 1}
!12 = !{!10, !7, i64 2}
!13 = !{!14, !15, i64 56}
!14 = !{!"rtl8139_dev", !7, i64 0, !6, i64 2, !15, i64 8, !16, i64 16, !7, i64 20, !17, i64 32, !15, i64 40, !17, i64 48, !15, i64 56}
!15 = !{!"long", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!"any pointer", !7, i64 0}
!18 = !{!14, !6, i64 2}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!14, !17, i64 32}
!22 = !{!14, !15, i64 40}
!23 = !{!14, !17, i64 48}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass