; 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.doomcom_t = type { i64, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, %struct.doomdata_t }
%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.hostent = type { ptr, ptr, i32, i32, ptr }

@DOOMPORT = external dso_local global i32, align 4
@sendsocket = external dso_local global i32, align 4
@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.6 = external hidden unnamed_addr constant [5 x i8], align 1
@myargc = external global i32, align 4
@myargv = external global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [5 x i8], align 1
@netgame = external global i32, align 4
@netsend = external dso_local global ptr, align 8
@netget = external dso_local global ptr, align 8
@.str.11 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @UDPsocket() #0

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @BindToLocalPort(i32 noundef, i32 noundef) #0

; 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 dso_local void @PacketSend() #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @PacketGet() #0

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

declare ptr @gethostbyname(ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local void @I_InitNetwork() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #9
  store i32 1, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #9
  %6 = call noalias ptr @malloc(i64 noundef 144) #10
  store ptr %6, ptr @doomcom, align 8, !tbaa !9
  %7 = load ptr, ptr @doomcom, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 8 %7, i8 0, i64 144, i1 false)
  %8 = call i32 @M_CheckParm(ptr noundef @.str.6)
  store i32 %8, ptr %2, align 4, !tbaa !5
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %48

11:                                               ; preds = %0
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = load i32, ptr @myargc, align 4, !tbaa !5
  %14 = sub nsw i32 %13, 1
  %15 = icmp slt i32 %12, %14
  br i1 %15, label %16, label %48

16:                                               ; preds = %11
  %17 = load ptr, ptr @myargv, align 8, !tbaa !9
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds ptr, ptr %17, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %22, i64 0
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = sext i8 %24 to i32
  %26 = sub nsw i32 %25, 48
  %27 = trunc i32 %26 to i16
  %28 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.doomcom_t, ptr %28, i32 0, i32 6
  store i16 %27, ptr %29, align 2, !tbaa !12
  %30 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.doomcom_t, ptr %30, i32 0, i32 6
  %32 = load i16, ptr %31, align 2, !tbaa !12
  %33 = sext i16 %32 to i32
  %34 = icmp slt i32 %33, 1
  br i1 %34, label %35, label %38

35:                                               ; preds = %16
  %36 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.doomcom_t, ptr %36, i32 0, i32 6
  store i16 1, ptr %37, align 2, !tbaa !12
  br label %38

38:                                               ; preds = %35, %16
  %39 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.doomcom_t, ptr %39, i32 0, i32 6
  %41 = load i16, ptr %40, align 2, !tbaa !12
  %42 = sext i16 %41 to i32
  %43 = icmp sgt i32 %42, 9
  br i1 %43, label %44, label %47

44:                                               ; preds = %38
  %45 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.doomcom_t, ptr %45, i32 0, i32 6
  store i16 9, ptr %46, align 2, !tbaa !12
  br label %47

47:                                               ; preds = %44, %38
  br label %51

48:                                               ; preds = %11, %0
  %49 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.doomcom_t, ptr %49, i32 0, i32 6
  store i16 1, ptr %50, align 2, !tbaa !12
  br label %51

51:                                               ; preds = %48, %47
  %52 = call i32 @M_CheckParm(ptr noundef @.str.7)
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %57

54:                                               ; preds = %51
  %55 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.doomcom_t, ptr %55, i32 0, i32 7
  store i16 1, ptr %56, align 4, !tbaa !17
  br label %60

57:                                               ; preds = %51
  %58 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.doomcom_t, ptr %58, i32 0, i32 7
  store i16 0, ptr %59, align 4, !tbaa !17
  br label %60

60:                                               ; preds = %57, %54
  %61 = call i32 @M_CheckParm(ptr noundef @.str.8)
  store i32 %61, ptr %3, align 4, !tbaa !5
  %62 = load i32, ptr %3, align 4, !tbaa !5
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %79

64:                                               ; preds = %60
  %65 = load i32, ptr %3, align 4, !tbaa !5
  %66 = load i32, ptr @myargc, align 4, !tbaa !5
  %67 = sub nsw i32 %66, 1
  %68 = icmp slt i32 %65, %67
  br i1 %68, label %69, label %79

69:                                               ; preds = %64
  %70 = load ptr, ptr @myargv, align 8, !tbaa !9
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds ptr, ptr %70, i64 %73
  %75 = load ptr, ptr %74, align 8, !tbaa !9
  %76 = call i32 @atoi(ptr noundef %75) #11
  store i32 %76, ptr @DOOMPORT, align 4, !tbaa !5
  %77 = load i32, ptr @DOOMPORT, align 4, !tbaa !5
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, i32 noundef %77)
  br label %79

79:                                               ; preds = %69, %64, %60
  %80 = call i32 @M_CheckParm(ptr noundef @.str.10)
  store i32 %80, ptr %2, align 4, !tbaa !5
  %81 = load i32, ptr %2, align 4, !tbaa !5
  %82 = icmp ne i32 %81, 0
  br i1 %82, label %94, label %83

83:                                               ; preds = %79
  store i32 0, ptr @netgame, align 4, !tbaa !5
  %84 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %85 = getelementptr inbounds %struct.doomcom_t, ptr %84, i32 0, i32 0
  store i64 305419896, ptr %85, align 8, !tbaa !18
  %86 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %87 = getelementptr inbounds %struct.doomcom_t, ptr %86, i32 0, i32 5
  store i16 1, ptr %87, align 8, !tbaa !19
  %88 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.doomcom_t, ptr %88, i32 0, i32 14
  store i16 1, ptr %89, align 2, !tbaa !20
  %90 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct.doomcom_t, ptr %90, i32 0, i32 8
  store i16 0, ptr %91, align 2, !tbaa !21
  %92 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %93 = getelementptr inbounds %struct.doomcom_t, ptr %92, i32 0, i32 13
  store i16 0, ptr %93, align 8, !tbaa !22
  store i32 1, ptr %5, align 4
  br label %220

94:                                               ; preds = %79
  store ptr @PacketSend, ptr @netsend, align 8, !tbaa !9
  store ptr @PacketGet, ptr @netget, align 8, !tbaa !9
  store i32 1, ptr @netgame, align 4, !tbaa !5
  %95 = load ptr, ptr @myargv, align 8, !tbaa !9
  %96 = load i32, ptr %2, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds ptr, ptr %95, i64 %98
  %100 = load ptr, ptr %99, align 8, !tbaa !9
  %101 = getelementptr inbounds i8, ptr %100, i64 0
  %102 = load i8, ptr %101, align 1, !tbaa !11
  %103 = sext i8 %102 to i32
  %104 = sub nsw i32 %103, 49
  %105 = trunc i32 %104 to i16
  %106 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %107 = getelementptr inbounds %struct.doomcom_t, ptr %106, i32 0, i32 13
  store i16 %105, ptr %107, align 8, !tbaa !22
  %108 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %109 = getelementptr inbounds %struct.doomcom_t, ptr %108, i32 0, i32 5
  store i16 1, ptr %109, align 8, !tbaa !19
  %110 = load i32, ptr %2, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %2, align 4, !tbaa !5
  br label %112

112:                                              ; preds = %198, %94
  %113 = load i32, ptr %2, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %2, align 4, !tbaa !5
  %115 = load i32, ptr @myargc, align 4, !tbaa !5
  %116 = icmp slt i32 %114, %115
  br i1 %116, label %117, label %127

117:                                              ; preds = %112
  %118 = load ptr, ptr @myargv, align 8, !tbaa !9
  %119 = load i32, ptr %2, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds ptr, ptr %118, i64 %120
  %122 = load ptr, ptr %121, align 8, !tbaa !9
  %123 = getelementptr inbounds i8, ptr %122, i64 0
  %124 = load i8, ptr %123, align 1, !tbaa !11
  %125 = sext i8 %124 to i32
  %126 = icmp ne i32 %125, 45
  br label %127

127:                                              ; preds = %117, %112
  %128 = phi i1 [ false, %112 ], [ %126, %117 ]
  br i1 %128, label %129, label %203

129:                                              ; preds = %127
  %130 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %131 = getelementptr inbounds %struct.doomcom_t, ptr %130, i32 0, i32 5
  %132 = load i16, ptr %131, align 8, !tbaa !19
  %133 = sext i16 %132 to i64
  %134 = getelementptr inbounds [8 x %struct.sockaddr_in], ptr @sendaddress, i64 0, i64 %133
  %135 = getelementptr inbounds %struct.sockaddr_in, ptr %134, i32 0, i32 0
  store i16 2, ptr %135, align 16, !tbaa !23
  %136 = load i32, ptr @DOOMPORT, align 4, !tbaa !5
  %137 = trunc i32 %136 to i16
  %138 = call zeroext i16 @__bswap_16(i16 noundef zeroext %137)
  %139 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %140 = getelementptr inbounds %struct.doomcom_t, ptr %139, i32 0, i32 5
  %141 = load i16, ptr %140, align 8, !tbaa !19
  %142 = sext i16 %141 to i64
  %143 = getelementptr inbounds [8 x %struct.sockaddr_in], ptr @sendaddress, i64 0, i64 %142
  %144 = getelementptr inbounds %struct.sockaddr_in, ptr %143, i32 0, i32 1
  store i16 %138, ptr %144, align 2, !tbaa !26
  %145 = load ptr, ptr @myargv, align 8, !tbaa !9
  %146 = load i32, ptr %2, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds ptr, ptr %145, i64 %147
  %149 = load ptr, ptr %148, align 8, !tbaa !9
  %150 = getelementptr inbounds i8, ptr %149, i64 0
  %151 = load i8, ptr %150, align 1, !tbaa !11
  %152 = sext i8 %151 to i32
  %153 = icmp eq i32 %152, 46
  br i1 %153, label %154, label %169

154:                                              ; preds = %129
  %155 = load ptr, ptr @myargv, align 8, !tbaa !9
  %156 = load i32, ptr %2, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds ptr, ptr %155, i64 %157
  %159 = load ptr, ptr %158, align 8, !tbaa !9
  %160 = getelementptr inbounds i8, ptr %159, i64 1
  %161 = call i32 @inet_addr(ptr noundef %160) #9
  %162 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %163 = getelementptr inbounds %struct.doomcom_t, ptr %162, i32 0, i32 5
  %164 = load i16, ptr %163, align 8, !tbaa !19
  %165 = sext i16 %164 to i64
  %166 = getelementptr inbounds [8 x %struct.sockaddr_in], ptr @sendaddress, i64 0, i64 %165
  %167 = getelementptr inbounds %struct.sockaddr_in, ptr %166, i32 0, i32 2
  %168 = getelementptr inbounds %struct.in_addr, ptr %167, i32 0, i32 0
  store i32 %161, ptr %168, align 4, !tbaa !27
  br label %198

169:                                              ; preds = %129
  %170 = load ptr, ptr @myargv, align 8, !tbaa !9
  %171 = load i32, ptr %2, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds ptr, ptr %170, i64 %172
  %174 = load ptr, ptr %173, align 8, !tbaa !9
  %175 = call ptr @gethostbyname(ptr noundef %174)
  store ptr %175, ptr %4, align 8, !tbaa !9
  %176 = load ptr, ptr %4, align 8, !tbaa !9
  %177 = icmp ne ptr %176, null
  br i1 %177, label %184, label %178

178:                                              ; preds = %169
  %179 = load ptr, ptr @myargv, align 8, !tbaa !9
  %180 = load i32, ptr %2, align 4, !tbaa !5
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds ptr, ptr %179, i64 %181
  %183 = load ptr, ptr %182, align 8, !tbaa !9
  call void (ptr, ...) @I_Error(ptr noundef @.str.11, ptr noundef %183) #12
  unreachable

184:                                              ; preds = %169
  %185 = load ptr, ptr %4, align 8, !tbaa !9
  %186 = getelementptr inbounds %struct.hostent, ptr %185, i32 0, i32 4
  %187 = load ptr, ptr %186, align 8, !tbaa !28
  %188 = getelementptr inbounds ptr, ptr %187, i64 0
  %189 = load ptr, ptr %188, align 8, !tbaa !9
  %190 = load i32, ptr %189, align 4, !tbaa !5
  %191 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %192 = getelementptr inbounds %struct.doomcom_t, ptr %191, i32 0, i32 5
  %193 = load i16, ptr %192, align 8, !tbaa !19
  %194 = sext i16 %193 to i64
  %195 = getelementptr inbounds [8 x %struct.sockaddr_in], ptr @sendaddress, i64 0, i64 %194
  %196 = getelementptr inbounds %struct.sockaddr_in, ptr %195, i32 0, i32 2
  %197 = getelementptr inbounds %struct.in_addr, ptr %196, i32 0, i32 0
  store i32 %190, ptr %197, align 4, !tbaa !27
  br label %198

198:                                              ; preds = %184, %154
  %199 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %200 = getelementptr inbounds %struct.doomcom_t, ptr %199, i32 0, i32 5
  %201 = load i16, ptr %200, align 8, !tbaa !19
  %202 = add i16 %201, 1
  store i16 %202, ptr %200, align 8, !tbaa !19
  br label %112, !llvm.loop !30

203:                                              ; preds = %127
  %204 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %205 = getelementptr inbounds %struct.doomcom_t, ptr %204, i32 0, i32 0
  store i64 305419896, ptr %205, align 8, !tbaa !18
  %206 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %207 = getelementptr inbounds %struct.doomcom_t, ptr %206, i32 0, i32 5
  %208 = load i16, ptr %207, align 8, !tbaa !19
  %209 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %210 = getelementptr inbounds %struct.doomcom_t, ptr %209, i32 0, i32 14
  store i16 %208, ptr %210, align 2, !tbaa !20
  %211 = call i32 @UDPsocket()
  store i32 %211, ptr @insocket, align 4, !tbaa !5
  %212 = load i32, ptr @insocket, align 4, !tbaa !5
  %213 = load i32, ptr @DOOMPORT, align 4, !tbaa !5
  %214 = trunc i32 %213 to i16
  %215 = call zeroext i16 @__bswap_16(i16 noundef zeroext %214)
  %216 = zext i16 %215 to i32
  call void @BindToLocalPort(i32 noundef %212, i32 noundef %216)
  %217 = load i32, ptr @insocket, align 4, !tbaa !5
  %218 = call i32 (i32, i64, ...) @ioctl(i32 noundef %217, i64 noundef 21537, ptr noundef %1) #9
  %219 = call i32 @UDPsocket()
  store i32 %219, ptr @sendsocket, align 4, !tbaa !5
  store i32 0, ptr %5, align 4
  br label %220

220:                                              ; preds = %203, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #9
  %221 = load i32, ptr %5, align 4
  switch i32 %221, label %223 [
    i32 0, label %222
    i32 1, label %222
  ]

222:                                              ; preds = %220, %220
  ret void

223:                                              ; preds = %220
  unreachable
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #6

declare i32 @M_CheckParm(ptr noundef) #5

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #7

; Function Attrs: nounwind
declare i32 @inet_addr(ptr noundef) #8

; Function Attrs: nounwind
declare i32 @ioctl(i32 noundef, i64 noundef, ...) #8

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


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

@DOOMPORT = external dso_local local_unnamed_addr global i32, align 4
@sendsocket = external dso_local local_unnamed_addr global i32, align 4
@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.6 = external hidden unnamed_addr constant [5 x i8], align 1
@myargc = external local_unnamed_addr global i32, align 4
@myargv = external local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [5 x i8], align 1
@netgame = external local_unnamed_addr global i32, align 4
@netsend = external dso_local local_unnamed_addr global ptr, align 8
@netget = external dso_local local_unnamed_addr global ptr, align 8
@.str.11 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @UDPsocket() local_unnamed_addr #0

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

; Function Attrs: noreturn
declare void @I_Error(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

; Function Attrs: nounwind uwtable
declare dso_local void @BindToLocalPort(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @PacketSend() #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @PacketGet() #0

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

declare ptr @gethostbyname(ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local void @I_InitNetwork() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #9
  store i32 1, ptr %1, align 4, !tbaa !5
  %calloc = tail call dereferenceable_or_null(144) ptr @calloc(i64 1, i64 144)
  store ptr %calloc, ptr @doomcom, align 8, !tbaa !9
  %2 = tail call i32 @M_CheckParm(ptr noundef nonnull @.str.6) #9
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %22, label %3

3:                                                ; preds = %0
  %4 = load i32, ptr @myargc, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  %6 = icmp slt i32 %2, %5
  br i1 %6, label %7, label %22

7:                                                ; preds = %3
  %8 = load ptr, ptr @myargv, align 8, !tbaa !9
  %9 = sext i32 %2 to i64
  %10 = getelementptr ptr, ptr %8, i64 %9
  %11 = getelementptr i8, ptr %10, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = load i8, ptr %12, align 1, !tbaa !11
  %14 = sext i8 %13 to i16
  %15 = add nsw i16 %14, -48
  %16 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %16, i64 18
  store i16 %15, ptr %17, align 2, !tbaa !12
  %18 = icmp slt i8 %13, 49
  br i1 %18, label %.thread, label %19

.thread:                                          ; preds = %7
  store i16 1, ptr %17, align 2, !tbaa !12
  br label %25

19:                                               ; preds = %7
  %20 = icmp ugt i8 %13, 57
  br i1 %20, label %21, label %25

21:                                               ; preds = %19
  store i16 9, ptr %17, align 2, !tbaa !12
  br label %25

22:                                               ; preds = %3, %0
  %23 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %24 = getelementptr inbounds i8, ptr %23, i64 18
  store i16 1, ptr %24, align 2, !tbaa !12
  br label %25

25:                                               ; preds = %.thread, %19, %21, %22
  %26 = tail call i32 @M_CheckParm(ptr noundef nonnull @.str.7) #9
  %.not21 = icmp ne i32 %26, 0
  %27 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %28 = getelementptr inbounds i8, ptr %27, i64 20
  %. = zext i1 %.not21 to i16
  store i16 %., ptr %28, align 4, !tbaa !17
  %29 = tail call i32 @M_CheckParm(ptr noundef nonnull @.str.8) #9
  %.not22 = icmp eq i32 %29, 0
  br i1 %.not22, label %42, label %30

30:                                               ; preds = %25
  %31 = load i32, ptr @myargc, align 4, !tbaa !5
  %32 = add nsw i32 %31, -1
  %33 = icmp slt i32 %29, %32
  br i1 %33, label %34, label %42

34:                                               ; preds = %30
  %35 = load ptr, ptr @myargv, align 8, !tbaa !9
  %36 = sext i32 %29 to i64
  %37 = getelementptr ptr, ptr %35, i64 %36
  %38 = getelementptr i8, ptr %37, i64 8
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = tail call i32 @atoi(ptr nocapture noundef %39) #10
  store i32 %40, ptr @DOOMPORT, align 4, !tbaa !5
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %40)
  br label %42

42:                                               ; preds = %34, %30, %25
  %43 = tail call i32 @M_CheckParm(ptr noundef nonnull @.str.10) #9
  %.not23 = icmp eq i32 %43, 0
  br i1 %.not23, label %44, label %50

44:                                               ; preds = %42
  store i32 0, ptr @netgame, align 4, !tbaa !5
  %45 = load ptr, ptr @doomcom, align 8, !tbaa !9
  store i64 305419896, ptr %45, align 8, !tbaa !18
  %46 = getelementptr inbounds i8, ptr %45, i64 16
  store i16 1, ptr %46, align 8, !tbaa !19
  %47 = getelementptr inbounds i8, ptr %45, i64 34
  store i16 1, ptr %47, align 2, !tbaa !20
  %48 = getelementptr inbounds i8, ptr %45, i64 22
  store i16 0, ptr %48, align 2, !tbaa !21
  %49 = getelementptr inbounds i8, ptr %45, i64 32
  store i16 0, ptr %49, align 8, !tbaa !22
  br label %125

50:                                               ; preds = %42
  store ptr @PacketSend, ptr @netsend, align 8, !tbaa !9
  store ptr @PacketGet, ptr @netget, align 8, !tbaa !9
  store i32 1, ptr @netgame, align 4, !tbaa !5
  %51 = load ptr, ptr @myargv, align 8, !tbaa !9
  %52 = sext i32 %43 to i64
  %53 = getelementptr ptr, ptr %51, i64 %52
  %54 = getelementptr i8, ptr %53, i64 8
  %55 = load ptr, ptr %54, align 8, !tbaa !9
  %56 = load i8, ptr %55, align 1, !tbaa !11
  %57 = sext i8 %56 to i16
  %58 = add nsw i16 %57, -49
  %59 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %60 = getelementptr inbounds i8, ptr %59, i64 32
  store i16 %58, ptr %60, align 8, !tbaa !22
  %61 = getelementptr inbounds i8, ptr %59, i64 16
  store i16 1, ptr %61, align 8, !tbaa !19
  %62 = add nsw i32 %43, 2
  %63 = load i32, ptr @myargc, align 4, !tbaa !5
  %64 = icmp slt i32 %62, %63
  br i1 %64, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %50
  %65 = sext i32 %62 to i64
  %66 = load ptr, ptr @myargv, align 8, !tbaa !9
  %67 = getelementptr inbounds ptr, ptr %66, i64 %65
  %68 = load ptr, ptr %67, align 8, !tbaa !9
  %69 = load i8, ptr %68, align 1, !tbaa !11
  %.not2440 = icmp eq i8 %69, 45
  br i1 %.not2440, label %.critedge, label %.lr.ph43

.lr.ph:                                           ; preds = %103
  %70 = load ptr, ptr @myargv, align 8, !tbaa !9
  %71 = getelementptr inbounds ptr, ptr %70, i64 %indvars.iv.next
  %72 = load ptr, ptr %71, align 8, !tbaa !9
  %73 = load i8, ptr %72, align 1, !tbaa !11
  %.not24 = icmp eq i8 %73, 45
  br i1 %.not24, label %.critedge, label %.lr.ph43, !llvm.loop !23

.lr.ph43:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv42 = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %65, %.lr.ph.preheader ]
  %.pre.pre41 = phi i16 [ %110, %.lr.ph ], [ 1, %.lr.ph.preheader ]
  %74 = sext i16 %.pre.pre41 to i64
  %75 = getelementptr inbounds [8 x %struct.sockaddr_in], ptr @sendaddress, i64 0, i64 %74
  store i16 2, ptr %75, align 16, !tbaa !25
  %76 = load i32, ptr @DOOMPORT, align 4, !tbaa !5
  %77 = trunc i32 %76 to i16
  %78 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext %77)
  %79 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %80 = getelementptr inbounds i8, ptr %79, i64 16
  %81 = load i16, ptr %80, align 8, !tbaa !19
  %82 = sext i16 %81 to i64
  %83 = getelementptr inbounds [8 x %struct.sockaddr_in], ptr @sendaddress, i64 0, i64 %82, i32 1
  store i16 %78, ptr %83, align 2, !tbaa !28
  %84 = load ptr, ptr @myargv, align 8, !tbaa !9
  %85 = getelementptr inbounds ptr, ptr %84, i64 %indvars.iv42
  %86 = load ptr, ptr %85, align 8, !tbaa !9
  %87 = load i8, ptr %86, align 1, !tbaa !11
  %88 = icmp eq i8 %87, 46
  br i1 %88, label %89, label %92

89:                                               ; preds = %.lr.ph43
  %90 = getelementptr inbounds i8, ptr %86, i64 1
  %91 = tail call i32 @inet_addr(ptr noundef nonnull %90) #9
  br label %103

92:                                               ; preds = %.lr.ph43
  %93 = tail call ptr @gethostbyname(ptr noundef nonnull %86) #9
  %.not25 = icmp eq ptr %93, null
  br i1 %.not25, label %94, label %98

94:                                               ; preds = %92
  %95 = load ptr, ptr @myargv, align 8, !tbaa !9
  %96 = getelementptr inbounds ptr, ptr %95, i64 %indvars.iv42
  %97 = load ptr, ptr %96, align 8, !tbaa !9
  tail call void (ptr, ...) @I_Error(ptr noundef nonnull @.str.11, ptr noundef %97) #11
  unreachable

98:                                               ; preds = %92
  %99 = getelementptr inbounds i8, ptr %93, i64 24
  %100 = load ptr, ptr %99, align 8, !tbaa !29
  %101 = load ptr, ptr %100, align 8, !tbaa !9
  %102 = load i32, ptr %101, align 4, !tbaa !5
  br label %103

103:                                              ; preds = %98, %89
  %.sink32 = phi i32 [ %102, %98 ], [ %91, %89 ]
  %104 = load ptr, ptr @doomcom, align 8, !tbaa !9
  %105 = getelementptr inbounds i8, ptr %104, i64 16
  %106 = load i16, ptr %105, align 8, !tbaa !19
  %107 = sext i16 %106 to i64
  %108 = getelementptr inbounds [8 x %struct.sockaddr_in], ptr @sendaddress, i64 0, i64 %107, i32 2
  store i32 %.sink32, ptr %108, align 4, !tbaa !31
  %109 = getelementptr inbounds i8, ptr %104, i64 16
  %110 = add i16 %106, 1
  store i16 %110, ptr %109, align 8, !tbaa !19
  %indvars.iv.next = add nsw i64 %indvars.iv42, 1
  %111 = load i32, ptr @myargc, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = icmp slt i64 %indvars.iv.next, %112
  br i1 %113, label %.lr.ph, label %.critedge, !llvm.loop !23

.critedge:                                        ; preds = %103, %.lr.ph, %.lr.ph.preheader, %50
  %114 = phi i16 [ 1, %50 ], [ 1, %.lr.ph.preheader ], [ %110, %.lr.ph ], [ %110, %103 ]
  %115 = phi ptr [ %59, %50 ], [ %59, %.lr.ph.preheader ], [ %104, %.lr.ph ], [ %104, %103 ]
  store i64 305419896, ptr %115, align 8, !tbaa !18
  %116 = getelementptr inbounds i8, ptr %115, i64 34
  store i16 %114, ptr %116, align 2, !tbaa !20
  %117 = tail call i32 @UDPsocket()
  store i32 %117, ptr @insocket, align 4, !tbaa !5
  %118 = load i32, ptr @DOOMPORT, align 4, !tbaa !5
  %119 = trunc i32 %118 to i16
  %120 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext %119)
  %121 = zext i16 %120 to i32
  tail call void @BindToLocalPort(i32 noundef %117, i32 noundef %121)
  %122 = load i32, ptr @insocket, align 4, !tbaa !5
  %123 = call i32 (i32, i64, ...) @ioctl(i32 noundef %122, i64 noundef 21537, ptr noundef nonnull %1) #9
  %124 = call i32 @UDPsocket()
  store i32 %124, ptr @sendsocket, align 4, !tbaa !5
  br label %125

125:                                              ; preds = %.critedge, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #9
  ret void
}

declare i32 @M_CheckParm(ptr noundef) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #6

; Function Attrs: nounwind
declare i32 @inet_addr(ptr noundef) local_unnamed_addr #7

; Function Attrs: nounwind
declare i32 @ioctl(i32 noundef, i64 noundef, ...) local_unnamed_addr #7

; 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 #8

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 = { 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 #3 = { 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 #4 = { 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 #5 = { "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 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 #7 = { 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 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #9 = { nounwind }
attributes #10 = { nounwind willreturn memory(read) }
attributes #11 = { 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 = !{!7, !7, i64 0}
!12 = !{!13, !15, i64 18}
!13 = !{!"", !14, i64 0, !15, i64 8, !15, i64 10, !15, i64 12, !15, i64 14, !15, i64 16, !15, i64 18, !15, i64 20, !15, i64 22, !15, i64 24, !15, i64 26, !15, i64 28, !15, i64 30, !15, i64 32, !15, i64 34, !15, i64 36, !15, i64 38, !16, i64 40}
!14 = !{!"long", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!"", !6, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8}
!17 = !{!13, !15, i64 20}
!18 = !{!13, !14, i64 0}
!19 = !{!13, !15, i64 16}
!20 = !{!13, !15, i64 34}
!21 = !{!13, !15, i64 22}
!22 = !{!13, !15, i64 32}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!26, !15, i64 0}
!26 = !{!"sockaddr_in", !15, i64 0, !15, i64 2, !27, i64 4, !7, i64 8}
!27 = !{!"in_addr", !6, i64 0}
!28 = !{!26, !15, i64 2}
!29 = !{!30, !10, i64 24}
!30 = !{!"hostent", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 20, !10, i64 24}
!31 = !{!26, !6, i64 4}


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