; LLVM IR from BrunoLevy/learn-fpga :: LiteX/software/Doom/mc1-doom/src (i_net)

; 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.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.doomdata_t = type { i32, i8, i8, i8, i8, [12 x %struct.ticcmd_t] }
%struct.ticcmd_t = type { i8, i8, i16, i16, i8, i8 }
%struct.doomcom_t = type { i64, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, %struct.doomdata_t }

@netbuffer = external global ptr, align 8
@doomcom = external global ptr, align 8
@sendaddress = external dso_local global [8 x %struct.sockaddr_in], align 16
@insocket = external dso_local global i32, align 4
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@PacketGet.first = external hidden global i32, align 4
@.str.3 = external hidden unnamed_addr constant [23 x 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: noreturn
declare void @I_Error(ptr noundef, ...) #1

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @__bswap_32(i32 noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i16 @__bswap_16(i16 noundef zeroext) #4

; Function Attrs: nounwind uwtable
define dso_local void @PacketGet() #5 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %struct.sockaddr_in, align 4
  %4 = alloca i32, align 4
  %5 = alloca %struct.doomdata_t, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 104, ptr %5) #7
  store i32 16, ptr %4, align 4, !tbaa !5
  %7 = load i32, ptr @insocket, align 4, !tbaa !5
  %8 = call i64 @recvfrom(i32 noundef %7, ptr noundef %5, i64 noundef 104, i32 noundef 0, ptr noundef %3, ptr noundef %4)
  %9 = trunc i64 %8 to i32
  store i32 %9, ptr %2, align 4, !tbaa !5
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = icmp eq i32 %10, -1
  br i1 %11, label %12, label %23

12:                                               ; preds = %0
  %13 = call ptr @__errno_location() #8
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = icmp ne i32 %14, 11
  br i1 %15, label %16, label %20

16:                                               ; preds = %12
  %17 = call ptr @__errno_location() #8
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = call ptr @strerror(i32 noundef %18) #7
  call void (ptr, ...) @I_Error(ptr noundef @.str.2, ptr noundef %19) #9
  unreachable

20:                                               ; preds = %12
  %21 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.doomcom_t, ptr %21, i32 0, i32 3
  store i16 -1, ptr %22, align 4, !tbaa !11
  store i32 1, ptr %6, align 4
  br label %182

23:                                               ; preds = %0
  %24 = load i32, ptr @PacketGet.first, align 4, !tbaa !5
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %32

26:                                               ; preds = %23
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = getelementptr inbounds i32, ptr %5, i64 1
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %27, i32 noundef %28, i32 noundef %30)
  br label %32

32:                                               ; preds = %26, %23
  store i32 0, ptr @PacketGet.first, align 4, !tbaa !5
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %53, %32
  %34 = load i32, ptr %1, align 4, !tbaa !5
  %35 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.doomcom_t, ptr %35, i32 0, i32 5
  %37 = load i16, ptr %36, align 8, !tbaa !16
  %38 = sext i16 %37 to i32
  %39 = icmp slt i32 %34, %38
  br i1 %39, label %40, label %56

40:                                               ; preds = %33
  %41 = getelementptr inbounds %struct.sockaddr_in, ptr %3, i32 0, i32 2
  %42 = getelementptr inbounds %struct.in_addr, ptr %41, i32 0, i32 0
  %43 = load i32, ptr %42, align 4, !tbaa !17
  %44 = load i32, ptr %1, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [8 x %struct.sockaddr_in], ptr @sendaddress, i64 0, i64 %45
  %47 = getelementptr inbounds %struct.sockaddr_in, ptr %46, i32 0, i32 2
  %48 = getelementptr inbounds %struct.in_addr, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 4, !tbaa !17
  %50 = icmp eq i32 %43, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %40
  br label %56

52:                                               ; preds = %40
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %1, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %1, align 4, !tbaa !5
  br label %33, !llvm.loop !20

56:                                               ; preds = %51, %33
  %57 = load i32, ptr %1, align 4, !tbaa !5
  %58 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.doomcom_t, ptr %58, i32 0, i32 5
  %60 = load i16, ptr %59, align 8, !tbaa !16
  %61 = sext i16 %60 to i32
  %62 = icmp eq i32 %57, %61
  br i1 %62, label %63, label %66

63:                                               ; preds = %56
  %64 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.doomcom_t, ptr %64, i32 0, i32 3
  store i16 -1, ptr %65, align 4, !tbaa !11
  store i32 1, ptr %6, align 4
  br label %182

66:                                               ; preds = %56
  %67 = load i32, ptr %1, align 4, !tbaa !5
  %68 = trunc i32 %67 to i16
  %69 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.doomcom_t, ptr %69, i32 0, i32 3
  store i16 %68, ptr %70, align 4, !tbaa !11
  %71 = load i32, ptr %2, align 4, !tbaa !5
  %72 = trunc i32 %71 to i16
  %73 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %74 = getelementptr inbounds %struct.doomcom_t, ptr %73, i32 0, i32 4
  store i16 %72, ptr %74, align 2, !tbaa !22
  %75 = getelementptr inbounds %struct.doomdata_t, ptr %5, i32 0, i32 0
  %76 = load i32, ptr %75, align 4, !tbaa !23
  %77 = call i32 @__bswap_32(i32 noundef %76)
  %78 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %79 = getelementptr inbounds %struct.doomdata_t, ptr %78, i32 0, i32 0
  store i32 %77, ptr %79, align 4, !tbaa !23
  %80 = getelementptr inbounds %struct.doomdata_t, ptr %5, i32 0, i32 3
  %81 = load i8, ptr %80, align 2, !tbaa !24
  %82 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct.doomdata_t, ptr %82, i32 0, i32 3
  store i8 %81, ptr %83, align 2, !tbaa !24
  %84 = getelementptr inbounds %struct.doomdata_t, ptr %5, i32 0, i32 1
  %85 = load i8, ptr %84, align 4, !tbaa !25
  %86 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %87 = getelementptr inbounds %struct.doomdata_t, ptr %86, i32 0, i32 1
  store i8 %85, ptr %87, align 4, !tbaa !25
  %88 = getelementptr inbounds %struct.doomdata_t, ptr %5, i32 0, i32 2
  %89 = load i8, ptr %88, align 1, !tbaa !26
  %90 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct.doomdata_t, ptr %90, i32 0, i32 2
  store i8 %89, ptr %91, align 1, !tbaa !26
  %92 = getelementptr inbounds %struct.doomdata_t, ptr %5, i32 0, i32 4
  %93 = load i8, ptr %92, align 1, !tbaa !27
  %94 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %95 = getelementptr inbounds %struct.doomdata_t, ptr %94, i32 0, i32 4
  store i8 %93, ptr %95, align 1, !tbaa !27
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %178, %66
  %97 = load i32, ptr %2, align 4, !tbaa !5
  %98 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %99 = getelementptr inbounds %struct.doomdata_t, ptr %98, i32 0, i32 4
  %100 = load i8, ptr %99, align 1, !tbaa !27
  %101 = zext i8 %100 to i32
  %102 = icmp slt i32 %97, %101
  br i1 %102, label %103, label %181

103:                                              ; preds = %96
  %104 = getelementptr inbounds %struct.doomdata_t, ptr %5, i32 0, i32 5
  %105 = load i32, ptr %2, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %104, i64 0, i64 %106
  %108 = getelementptr inbounds %struct.ticcmd_t, ptr %107, i32 0, i32 0
  %109 = load i8, ptr %108, align 4, !tbaa !28
  %110 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %111 = getelementptr inbounds %struct.doomdata_t, ptr %110, i32 0, i32 5
  %112 = load i32, ptr %2, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %111, i64 0, i64 %113
  %115 = getelementptr inbounds %struct.ticcmd_t, ptr %114, i32 0, i32 0
  store i8 %109, ptr %115, align 4, !tbaa !28
  %116 = getelementptr inbounds %struct.doomdata_t, ptr %5, i32 0, i32 5
  %117 = load i32, ptr %2, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %116, i64 0, i64 %118
  %120 = getelementptr inbounds %struct.ticcmd_t, ptr %119, i32 0, i32 1
  %121 = load i8, ptr %120, align 1, !tbaa !30
  %122 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %123 = getelementptr inbounds %struct.doomdata_t, ptr %122, i32 0, i32 5
  %124 = load i32, ptr %2, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %123, i64 0, i64 %125
  %127 = getelementptr inbounds %struct.ticcmd_t, ptr %126, i32 0, i32 1
  store i8 %121, ptr %127, align 1, !tbaa !30
  %128 = getelementptr inbounds %struct.doomdata_t, ptr %5, i32 0, i32 5
  %129 = load i32, ptr %2, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %128, i64 0, i64 %130
  %132 = getelementptr inbounds %struct.ticcmd_t, ptr %131, i32 0, i32 2
  %133 = load i16, ptr %132, align 2, !tbaa !31
  %134 = call zeroext i16 @__bswap_16(i16 noundef zeroext %133)
  %135 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %136 = getelementptr inbounds %struct.doomdata_t, ptr %135, i32 0, i32 5
  %137 = load i32, ptr %2, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %136, i64 0, i64 %138
  %140 = getelementptr inbounds %struct.ticcmd_t, ptr %139, i32 0, i32 2
  store i16 %134, ptr %140, align 2, !tbaa !31
  %141 = getelementptr inbounds %struct.doomdata_t, ptr %5, i32 0, i32 5
  %142 = load i32, ptr %2, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %141, i64 0, i64 %143
  %145 = getelementptr inbounds %struct.ticcmd_t, ptr %144, i32 0, i32 3
  %146 = load i16, ptr %145, align 4, !tbaa !32
  %147 = call zeroext i16 @__bswap_16(i16 noundef zeroext %146)
  %148 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %149 = getelementptr inbounds %struct.doomdata_t, ptr %148, i32 0, i32 5
  %150 = load i32, ptr %2, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %149, i64 0, i64 %151
  %153 = getelementptr inbounds %struct.ticcmd_t, ptr %152, i32 0, i32 3
  store i16 %147, ptr %153, align 4, !tbaa !32
  %154 = getelementptr inbounds %struct.doomdata_t, ptr %5, i32 0, i32 5
  %155 = load i32, ptr %2, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %154, i64 0, i64 %156
  %158 = getelementptr inbounds %struct.ticcmd_t, ptr %157, i32 0, i32 4
  %159 = load i8, ptr %158, align 2, !tbaa !33
  %160 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %161 = getelementptr inbounds %struct.doomdata_t, ptr %160, i32 0, i32 5
  %162 = load i32, ptr %2, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %161, i64 0, i64 %163
  %165 = getelementptr inbounds %struct.ticcmd_t, ptr %164, i32 0, i32 4
  store i8 %159, ptr %165, align 2, !tbaa !33
  %166 = getelementptr inbounds %struct.doomdata_t, ptr %5, i32 0, i32 5
  %167 = load i32, ptr %2, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %166, i64 0, i64 %168
  %170 = getelementptr inbounds %struct.ticcmd_t, ptr %169, i32 0, i32 5
  %171 = load i8, ptr %170, align 1, !tbaa !34
  %172 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %173 = getelementptr inbounds %struct.doomdata_t, ptr %172, i32 0, i32 5
  %174 = load i32, ptr %2, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %173, i64 0, i64 %175
  %177 = getelementptr inbounds %struct.ticcmd_t, ptr %176, i32 0, i32 5
  store i8 %171, ptr %177, align 1, !tbaa !34
  br label %178

178:                                              ; preds = %103
  %179 = load i32, ptr %2, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %2, align 4, !tbaa !5
  br label %96, !llvm.loop !35

181:                                              ; preds = %96
  store i32 0, ptr %6, align 4
  br label %182

182:                                              ; preds = %181, %63, %20
  call void @llvm.lifetime.end.p0(i64 104, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #7
  %183 = load i32, ptr %6, 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
}

declare i64 @recvfrom(i32 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef) #6

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn "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 "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 willreturn memory(none) "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 = { 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 #5 = { 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 #6 = { "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 = { nounwind willreturn memory(none) }
attributes #9 = { noreturn }

!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, !14, i64 12}
!12 = !{!"", !13, i64 0, !14, i64 8, !14, i64 10, !14, i64 12, !14, i64 14, !14, i64 16, !14, i64 18, !14, i64 20, !14, i64 22, !14, i64 24, !14, i64 26, !14, i64 28, !14, i64 30, !14, i64 32, !14, i64 34, !14, i64 36, !14, i64 38, !15, i64 40}
!13 = !{!"long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!"", !6, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8}
!16 = !{!12, !14, i64 16}
!17 = !{!18, !6, i64 4}
!18 = !{!"sockaddr_in", !14, i64 0, !14, i64 2, !19, i64 4, !7, i64 8}
!19 = !{!"in_addr", !6, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!12, !14, i64 14}
!23 = !{!15, !6, i64 0}
!24 = !{!15, !7, i64 6}
!25 = !{!15, !7, i64 4}
!26 = !{!15, !7, i64 5}
!27 = !{!15, !7, i64 7}
!28 = !{!29, !7, i64 0}
!29 = !{!"", !7, i64 0, !7, i64 1, !14, i64 2, !14, i64 4, !7, i64 6, !7, i64 7}
!30 = !{!29, !7, i64 1}
!31 = !{!29, !14, i64 2}
!32 = !{!29, !14, i64 4}
!33 = !{!29, !7, i64 6}
!34 = !{!29, !7, i64 7}
!35 = distinct !{!35, !21}


; 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.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.doomdata_t = type { i32, i8, i8, i8, i8, [12 x %struct.ticcmd_t] }
%struct.ticcmd_t = type { i8, i8, i16, i16, i8, i8 }

@netbuffer = external local_unnamed_addr global ptr, align 8
@doomcom = external local_unnamed_addr global ptr, align 8
@sendaddress = external dso_local local_unnamed_addr global [8 x %struct.sockaddr_in], align 16
@insocket = external dso_local local_unnamed_addr global i32, align 4
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@PacketGet.first = external hidden local_unnamed_addr global i32, align 4
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1

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

; Function Attrs: noreturn
declare void @I_Error(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #3

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @__bswap_32(i32 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i16 @__bswap_16(i16 noundef zeroext) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local void @PacketGet() local_unnamed_addr #5 {
  %1 = alloca %struct.sockaddr_in, align 4
  %2 = alloca i32, align 4
  %3 = alloca %struct.doomdata_t, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %3) #8
  store i32 16, ptr %2, align 4, !tbaa !5
  %4 = load i32, ptr @insocket, align 4, !tbaa !5
  %5 = call i64 @recvfrom(i32 noundef %4, ptr noundef nonnull %3, i64 noundef 104, i32 noundef 0, ptr noundef nonnull %1, ptr noundef nonnull %2) #8
  %6 = trunc i64 %5 to i32
  %7 = icmp eq i32 %6, -1
  br i1 %7, label %8, label %15

8:                                                ; preds = %0
  %9 = tail call ptr @__errno_location() #9
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %.not25 = icmp eq i32 %10, 11
  br i1 %.not25, label %13, label %11

11:                                               ; preds = %8
  %12 = call ptr @strerror(i32 noundef %10) #8
  call void (ptr, ...) @I_Error(ptr noundef nonnull @.str.2, ptr noundef %12) #10
  unreachable

13:                                               ; preds = %8
  %14 = load ptr, ptr @doomcom, align 8, !tbaa !9
  br label %.loopexit.sink.split

15:                                               ; preds = %0
  %16 = load i32, ptr @PacketGet.first, align 4, !tbaa !5
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %22, label %17

17:                                               ; preds = %15
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %3, i64 4
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %6, i32 noundef %18, i32 noundef %20)
  br label %22

22:                                               ; preds = %17, %15
  store i32 0, ptr @PacketGet.first, align 4, !tbaa !5
  %23 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %24 = getelementptr inbounds i8, ptr %23, i64 16
  %25 = load i16, ptr %24, align 8, !tbaa !11
  %26 = sext i16 %25 to i32
  %27 = icmp sgt i16 %25, 0
  br i1 %27, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %22
  %28 = getelementptr inbounds i8, ptr %1, i64 4
  %29 = load i32, ptr %28, align 4, !tbaa !16
  %wide.trip.count = zext nneg i32 %26 to i64
  br label %30

30:                                               ; preds = %.lr.ph, %34
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %34 ]
  %31 = getelementptr inbounds [8 x %struct.sockaddr_in], ptr @sendaddress, i64 0, i64 %indvars.iv, i32 2
  %32 = load i32, ptr %31, align 4, !tbaa !16
  %33 = icmp eq i32 %29, %32
  br i1 %33, label %._crit_edge.loopexit, label %34

34:                                               ; preds = %30
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit.sink.split, label %30, !llvm.loop !19

._crit_edge.loopexit:                             ; preds = %30
  %35 = trunc nuw nsw i64 %indvars.iv to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %22
  %.022.lcssa = phi i32 [ 0, %22 ], [ %35, %._crit_edge.loopexit ]
  %36 = icmp eq i32 %.022.lcssa, %26
  br i1 %36, label %.loopexit.sink.split, label %37

37:                                               ; preds = %._crit_edge
  %38 = trunc i32 %.022.lcssa to i16
  %39 = getelementptr inbounds i8, ptr %23, i64 12
  store i16 %38, ptr %39, align 4, !tbaa !21
  %40 = trunc i64 %5 to i16
  %41 = getelementptr inbounds i8, ptr %23, i64 14
  store i16 %40, ptr %41, align 2, !tbaa !22
  %42 = load i32, ptr %3, align 4, !tbaa !23
  %43 = call i32 @__bswap_32(i32 noundef %42)
  %44 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  store i32 %43, ptr %44, align 4, !tbaa !23
  %45 = getelementptr inbounds i8, ptr %3, i64 4
  %46 = getelementptr inbounds i8, ptr %44, i64 4
  %47 = load <4 x i8>, ptr %45, align 4, !tbaa !24
  store <4 x i8> %47, ptr %46, align 4, !tbaa !24
  %48 = extractelement <4 x i8> %47, i64 3
  %.not37 = icmp eq i8 %48, 0
  br i1 %.not37, label %.loopexit, label %.lr.ph36

.lr.ph36:                                         ; preds = %37
  %49 = getelementptr inbounds i8, ptr %3, i64 8
  br label %50

50:                                               ; preds = %.lr.ph36, %50
  %indvars.iv39 = phi i64 [ 0, %.lr.ph36 ], [ %indvars.iv.next40, %50 ]
  %51 = phi ptr [ %44, %.lr.ph36 ], [ %68, %50 ]
  %52 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %49, i64 0, i64 %indvars.iv39
  %53 = load i8, ptr %52, align 4, !tbaa !25
  %54 = getelementptr inbounds i8, ptr %51, i64 8
  %55 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %54, i64 0, i64 %indvars.iv39
  store i8 %53, ptr %55, align 4, !tbaa !25
  %56 = getelementptr inbounds i8, ptr %52, i64 1
  %57 = load i8, ptr %56, align 1, !tbaa !27
  %58 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %54, i64 0, i64 %indvars.iv39, i32 1
  store i8 %57, ptr %58, align 1, !tbaa !27
  %59 = getelementptr inbounds i8, ptr %52, i64 2
  %60 = load i16, ptr %59, align 2, !tbaa !28
  %61 = call zeroext i16 @__bswap_16(i16 noundef zeroext %60)
  %62 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %63 = getelementptr inbounds i8, ptr %62, i64 8
  %64 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %63, i64 0, i64 %indvars.iv39, i32 2
  store i16 %61, ptr %64, align 2, !tbaa !28
  %65 = getelementptr inbounds i8, ptr %52, i64 4
  %66 = load i16, ptr %65, align 4, !tbaa !29
  %67 = call zeroext i16 @__bswap_16(i16 noundef zeroext %66)
  %68 = load ptr, ptr @netbuffer, align 8, !tbaa !9
  %69 = getelementptr inbounds i8, ptr %68, i64 8
  %70 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %69, i64 0, i64 %indvars.iv39, i32 3
  store i16 %67, ptr %70, align 4, !tbaa !29
  %71 = getelementptr inbounds i8, ptr %52, i64 6
  %72 = load i8, ptr %71, align 2, !tbaa !30
  %73 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %69, i64 0, i64 %indvars.iv39, i32 4
  store i8 %72, ptr %73, align 2, !tbaa !30
  %74 = getelementptr inbounds i8, ptr %52, i64 7
  %75 = load i8, ptr %74, align 1, !tbaa !31
  %76 = getelementptr inbounds [12 x %struct.ticcmd_t], ptr %69, i64 0, i64 %indvars.iv39, i32 5
  store i8 %75, ptr %76, align 1, !tbaa !31
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %77 = getelementptr inbounds i8, ptr %68, i64 7
  %78 = load i8, ptr %77, align 1, !tbaa !32
  %79 = zext i8 %78 to i64
  %80 = icmp ult i64 %indvars.iv.next40, %79
  br i1 %80, label %50, label %.loopexit, !llvm.loop !33

.loopexit.sink.split:                             ; preds = %34, %._crit_edge, %13
  %.sink44 = phi ptr [ %14, %13 ], [ %23, %._crit_edge ], [ %23, %34 ]
  %81 = getelementptr inbounds i8, ptr %.sink44, i64 12
  store i16 -1, ptr %81, align 4, !tbaa !21
  br label %.loopexit

.loopexit:                                        ; preds = %50, %.loopexit.sink.split, %37
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #8
  ret void
}

declare i64 @recvfrom(i32 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #6

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn "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 "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 nosync nounwind willreturn memory(none) "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 = { 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 #5 = { 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 #6 = { "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 = { 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 #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(none) }
attributes #10 = { 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 = !{!"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, !14, i64 16}
!12 = !{!"", !13, i64 0, !14, i64 8, !14, i64 10, !14, i64 12, !14, i64 14, !14, i64 16, !14, i64 18, !14, i64 20, !14, i64 22, !14, i64 24, !14, i64 26, !14, i64 28, !14, i64 30, !14, i64 32, !14, i64 34, !14, i64 36, !14, i64 38, !15, i64 40}
!13 = !{!"long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!"", !6, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8}
!16 = !{!17, !6, i64 4}
!17 = !{!"sockaddr_in", !14, i64 0, !14, i64 2, !18, i64 4, !7, i64 8}
!18 = !{!"in_addr", !6, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!12, !14, i64 12}
!22 = !{!12, !14, i64 14}
!23 = !{!15, !6, i64 0}
!24 = !{!7, !7, i64 0}
!25 = !{!26, !7, i64 0}
!26 = !{!"", !7, i64 0, !7, i64 1, !14, i64 2, !14, i64 4, !7, i64 6, !7, i64 7}
!27 = !{!26, !7, i64 1}
!28 = !{!26, !14, i64 2}
!29 = !{!26, !14, i64 4}
!30 = !{!26, !7, i64 6}
!31 = !{!26, !7, i64 7}
!32 = !{!15, !7, i64 7}
!33 = distinct !{!33, !20}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass