; LLVM IR from aap/pdp6 :: newemu (netmem)

; 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.PDP6 = type { i32, i32, i32, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i64, i64, i8, i64, i64, i64, i32, i32, i32, i32, i32, i32, i64, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i64, i64, i64, i8, i8, i8, i8, i64, i8, i8, i8, i32, %struct.FD, i64, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, %struct.FD, i32, i64, i64, %struct.FD, i8, i64, i64, i64, i64, i64, i8, i64 }
%struct.FD = type { i32, i32, i32 }

@handlenetmem.buf = external hidden global [2566 x i8], align 16
@.str = external hidden unnamed_addr constant [23 x i8], align 1
@memory = external global [262144 x i64], align 16
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [58 x i8], align 1
@__PRETTY_FUNCTION__.handlenetmem = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @handlenetmem(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i16, align 2
  %5 = alloca i16, align 2
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 2, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.PDP6, ptr %9, i32 0, i32 113
  %11 = load i8, ptr %10, align 4, !tbaa !9, !range !15, !noundef !16
  %12 = trunc i8 %11 to i1
  br i1 %12, label %25, label %13

13:                                               ; preds = %1
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.PDP6, ptr %14, i32 0, i32 170
  %16 = getelementptr inbounds %struct.FD, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !17
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %25, label %19

19:                                               ; preds = %13
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.PDP6, ptr %20, i32 0, i32 170
  %22 = getelementptr inbounds %struct.FD, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !18
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %26, label %25

25:                                               ; preds = %19, %13, %1
  store i32 1, ptr %8, align 4
  br label %182

26:                                               ; preds = %19
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.PDP6, ptr %27, i32 0, i32 170
  %29 = getelementptr inbounds %struct.FD, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !17
  %31 = call i32 @readn(i32 noundef %30, ptr noundef @handlenetmem.buf, i32 noundef 2)
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %26
  store i32 1, ptr %8, align 4
  br label %182

34:                                               ; preds = %26
  %35 = call ptr @getu16(ptr noundef @handlenetmem.buf, ptr noundef %4)
  %36 = load i16, ptr %4, align 2, !tbaa !19
  %37 = zext i16 %36 to i64
  %38 = icmp ugt i64 %37, 2566
  br i1 %38, label %39, label %43

39:                                               ; preds = %34
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.PDP6, ptr %41, i32 0, i32 170
  call void @closefd(ptr noundef %42)
  store i32 1, ptr %8, align 4
  br label %182

43:                                               ; preds = %34
  call void @llvm.memset.p0.i64(ptr align 16 @handlenetmem.buf, i8 0, i64 2566, i1 false)
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.PDP6, ptr %44, i32 0, i32 170
  %46 = getelementptr inbounds %struct.FD, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !17
  %48 = load i16, ptr %4, align 2, !tbaa !19
  %49 = zext i16 %48 to i32
  %50 = call i32 @readn(i32 noundef %47, ptr noundef @handlenetmem.buf, i32 noundef %49)
  %51 = call ptr @getaddr(ptr noundef getelementptr inbounds ([2566 x i8], ptr @handlenetmem.buf, i64 0, i64 1), ptr noundef %6)
  store ptr %51, ptr %3, align 8, !tbaa !5
  %52 = load i8, ptr @handlenetmem.buf, align 16, !tbaa !21
  %53 = zext i8 %52 to i32
  switch i32 %53, label %175 [
    i32 1, label %54
    i32 2, label %74
    i32 5, label %95
    i32 6, label %138
  ]

54:                                               ; preds = %43
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = call ptr @getword(ptr noundef %55, ptr noundef %7)
  store ptr %56, ptr %3, align 8, !tbaa !5
  %57 = load i64, ptr %7, align 8, !tbaa !22
  %58 = load i32, ptr %6, align 4, !tbaa !23
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds [262144 x i64], ptr @memory, i64 0, i64 %59
  store i64 %57, ptr %60, align 8, !tbaa !22
  store i16 1, ptr %4, align 2, !tbaa !19
  %61 = load i16, ptr %4, align 2, !tbaa !19
  %62 = call ptr @putu16(ptr noundef @handlenetmem.buf, i16 noundef zeroext %61)
  store ptr %62, ptr %3, align 8, !tbaa !5
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i32 1
  store ptr %64, ptr %3, align 8, !tbaa !5
  store i8 3, ptr %63, align 1, !tbaa !21
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.PDP6, ptr %65, i32 0, i32 170
  %67 = getelementptr inbounds %struct.FD, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 8, !tbaa !17
  %69 = load i16, ptr %4, align 2, !tbaa !19
  %70 = zext i16 %69 to i32
  %71 = add nsw i32 %70, 2
  %72 = sext i32 %71 to i64
  %73 = call i64 @write(i32 noundef %68, ptr noundef @handlenetmem.buf, i64 noundef %72)
  br label %179

74:                                               ; preds = %43
  %75 = load i32, ptr %6, align 4, !tbaa !23
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds [262144 x i64], ptr @memory, i64 0, i64 %76
  %78 = load i64, ptr %77, align 8, !tbaa !22
  store i64 %78, ptr %7, align 8, !tbaa !22
  store i16 6, ptr %4, align 2, !tbaa !19
  %79 = load i16, ptr %4, align 2, !tbaa !19
  %80 = call ptr @putu16(ptr noundef @handlenetmem.buf, i16 noundef zeroext %79)
  store ptr %80, ptr %3, align 8, !tbaa !5
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds i8, ptr %81, i32 1
  store ptr %82, ptr %3, align 8, !tbaa !5
  store i8 3, ptr %81, align 1, !tbaa !21
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = load i64, ptr %7, align 8, !tbaa !22
  %85 = call ptr @putword(ptr noundef %83, i64 noundef %84)
  store ptr %85, ptr %3, align 8, !tbaa !5
  %86 = load ptr, ptr %2, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.PDP6, ptr %86, i32 0, i32 170
  %88 = getelementptr inbounds %struct.FD, ptr %87, i32 0, i32 0
  %89 = load i32, ptr %88, align 8, !tbaa !17
  %90 = load i16, ptr %4, align 2, !tbaa !19
  %91 = zext i16 %90 to i32
  %92 = add nsw i32 %91, 2
  %93 = sext i32 %92 to i64
  %94 = call i64 @write(i32 noundef %89, ptr noundef @handlenetmem.buf, i64 noundef %93)
  br label %179

95:                                               ; preds = %43
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = call ptr @getu16(ptr noundef %96, ptr noundef %5)
  store ptr %97, ptr %3, align 8, !tbaa !5
  %98 = load i16, ptr %5, align 2, !tbaa !19
  %99 = zext i16 %98 to i32
  %100 = icmp sle i32 %99, 512
  br i1 %100, label %101, label %102

101:                                              ; preds = %95
  br label %103

102:                                              ; preds = %95
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 120, ptr noundef @__PRETTY_FUNCTION__.handlenetmem) #6
  unreachable

103:                                              ; preds = %101
  %104 = load i16, ptr %5, align 2, !tbaa !19
  %105 = zext i16 %104 to i32
  %106 = mul nsw i32 %105, 5
  %107 = add nsw i32 1, %106
  %108 = trunc i32 %107 to i16
  store i16 %108, ptr %4, align 2, !tbaa !19
  %109 = load i16, ptr %4, align 2, !tbaa !19
  %110 = call ptr @putu16(ptr noundef @handlenetmem.buf, i16 noundef zeroext %109)
  store ptr %110, ptr %3, align 8, !tbaa !5
  %111 = load ptr, ptr %3, align 8, !tbaa !5
  %112 = getelementptr inbounds i8, ptr %111, i32 1
  store ptr %112, ptr %3, align 8, !tbaa !5
  store i8 3, ptr %111, align 1, !tbaa !21
  br label %113

113:                                              ; preds = %117, %103
  %114 = load i16, ptr %5, align 2, !tbaa !19
  %115 = add i16 %114, -1
  store i16 %115, ptr %5, align 2, !tbaa !19
  %116 = icmp ne i16 %114, 0
  br i1 %116, label %117, label %128

117:                                              ; preds = %113
  %118 = load i32, ptr %6, align 4, !tbaa !23
  %119 = zext i32 %118 to i64
  %120 = getelementptr inbounds [262144 x i64], ptr @memory, i64 0, i64 %119
  %121 = load i64, ptr %120, align 8, !tbaa !22
  store i64 %121, ptr %7, align 8, !tbaa !22
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = load i64, ptr %7, align 8, !tbaa !22
  %124 = call ptr @putword(ptr noundef %122, i64 noundef %123)
  store ptr %124, ptr %3, align 8, !tbaa !5
  %125 = load i32, ptr %6, align 4, !tbaa !23
  %126 = add i32 %125, 1
  %127 = and i32 %126, 262143
  store i32 %127, ptr %6, align 4, !tbaa !23
  br label %113, !llvm.loop !24

128:                                              ; preds = %113
  %129 = load ptr, ptr %2, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.PDP6, ptr %129, i32 0, i32 170
  %131 = getelementptr inbounds %struct.FD, ptr %130, i32 0, i32 0
  %132 = load i32, ptr %131, align 8, !tbaa !17
  %133 = load i16, ptr %4, align 2, !tbaa !19
  %134 = zext i16 %133 to i32
  %135 = add nsw i32 %134, 2
  %136 = sext i32 %135 to i64
  %137 = call i64 @write(i32 noundef %132, ptr noundef @handlenetmem.buf, i64 noundef %136)
  br label %179

138:                                              ; preds = %43
  %139 = load ptr, ptr %3, align 8, !tbaa !5
  %140 = call ptr @getu16(ptr noundef %139, ptr noundef %5)
  store ptr %140, ptr %3, align 8, !tbaa !5
  %141 = load i16, ptr %5, align 2, !tbaa !19
  %142 = zext i16 %141 to i32
  %143 = icmp sle i32 %142, 512
  br i1 %143, label %144, label %145

144:                                              ; preds = %138
  br label %146

145:                                              ; preds = %138
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 138, ptr noundef @__PRETTY_FUNCTION__.handlenetmem) #6
  unreachable

146:                                              ; preds = %144
  br label %147

147:                                              ; preds = %151, %146
  %148 = load i16, ptr %5, align 2, !tbaa !19
  %149 = add i16 %148, -1
  store i16 %149, ptr %5, align 2, !tbaa !19
  %150 = icmp ne i16 %148, 0
  br i1 %150, label %151, label %161

151:                                              ; preds = %147
  %152 = load ptr, ptr %3, align 8, !tbaa !5
  %153 = call ptr @getword(ptr noundef %152, ptr noundef %7)
  store ptr %153, ptr %3, align 8, !tbaa !5
  %154 = load i64, ptr %7, align 8, !tbaa !22
  %155 = load i32, ptr %6, align 4, !tbaa !23
  %156 = zext i32 %155 to i64
  %157 = getelementptr inbounds [262144 x i64], ptr @memory, i64 0, i64 %156
  store i64 %154, ptr %157, align 8, !tbaa !22
  %158 = load i32, ptr %6, align 4, !tbaa !23
  %159 = add i32 %158, 1
  %160 = and i32 %159, 262143
  store i32 %160, ptr %6, align 4, !tbaa !23
  br label %147, !llvm.loop !26

161:                                              ; preds = %147
  store i16 1, ptr %4, align 2, !tbaa !19
  %162 = load i16, ptr %4, align 2, !tbaa !19
  %163 = call ptr @putu16(ptr noundef @handlenetmem.buf, i16 noundef zeroext %162)
  store ptr %163, ptr %3, align 8, !tbaa !5
  %164 = load ptr, ptr %3, align 8, !tbaa !5
  %165 = getelementptr inbounds i8, ptr %164, i32 1
  store ptr %165, ptr %3, align 8, !tbaa !5
  store i8 3, ptr %164, align 1, !tbaa !21
  %166 = load ptr, ptr %2, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.PDP6, ptr %166, i32 0, i32 170
  %168 = getelementptr inbounds %struct.FD, ptr %167, i32 0, i32 0
  %169 = load i32, ptr %168, align 8, !tbaa !17
  %170 = load i16, ptr %4, align 2, !tbaa !19
  %171 = zext i16 %170 to i32
  %172 = add nsw i32 %171, 2
  %173 = sext i32 %172 to i64
  %174 = call i64 @write(i32 noundef %169, ptr noundef @handlenetmem.buf, i64 noundef %173)
  br label %179

175:                                              ; preds = %43
  %176 = load i8, ptr @handlenetmem.buf, align 16, !tbaa !21
  %177 = zext i8 %176 to i32
  %178 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %177)
  br label %179

179:                                              ; preds = %175, %161, %128, %74, %54
  %180 = load ptr, ptr %2, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.PDP6, ptr %180, i32 0, i32 170
  call void @waitfd(ptr noundef %181)
  store i32 0, ptr %8, align 4
  br label %182

182:                                              ; preds = %179, %39, %33, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  %183 = load i32, ptr %8, align 4
  switch i32 %183, label %185 [
    i32 0, label %184
    i32 1, label %184
  ]

184:                                              ; preds = %182, %182
  ret void

185:                                              ; preds = %182
  unreachable
}

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @getu16(ptr noundef, ptr noundef) #0

declare i32 @printf(ptr noundef, ...) #2

declare void @closefd(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden ptr @getaddr(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden ptr @getword(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden ptr @putu16(ptr noundef, i16 noundef zeroext) #0

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @putword(ptr noundef, i64 noundef) #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

declare void @waitfd(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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { noreturn nounwind "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 #5 = { nounwind }
attributes #6 = { noreturn 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, !12, i64 204}
!10 = !{!"PDP6", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !12, i64 16, !12, i64 17, !12, i64 18, !12, i64 19, !12, i64 20, !12, i64 21, !12, i64 22, !12, i64 23, !12, i64 24, !12, i64 25, !12, i64 26, !12, i64 27, !12, i64 28, !12, i64 29, !12, i64 30, !12, i64 31, !12, i64 32, !12, i64 33, !12, i64 34, !12, i64 35, !12, i64 36, !12, i64 37, !12, i64 38, !12, i64 39, !13, i64 40, !13, i64 48, !7, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !13, i64 112, !7, i64 120, !12, i64 121, !12, i64 122, !12, i64 123, !12, i64 124, !12, i64 125, !12, i64 126, !12, i64 127, !12, i64 128, !12, i64 129, !12, i64 130, !12, i64 131, !12, i64 132, !12, i64 133, !12, i64 134, !12, i64 135, !12, i64 136, !12, i64 137, !12, i64 138, !12, i64 139, !12, i64 140, !12, i64 141, !12, i64 142, !12, i64 143, !12, i64 144, !12, i64 145, !12, i64 146, !12, i64 147, !12, i64 148, !12, i64 149, !12, i64 150, !12, i64 151, !12, i64 152, !12, i64 153, !12, i64 154, !12, i64 155, !12, i64 156, !12, i64 157, !12, i64 158, !12, i64 159, !12, i64 160, !12, i64 161, !12, i64 162, !12, i64 163, !12, i64 164, !12, i64 165, !12, i64 166, !12, i64 167, !12, i64 168, !12, i64 169, !12, i64 170, !12, i64 171, !12, i64 172, !12, i64 173, !12, i64 174, !12, i64 175, !12, i64 176, !12, i64 177, !12, i64 178, !12, i64 179, !7, i64 180, !7, i64 181, !7, i64 182, !7, i64 183, !12, i64 184, !12, i64 185, !12, i64 186, !12, i64 187, !12, i64 188, !11, i64 192, !11, i64 196, !11, i64 200, !12, i64 204, !12, i64 205, !12, i64 206, !12, i64 207, !12, i64 208, !12, i64 209, !12, i64 210, !12, i64 211, !12, i64 212, !12, i64 213, !12, i64 214, !12, i64 215, !7, i64 216, !12, i64 217, !12, i64 218, !12, i64 219, !12, i64 220, !12, i64 221, !12, i64 222, !12, i64 223, !12, i64 224, !12, i64 225, !12, i64 226, !12, i64 227, !12, i64 228, !12, i64 229, !7, i64 230, !11, i64 232, !11, i64 236, !13, i64 240, !13, i64 248, !13, i64 256, !12, i64 264, !12, i64 265, !12, i64 266, !7, i64 267, !13, i64 272, !12, i64 280, !12, i64 281, !12, i64 282, !11, i64 284, !14, i64 288, !13, i64 304, !7, i64 312, !12, i64 313, !12, i64 314, !12, i64 315, !7, i64 316, !12, i64 317, !12, i64 318, !7, i64 319, !11, i64 320, !11, i64 324, !14, i64 328, !11, i64 340, !13, i64 344, !13, i64 352, !14, i64 360, !12, i64 372, !13, i64 376, !13, i64 384, !13, i64 392, !13, i64 400, !13, i64 408, !12, i64 416, !13, i64 424}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"FD", !11, i64 0, !11, i64 4, !11, i64 8}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!10, !11, i64 360}
!18 = !{!10, !11, i64 364}
!19 = !{!20, !20, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = !{!7, !7, i64 0}
!22 = !{!13, !13, i64 0}
!23 = !{!11, !11, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !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"

@handlenetmem.buf = external hidden global [2566 x i8], align 16
@.str = external hidden unnamed_addr constant [23 x i8], align 1
@memory = external local_unnamed_addr global [262144 x i64], align 16
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [58 x i8], align 1
@__PRETTY_FUNCTION__.handlenetmem = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @handlenetmem(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca i16, align 2
  %3 = alloca i16, align 2
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  %6 = getelementptr inbounds i8, ptr %0, i64 204
  %7 = load i8, ptr %6, align 4, !tbaa !5, !range !13, !noundef !14
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %105, label %9

9:                                                ; preds = %1
  %10 = getelementptr inbounds i8, ptr %0, i64 360
  %11 = load i32, ptr %10, align 8, !tbaa !15
  %12 = icmp slt i32 %11, 0
  br i1 %12, label %105, label %13

13:                                               ; preds = %9
  %14 = getelementptr inbounds i8, ptr %0, i64 364
  %15 = load i32, ptr %14, align 4, !tbaa !16
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %105, label %16

16:                                               ; preds = %13
  %17 = tail call i32 @readn(i32 noundef %11, ptr noundef nonnull @handlenetmem.buf, i32 noundef 2) #7
  %.not23 = icmp eq i32 %17, 0
  br i1 %.not23, label %18, label %105

18:                                               ; preds = %16
  %19 = call ptr @getu16(ptr noundef nonnull @handlenetmem.buf, ptr noundef nonnull %2)
  %20 = load i16, ptr %2, align 2, !tbaa !17
  %21 = icmp ugt i16 %20, 2566
  br i1 %21, label %22, label %24

22:                                               ; preds = %18
  %23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  call void @closefd(ptr noundef nonnull %10) #7
  br label %105

24:                                               ; preds = %18
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(2566) @handlenetmem.buf, i8 0, i64 2566, i1 false)
  %25 = load i32, ptr %10, align 8, !tbaa !15
  %26 = zext nneg i16 %20 to i32
  %27 = call i32 @readn(i32 noundef %25, ptr noundef nonnull @handlenetmem.buf, i32 noundef %26) #7
  %28 = call ptr @getaddr(ptr noundef nonnull getelementptr inbounds (i8, ptr @handlenetmem.buf, i64 1), ptr noundef nonnull %4)
  %29 = load i8, ptr @handlenetmem.buf, align 16, !tbaa !19
  switch i8 %29, label %101 [
    i8 1, label %30
    i8 2, label %42
    i8 5, label %56
    i8 6, label %81
  ]

30:                                               ; preds = %24
  %31 = call ptr @getword(ptr noundef %28, ptr noundef nonnull %5)
  %32 = load i64, ptr %5, align 8, !tbaa !20
  %33 = load i32, ptr %4, align 4, !tbaa !21
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds [262144 x i64], ptr @memory, i64 0, i64 %34
  store i64 %32, ptr %35, align 8, !tbaa !20
  store i16 1, ptr %2, align 2, !tbaa !17
  %36 = call ptr @putu16(ptr noundef nonnull @handlenetmem.buf, i16 noundef zeroext 1)
  store i8 3, ptr %36, align 1, !tbaa !19
  %37 = load i32, ptr %10, align 8, !tbaa !15
  %38 = load i16, ptr %2, align 2, !tbaa !17
  %39 = zext i16 %38 to i64
  %40 = add nuw nsw i64 %39, 2
  %41 = call i64 @write(i32 noundef %37, ptr noundef nonnull @handlenetmem.buf, i64 noundef %40) #7
  br label %104

42:                                               ; preds = %24
  %43 = load i32, ptr %4, align 4, !tbaa !21
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds [262144 x i64], ptr @memory, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !20
  store i64 %46, ptr %5, align 8, !tbaa !20
  store i16 6, ptr %2, align 2, !tbaa !17
  %47 = call ptr @putu16(ptr noundef nonnull @handlenetmem.buf, i16 noundef zeroext 6)
  %48 = getelementptr inbounds i8, ptr %47, i64 1
  store i8 3, ptr %47, align 1, !tbaa !19
  %49 = load i64, ptr %5, align 8, !tbaa !20
  %50 = call ptr @putword(ptr noundef nonnull %48, i64 noundef %49)
  %51 = load i32, ptr %10, align 8, !tbaa !15
  %52 = load i16, ptr %2, align 2, !tbaa !17
  %53 = zext i16 %52 to i64
  %54 = add nuw nsw i64 %53, 2
  %55 = call i64 @write(i32 noundef %51, ptr noundef nonnull @handlenetmem.buf, i64 noundef %54) #7
  br label %104

56:                                               ; preds = %24
  %57 = call ptr @getu16(ptr noundef %28, ptr noundef nonnull %3)
  %58 = load i16, ptr %3, align 2, !tbaa !17
  %59 = icmp ult i16 %58, 513
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 120, ptr noundef nonnull @__PRETTY_FUNCTION__.handlenetmem) #8
  unreachable

61:                                               ; preds = %56
  %narrow = mul nuw nsw i16 %58, 5
  %narrow25 = add nuw nsw i16 %narrow, 1
  store i16 %narrow25, ptr %2, align 2, !tbaa !17
  %62 = call ptr @putu16(ptr noundef nonnull @handlenetmem.buf, i16 noundef zeroext %narrow25)
  store i8 3, ptr %62, align 1, !tbaa !19
  %63 = load i16, ptr %3, align 2, !tbaa !17
  %64 = add i16 %63, -1
  store i16 %64, ptr %3, align 2, !tbaa !17
  %.not2629 = icmp eq i16 %63, 0
  br i1 %.not2629, label %._crit_edge33, label %.lr.ph32.preheader

.lr.ph32.preheader:                               ; preds = %61
  %65 = getelementptr inbounds i8, ptr %62, i64 1
  %.pre = load i32, ptr %4, align 4, !tbaa !21
  br label %.lr.ph32

.lr.ph32:                                         ; preds = %.lr.ph32.preheader, %.lr.ph32
  %66 = phi i32 [ %73, %.lr.ph32 ], [ %.pre, %.lr.ph32.preheader ]
  %.030 = phi ptr [ %70, %.lr.ph32 ], [ %65, %.lr.ph32.preheader ]
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds [262144 x i64], ptr @memory, i64 0, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !20
  store i64 %69, ptr %5, align 8, !tbaa !20
  %70 = call ptr @putword(ptr noundef %.030, i64 noundef %69)
  %71 = load i32, ptr %4, align 4, !tbaa !21
  %72 = add i32 %71, 1
  %73 = and i32 %72, 262143
  store i32 %73, ptr %4, align 4, !tbaa !21
  %74 = load i16, ptr %3, align 2, !tbaa !17
  %75 = add i16 %74, -1
  store i16 %75, ptr %3, align 2, !tbaa !17
  %.not26 = icmp eq i16 %74, 0
  br i1 %.not26, label %._crit_edge33, label %.lr.ph32, !llvm.loop !22

._crit_edge33:                                    ; preds = %.lr.ph32, %61
  %76 = load i32, ptr %10, align 8, !tbaa !15
  %77 = load i16, ptr %2, align 2, !tbaa !17
  %78 = zext i16 %77 to i64
  %79 = add nuw nsw i64 %78, 2
  %80 = call i64 @write(i32 noundef %76, ptr noundef nonnull @handlenetmem.buf, i64 noundef %79) #7
  br label %104

81:                                               ; preds = %24
  %82 = call ptr @getu16(ptr noundef %28, ptr noundef nonnull %3)
  %83 = load i16, ptr %3, align 2, !tbaa !17
  %84 = icmp ult i16 %83, 513
  br i1 %84, label %.preheader, label %86

.preheader:                                       ; preds = %81
  %85 = add nsw i16 %83, -1
  store i16 %85, ptr %3, align 2, !tbaa !17
  %.not2427 = icmp eq i16 %83, 0
  br i1 %.not2427, label %._crit_edge, label %.lr.ph

86:                                               ; preds = %81
  call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 138, ptr noundef nonnull @__PRETTY_FUNCTION__.handlenetmem) #8
  unreachable

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.128 = phi ptr [ %87, %.lr.ph ], [ %82, %.preheader ]
  %87 = call ptr @getword(ptr noundef %.128, ptr noundef nonnull %5)
  %88 = load i64, ptr %5, align 8, !tbaa !20
  %89 = load i32, ptr %4, align 4, !tbaa !21
  %90 = zext i32 %89 to i64
  %91 = getelementptr inbounds [262144 x i64], ptr @memory, i64 0, i64 %90
  store i64 %88, ptr %91, align 8, !tbaa !20
  %92 = add i32 %89, 1
  %93 = and i32 %92, 262143
  store i32 %93, ptr %4, align 4, !tbaa !21
  %.pr = load i16, ptr %3, align 2, !tbaa !17
  %94 = add i16 %.pr, -1
  store i16 %94, ptr %3, align 2, !tbaa !17
  %.not24 = icmp eq i16 %.pr, 0
  br i1 %.not24, label %._crit_edge, label %.lr.ph, !llvm.loop !24

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  store i16 1, ptr %2, align 2, !tbaa !17
  %95 = call ptr @putu16(ptr noundef nonnull @handlenetmem.buf, i16 noundef zeroext 1)
  store i8 3, ptr %95, align 1, !tbaa !19
  %96 = load i32, ptr %10, align 8, !tbaa !15
  %97 = load i16, ptr %2, align 2, !tbaa !17
  %98 = zext i16 %97 to i64
  %99 = add nuw nsw i64 %98, 2
  %100 = call i64 @write(i32 noundef %96, ptr noundef nonnull @handlenetmem.buf, i64 noundef %99) #7
  br label %104

101:                                              ; preds = %24
  %102 = zext i8 %29 to i32
  %103 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %102)
  br label %104

104:                                              ; preds = %101, %._crit_edge, %._crit_edge33, %42, %30
  call void @waitfd(ptr noundef nonnull %10) #7
  br label %105

105:                                              ; preds = %16, %1, %9, %13, %104, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %2) #7
  ret void
}

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

declare i32 @readn(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden ptr @getu16(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

declare void @closefd(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden ptr @getaddr(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden ptr @getword(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden ptr @putu16(ptr noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden ptr @putword(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #6

declare void @waitfd(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress 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 = { mustprogress 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 = { nofree nounwind "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nofree "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 = { noreturn nounwind "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 #7 = { nounwind }
attributes #8 = { noreturn 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, !10, i64 204}
!6 = !{!"PDP6", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 17, !10, i64 18, !10, i64 19, !10, i64 20, !10, i64 21, !10, i64 22, !10, i64 23, !10, i64 24, !10, i64 25, !10, i64 26, !10, i64 27, !10, i64 28, !10, i64 29, !10, i64 30, !10, i64 31, !10, i64 32, !10, i64 33, !10, i64 34, !10, i64 35, !10, i64 36, !10, i64 37, !10, i64 38, !10, i64 39, !11, i64 40, !11, i64 48, !8, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100, !7, i64 104, !7, i64 108, !11, i64 112, !8, i64 120, !10, i64 121, !10, i64 122, !10, i64 123, !10, i64 124, !10, i64 125, !10, i64 126, !10, i64 127, !10, i64 128, !10, i64 129, !10, i64 130, !10, i64 131, !10, i64 132, !10, i64 133, !10, i64 134, !10, i64 135, !10, i64 136, !10, i64 137, !10, i64 138, !10, i64 139, !10, i64 140, !10, i64 141, !10, i64 142, !10, i64 143, !10, i64 144, !10, i64 145, !10, i64 146, !10, i64 147, !10, i64 148, !10, i64 149, !10, i64 150, !10, i64 151, !10, i64 152, !10, i64 153, !10, i64 154, !10, i64 155, !10, i64 156, !10, i64 157, !10, i64 158, !10, i64 159, !10, i64 160, !10, i64 161, !10, i64 162, !10, i64 163, !10, i64 164, !10, i64 165, !10, i64 166, !10, i64 167, !10, i64 168, !10, i64 169, !10, i64 170, !10, i64 171, !10, i64 172, !10, i64 173, !10, i64 174, !10, i64 175, !10, i64 176, !10, i64 177, !10, i64 178, !10, i64 179, !8, i64 180, !8, i64 181, !8, i64 182, !8, i64 183, !10, i64 184, !10, i64 185, !10, i64 186, !10, i64 187, !10, i64 188, !7, i64 192, !7, i64 196, !7, i64 200, !10, i64 204, !10, i64 205, !10, i64 206, !10, i64 207, !10, i64 208, !10, i64 209, !10, i64 210, !10, i64 211, !10, i64 212, !10, i64 213, !10, i64 214, !10, i64 215, !8, i64 216, !10, i64 217, !10, i64 218, !10, i64 219, !10, i64 220, !10, i64 221, !10, i64 222, !10, i64 223, !10, i64 224, !10, i64 225, !10, i64 226, !10, i64 227, !10, i64 228, !10, i64 229, !8, i64 230, !7, i64 232, !7, i64 236, !11, i64 240, !11, i64 248, !11, i64 256, !10, i64 264, !10, i64 265, !10, i64 266, !8, i64 267, !11, i64 272, !10, i64 280, !10, i64 281, !10, i64 282, !7, i64 284, !12, i64 288, !11, i64 304, !8, i64 312, !10, i64 313, !10, i64 314, !10, i64 315, !8, i64 316, !10, i64 317, !10, i64 318, !8, i64 319, !7, i64 320, !7, i64 324, !12, i64 328, !7, i64 340, !11, i64 344, !11, i64 352, !12, i64 360, !10, i64 372, !11, i64 376, !11, i64 384, !11, i64 392, !11, i64 400, !11, i64 408, !10, i64 416, !11, i64 424}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!"long long", !8, i64 0}
!12 = !{!"FD", !7, i64 0, !7, i64 4, !7, i64 8}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!6, !7, i64 360}
!16 = !{!6, !7, i64 364}
!17 = !{!18, !18, i64 0}
!18 = !{!"short", !8, i64 0}
!19 = !{!8, !8, i64 0}
!20 = !{!11, !11, i64 0}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass