; LLVM IR from nem0/lumixengine_net :: external/enet (host)

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

%union._ENetProtocol = type { %struct._ENetProtocolConnect }
%struct._ENetProtocolConnect = type { %struct._ENetProtocolCommandHeader, i16, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct._ENetProtocolCommandHeader = type { i8, i8, i16 }
%struct._ENetHost = type <{ i32, %struct._ENetAddress, i32, i32, i32, i32, i32, i32, [4 x i8], ptr, i64, i64, i32, [4 x i8], %struct._ENetList, i32, [4 x i8], i64, i16, [32 x %union._ENetProtocol], [6 x i8], i64, [65 x %struct.ENetBuffer], i64, ptr, %struct._ENetCompressor, [2 x [4096 x i8]], %struct._ENetAddress, ptr, i64, i32, i32, i32, i32, ptr, i64, i64, i64, i64, i64 }>
%struct._ENetList = type { %struct._ENetListNode }
%struct._ENetListNode = type { ptr, ptr }
%struct.ENetBuffer = type { ptr, i64 }
%struct._ENetCompressor = type { ptr, ptr, ptr, ptr }
%struct._ENetAddress = type { i32, i16 }
%struct._ENetPeer = type { %struct._ENetListNode, ptr, i16, i16, i32, i8, i8, %struct._ENetAddress, ptr, i32, ptr, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, %struct._ENetList, %struct._ENetList, %struct._ENetList, %struct._ENetList, %struct._ENetList, %struct._ENetList, i32, i16, i16, [32 x i32], i32, i64 }
%struct._ENetChannel = type { i16, i16, i16, [16 x i16], i16, i16, %struct._ENetList, %struct._ENetList }

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

declare ptr @enet_malloc(i64 noundef) #1

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

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

declare void @enet_list_clear(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @enet_host_connect(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3) #4 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca %union._ENetProtocol, align 1
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 48, ptr %12) #6
  %14 = load i64, ptr %8, align 8, !tbaa !9
  %15 = icmp ult i64 %14, 1
  br i1 %15, label %16, label %17

16:                                               ; preds = %4
  store i64 1, ptr %8, align 8, !tbaa !9
  br label %22

17:                                               ; preds = %4
  %18 = load i64, ptr %8, align 8, !tbaa !9
  %19 = icmp ugt i64 %18, 255
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  store i64 255, ptr %8, align 8, !tbaa !9
  br label %21

21:                                               ; preds = %20, %17
  br label %22

22:                                               ; preds = %21, %16
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._ENetHost, ptr %23, i32 0, i32 9
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  store ptr %25, ptr %10, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %43, %22
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._ENetHost, ptr %28, i32 0, i32 9
  %30 = load ptr, ptr %29, align 8, !tbaa !13
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._ENetHost, ptr %31, i32 0, i32 10
  %33 = load i64, ptr %32, align 8, !tbaa !20
  %34 = getelementptr inbounds %struct._ENetPeer, ptr %30, i64 %33
  %35 = icmp ult ptr %27, %34
  br i1 %35, label %36, label %46

36:                                               ; preds = %26
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._ENetPeer, ptr %37, i32 0, i32 9
  %39 = load i32, ptr %38, align 8, !tbaa !21
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %36
  br label %46

42:                                               ; preds = %36
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._ENetPeer, ptr %44, i32 1
  store ptr %45, ptr %10, align 8, !tbaa !5
  br label %26, !llvm.loop !23

46:                                               ; preds = %41, %26
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._ENetHost, ptr %48, i32 0, i32 9
  %50 = load ptr, ptr %49, align 8, !tbaa !13
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._ENetHost, ptr %51, i32 0, i32 10
  %53 = load i64, ptr %52, align 8, !tbaa !20
  %54 = getelementptr inbounds %struct._ENetPeer, ptr %50, i64 %53
  %55 = icmp uge ptr %47, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %46
  store ptr null, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %213

57:                                               ; preds = %46
  %58 = load i64, ptr %8, align 8, !tbaa !9
  %59 = mul i64 %58, 80
  %60 = call ptr @enet_malloc(i64 noundef %59)
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._ENetPeer, ptr %61, i32 0, i32 10
  store ptr %60, ptr %62, align 8, !tbaa !25
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct._ENetPeer, ptr %63, i32 0, i32 10
  %65 = load ptr, ptr %64, align 8, !tbaa !25
  %66 = icmp eq ptr %65, null
  br i1 %66, label %67, label %68

67:                                               ; preds = %57
  store ptr null, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %213

68:                                               ; preds = %57
  %69 = load i64, ptr %8, align 8, !tbaa !9
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._ENetPeer, ptr %70, i32 0, i32 11
  store i64 %69, ptr %71, align 8, !tbaa !26
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct._ENetPeer, ptr %72, i32 0, i32 9
  store i32 1, ptr %73, align 8, !tbaa !21
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._ENetPeer, ptr %74, i32 0, i32 7
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %75, ptr align 4 %76, i64 8, i1 false), !tbaa.struct !27
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._ENetHost, ptr %77, i32 0, i32 6
  %79 = load i32, ptr %78, align 4, !tbaa !29
  %80 = add i32 %79, 1
  store i32 %80, ptr %78, align 4, !tbaa !29
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._ENetPeer, ptr %81, i32 0, i32 4
  store i32 %80, ptr %82, align 4, !tbaa !30
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct._ENetHost, ptr %83, i32 0, i32 3
  %85 = load i32, ptr %84, align 8, !tbaa !31
  %86 = icmp eq i32 %85, 0
  br i1 %86, label %87, label %90

87:                                               ; preds = %68
  %88 = load ptr, ptr %10, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct._ENetPeer, ptr %88, i32 0, i32 45
  store i32 65536, ptr %89, align 4, !tbaa !32
  br label %98

90:                                               ; preds = %68
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct._ENetHost, ptr %91, i32 0, i32 3
  %93 = load i32, ptr %92, align 8, !tbaa !31
  %94 = udiv i32 %93, 65536
  %95 = mul i32 %94, 4096
  %96 = load ptr, ptr %10, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct._ENetPeer, ptr %96, i32 0, i32 45
  store i32 %95, ptr %97, align 4, !tbaa !32
  br label %98

98:                                               ; preds = %90, %87
  %99 = load ptr, ptr %10, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct._ENetPeer, ptr %99, i32 0, i32 45
  %101 = load i32, ptr %100, align 4, !tbaa !32
  %102 = icmp ult i32 %101, 4096
  br i1 %102, label %103, label %106

103:                                              ; preds = %98
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct._ENetPeer, ptr %104, i32 0, i32 45
  store i32 4096, ptr %105, align 4, !tbaa !32
  br label %115

106:                                              ; preds = %98
  %107 = load ptr, ptr %10, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct._ENetPeer, ptr %107, i32 0, i32 45
  %109 = load i32, ptr %108, align 4, !tbaa !32
  %110 = icmp ugt i32 %109, 65536
  br i1 %110, label %111, label %114

111:                                              ; preds = %106
  %112 = load ptr, ptr %10, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct._ENetPeer, ptr %112, i32 0, i32 45
  store i32 65536, ptr %113, align 4, !tbaa !32
  br label %114

114:                                              ; preds = %111, %106
  br label %115

115:                                              ; preds = %114, %103
  %116 = load ptr, ptr %10, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct._ENetPeer, ptr %116, i32 0, i32 10
  %118 = load ptr, ptr %117, align 8, !tbaa !25
  store ptr %118, ptr %11, align 8, !tbaa !5
  br label %119

119:                                              ; preds = %145, %115
  %120 = load ptr, ptr %11, align 8, !tbaa !5
  %121 = load ptr, ptr %10, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct._ENetPeer, ptr %121, i32 0, i32 10
  %123 = load ptr, ptr %122, align 8, !tbaa !25
  %124 = load i64, ptr %8, align 8, !tbaa !9
  %125 = getelementptr inbounds %struct._ENetChannel, ptr %123, i64 %124
  %126 = icmp ult ptr %120, %125
  br i1 %126, label %127, label %148

127:                                              ; preds = %119
  %128 = load ptr, ptr %11, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct._ENetChannel, ptr %128, i32 0, i32 0
  store i16 0, ptr %129, align 8, !tbaa !33
  %130 = load ptr, ptr %11, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct._ENetChannel, ptr %130, i32 0, i32 1
  store i16 0, ptr %131, align 2, !tbaa !35
  %132 = load ptr, ptr %11, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct._ENetChannel, ptr %132, i32 0, i32 4
  store i16 0, ptr %133, align 2, !tbaa !36
  %134 = load ptr, ptr %11, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct._ENetChannel, ptr %134, i32 0, i32 5
  store i16 0, ptr %135, align 8, !tbaa !37
  %136 = load ptr, ptr %11, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct._ENetChannel, ptr %136, i32 0, i32 6
  call void @enet_list_clear(ptr noundef %137)
  %138 = load ptr, ptr %11, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct._ENetChannel, ptr %138, i32 0, i32 7
  call void @enet_list_clear(ptr noundef %139)
  %140 = load ptr, ptr %11, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct._ENetChannel, ptr %140, i32 0, i32 2
  store i16 0, ptr %141, align 4, !tbaa !38
  %142 = load ptr, ptr %11, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct._ENetChannel, ptr %142, i32 0, i32 3
  %144 = getelementptr inbounds [16 x i16], ptr %143, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 2 %144, i8 0, i64 32, i1 false)
  br label %145

145:                                              ; preds = %127
  %146 = load ptr, ptr %11, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct._ENetChannel, ptr %146, i32 1
  store ptr %147, ptr %11, align 8, !tbaa !5
  br label %119, !llvm.loop !39

148:                                              ; preds = %119
  %149 = getelementptr inbounds %struct._ENetProtocolCommandHeader, ptr %12, i32 0, i32 0
  store i8 -126, ptr %149, align 1, !tbaa !40
  %150 = getelementptr inbounds %struct._ENetProtocolCommandHeader, ptr %12, i32 0, i32 1
  store i8 -1, ptr %150, align 1, !tbaa !40
  %151 = load ptr, ptr %10, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct._ENetPeer, ptr %151, i32 0, i32 3
  %153 = load i16, ptr %152, align 2, !tbaa !41
  %154 = call zeroext i16 @__bswap_16(i16 noundef zeroext %153)
  %155 = getelementptr inbounds %struct._ENetProtocolConnect, ptr %12, i32 0, i32 1
  store i16 %154, ptr %155, align 1, !tbaa !40
  %156 = load ptr, ptr %10, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct._ENetPeer, ptr %156, i32 0, i32 6
  %158 = load i8, ptr %157, align 1, !tbaa !42
  %159 = getelementptr inbounds %struct._ENetProtocolConnect, ptr %12, i32 0, i32 2
  store i8 %158, ptr %159, align 1, !tbaa !40
  %160 = load ptr, ptr %10, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct._ENetPeer, ptr %160, i32 0, i32 5
  %162 = load i8, ptr %161, align 8, !tbaa !43
  %163 = getelementptr inbounds %struct._ENetProtocolConnect, ptr %12, i32 0, i32 3
  store i8 %162, ptr %163, align 1, !tbaa !40
  %164 = load ptr, ptr %10, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct._ENetPeer, ptr %164, i32 0, i32 44
  %166 = load i32, ptr %165, align 8, !tbaa !44
  %167 = call i32 @__bswap_32(i32 noundef %166)
  %168 = getelementptr inbounds %struct._ENetProtocolConnect, ptr %12, i32 0, i32 4
  store i32 %167, ptr %168, align 1, !tbaa !40
  %169 = load ptr, ptr %10, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct._ENetPeer, ptr %169, i32 0, i32 45
  %171 = load i32, ptr %170, align 4, !tbaa !32
  %172 = call i32 @__bswap_32(i32 noundef %171)
  %173 = getelementptr inbounds %struct._ENetProtocolConnect, ptr %12, i32 0, i32 5
  store i32 %172, ptr %173, align 1, !tbaa !40
  %174 = load i64, ptr %8, align 8, !tbaa !9
  %175 = trunc i64 %174 to i32
  %176 = call i32 @__bswap_32(i32 noundef %175)
  %177 = getelementptr inbounds %struct._ENetProtocolConnect, ptr %12, i32 0, i32 6
  store i32 %176, ptr %177, align 1, !tbaa !40
  %178 = load ptr, ptr %6, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct._ENetHost, ptr %178, i32 0, i32 2
  %180 = load i32, ptr %179, align 4, !tbaa !45
  %181 = call i32 @__bswap_32(i32 noundef %180)
  %182 = getelementptr inbounds %struct._ENetProtocolConnect, ptr %12, i32 0, i32 7
  store i32 %181, ptr %182, align 1, !tbaa !40
  %183 = load ptr, ptr %6, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct._ENetHost, ptr %183, i32 0, i32 3
  %185 = load i32, ptr %184, align 8, !tbaa !31
  %186 = call i32 @__bswap_32(i32 noundef %185)
  %187 = getelementptr inbounds %struct._ENetProtocolConnect, ptr %12, i32 0, i32 8
  store i32 %186, ptr %187, align 1, !tbaa !40
  %188 = load ptr, ptr %10, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct._ENetPeer, ptr %188, i32 0, i32 33
  %190 = load i32, ptr %189, align 4, !tbaa !46
  %191 = call i32 @__bswap_32(i32 noundef %190)
  %192 = getelementptr inbounds %struct._ENetProtocolConnect, ptr %12, i32 0, i32 9
  store i32 %191, ptr %192, align 1, !tbaa !40
  %193 = load ptr, ptr %10, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct._ENetPeer, ptr %193, i32 0, i32 31
  %195 = load i32, ptr %194, align 4, !tbaa !47
  %196 = call i32 @__bswap_32(i32 noundef %195)
  %197 = getelementptr inbounds %struct._ENetProtocolConnect, ptr %12, i32 0, i32 10
  store i32 %196, ptr %197, align 1, !tbaa !40
  %198 = load ptr, ptr %10, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct._ENetPeer, ptr %198, i32 0, i32 32
  %200 = load i32, ptr %199, align 8, !tbaa !48
  %201 = call i32 @__bswap_32(i32 noundef %200)
  %202 = getelementptr inbounds %struct._ENetProtocolConnect, ptr %12, i32 0, i32 11
  store i32 %201, ptr %202, align 1, !tbaa !40
  %203 = load ptr, ptr %10, align 8, !tbaa !5
  %204 = getelementptr inbounds %struct._ENetPeer, ptr %203, i32 0, i32 4
  %205 = load i32, ptr %204, align 4, !tbaa !30
  %206 = getelementptr inbounds %struct._ENetProtocolConnect, ptr %12, i32 0, i32 12
  store i32 %205, ptr %206, align 1, !tbaa !40
  %207 = load i32, ptr %9, align 4, !tbaa !11
  %208 = call i32 @__bswap_32(i32 noundef %207)
  %209 = getelementptr inbounds %struct._ENetProtocolConnect, ptr %12, i32 0, i32 13
  store i32 %208, ptr %209, align 1, !tbaa !40
  %210 = load ptr, ptr %10, align 8, !tbaa !5
  %211 = call ptr @enet_peer_queue_outgoing_command(ptr noundef %210, ptr noundef %12, ptr noundef null, i32 noundef 0, i16 noundef zeroext 0)
  %212 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %212, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %213

213:                                              ; preds = %148, %67, %56
  call void @llvm.lifetime.end.p0(i64 48, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  %214 = load ptr, ptr %5, align 8
  ret ptr %214
}

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

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

declare ptr @enet_peer_queue_outgoing_command(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i16 noundef zeroext) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = { 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 #6 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 40}
!14 = !{!"_ENetHost", !12, i64 0, !15, i64 4, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !6, i64 40, !10, i64 48, !10, i64 56, !12, i64 64, !17, i64 72, !12, i64 88, !10, i64 96, !16, i64 104, !7, i64 106, !10, i64 1648, !7, i64 1656, !10, i64 2696, !6, i64 2704, !19, i64 2712, !7, i64 2744, !15, i64 10936, !6, i64 10944, !10, i64 10952, !12, i64 10960, !12, i64 10964, !12, i64 10968, !12, i64 10972, !6, i64 10976, !10, i64 10984, !10, i64 10992, !10, i64 11000, !10, i64 11008, !10, i64 11016}
!15 = !{!"_ENetAddress", !12, i64 0, !16, i64 4}
!16 = !{!"short", !7, i64 0}
!17 = !{!"_ENetList", !18, i64 0}
!18 = !{!"_ENetListNode", !6, i64 0, !6, i64 8}
!19 = !{!"_ENetCompressor", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!20 = !{!14, !10, i64 48}
!21 = !{!22, !12, i64 56}
!22 = !{!"_ENetPeer", !18, i64 0, !6, i64 16, !16, i64 24, !16, i64 26, !12, i64 28, !7, i64 32, !7, i64 33, !15, i64 36, !6, i64 48, !12, i64 56, !6, i64 64, !10, i64 72, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132, !12, i64 136, !12, i64 140, !12, i64 144, !12, i64 148, !12, i64 152, !12, i64 156, !12, i64 160, !12, i64 164, !12, i64 168, !12, i64 172, !12, i64 176, !12, i64 180, !12, i64 184, !12, i64 188, !12, i64 192, !12, i64 196, !12, i64 200, !12, i64 204, !12, i64 208, !12, i64 212, !12, i64 216, !16, i64 220, !17, i64 224, !17, i64 240, !17, i64 256, !17, i64 272, !17, i64 288, !17, i64 304, !12, i64 320, !16, i64 324, !16, i64 326, !7, i64 328, !12, i64 456, !10, i64 464}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!22, !6, i64 64}
!26 = !{!22, !10, i64 72}
!27 = !{i64 0, i64 4, !11, i64 4, i64 2, !28}
!28 = !{!16, !16, i64 0}
!29 = !{!14, !12, i64 28}
!30 = !{!22, !12, i64 28}
!31 = !{!14, !12, i64 16}
!32 = !{!22, !12, i64 212}
!33 = !{!34, !16, i64 0}
!34 = !{!"_ENetChannel", !16, i64 0, !16, i64 2, !16, i64 4, !7, i64 6, !16, i64 38, !16, i64 40, !17, i64 48, !17, i64 64}
!35 = !{!34, !16, i64 2}
!36 = !{!34, !16, i64 38}
!37 = !{!34, !16, i64 40}
!38 = !{!34, !16, i64 4}
!39 = distinct !{!39, !24}
!40 = !{!7, !7, i64 0}
!41 = !{!22, !16, i64 26}
!42 = !{!22, !7, i64 33}
!43 = !{!22, !7, i64 32}
!44 = !{!22, !12, i64 208}
!45 = !{!14, !12, i64 12}
!46 = !{!22, !12, i64 164}
!47 = !{!22, !12, i64 156}
!48 = !{!22, !12, i64 160}


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

%union._ENetProtocol = type { %struct._ENetProtocolConnect }
%struct._ENetProtocolConnect = type { %struct._ENetProtocolCommandHeader, i16, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct._ENetProtocolCommandHeader = type { i8, i8, i16 }
%struct._ENetPeer = type { %struct._ENetListNode, ptr, i16, i16, i32, i8, i8, %struct._ENetAddress, ptr, i32, ptr, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, %struct._ENetList, %struct._ENetList, %struct._ENetList, %struct._ENetList, %struct._ENetList, %struct._ENetList, i32, i16, i16, [32 x i32], i32, i64 }
%struct._ENetListNode = type { ptr, ptr }
%struct._ENetAddress = type { i32, i16 }
%struct._ENetList = type { %struct._ENetListNode }
%struct._ENetChannel = type { i16, i16, i16, [16 x i16], i16, i16, %struct._ENetList, %struct._ENetList }

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

declare ptr @enet_malloc(i64 noundef) local_unnamed_addr #1

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

declare void @enet_list_clear(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @enet_host_connect(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #3 {
  %5 = alloca %union._ENetProtocol, align 1
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %5) #6
  %6 = icmp eq i64 %2, 0
  %spec.store.select = tail call i64 @llvm.umin.i64(i64 %2, i64 255)
  %.059 = select i1 %6, i64 1, i64 %spec.store.select
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 48
  %10 = load i64, ptr %9, align 8, !tbaa !17
  %11 = getelementptr inbounds %struct._ENetPeer, ptr %8, i64 %10
  %12 = icmp sgt i64 %10, 0
  br i1 %12, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %4, %16
  %.05764 = phi ptr [ %17, %16 ], [ %8, %4 ]
  %13 = getelementptr inbounds i8, ptr %.05764, i64 56
  %14 = load i32, ptr %13, align 8, !tbaa !18
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %19, label %16

16:                                               ; preds = %.lr.ph
  %17 = getelementptr inbounds i8, ptr %.05764, i64 472
  %18 = icmp ult ptr %17, %11
  br i1 %18, label %.lr.ph, label %.loopexit, !llvm.loop !20

19:                                               ; preds = %.lr.ph
  %20 = mul nuw nsw i64 %.059, 80
  %21 = tail call ptr @enet_malloc(i64 noundef %20) #6
  %22 = getelementptr inbounds i8, ptr %.05764, i64 64
  store ptr %21, ptr %22, align 8, !tbaa !22
  %23 = icmp eq ptr %21, null
  br i1 %23, label %.loopexit, label %24

24:                                               ; preds = %19
  %25 = getelementptr inbounds i8, ptr %.05764, i64 56
  %26 = getelementptr inbounds i8, ptr %.05764, i64 72
  store i64 %.059, ptr %26, align 8, !tbaa !23
  store i32 1, ptr %25, align 8, !tbaa !18
  %27 = getelementptr inbounds i8, ptr %.05764, i64 36
  %28 = load i64, ptr %1, align 4
  store i64 %28, ptr %27, align 4
  %29 = getelementptr inbounds i8, ptr %0, i64 28
  %30 = load i32, ptr %29, align 4, !tbaa !24
  %31 = add i32 %30, 1
  store i32 %31, ptr %29, align 4, !tbaa !24
  %32 = getelementptr inbounds i8, ptr %.05764, i64 28
  store i32 %31, ptr %32, align 4, !tbaa !25
  %33 = getelementptr inbounds i8, ptr %0, i64 16
  %34 = load i32, ptr %33, align 8, !tbaa !26
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %.thread70, label %37

.thread70:                                        ; preds = %24
  %36 = getelementptr inbounds i8, ptr %.05764, i64 212
  store i32 65536, ptr %36, align 4
  br label %46

37:                                               ; preds = %24
  %38 = lshr i32 %34, 4
  %39 = and i32 %38, 268431360
  %40 = getelementptr inbounds i8, ptr %.05764, i64 212
  store i32 %39, ptr %40, align 4
  %41 = icmp eq i32 %39, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %37
  store i32 4096, ptr %40, align 4, !tbaa !27
  br label %46

43:                                               ; preds = %37
  %44 = icmp ugt i32 %39, 65536
  br i1 %44, label %45, label %46

45:                                               ; preds = %43
  store i32 65536, ptr %40, align 4, !tbaa !27
  br label %46

46:                                               ; preds = %.thread70, %43, %45, %42
  %47 = phi ptr [ %40, %43 ], [ %40, %45 ], [ %40, %42 ], [ %36, %.thread70 ]
  %.not = icmp eq i64 %.059, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph66

.lr.ph66:                                         ; preds = %46, %.lr.ph66
  %.065 = phi ptr [ %54, %.lr.ph66 ], [ %21, %46 ]
  store i16 0, ptr %.065, align 8, !tbaa !28
  %48 = getelementptr inbounds i8, ptr %.065, i64 2
  store i16 0, ptr %48, align 2, !tbaa !30
  %49 = getelementptr inbounds i8, ptr %.065, i64 38
  store i16 0, ptr %49, align 2, !tbaa !31
  %50 = getelementptr inbounds i8, ptr %.065, i64 40
  store i16 0, ptr %50, align 8, !tbaa !32
  %51 = getelementptr inbounds i8, ptr %.065, i64 48
  tail call void @enet_list_clear(ptr noundef nonnull %51) #6
  %52 = getelementptr inbounds i8, ptr %.065, i64 64
  tail call void @enet_list_clear(ptr noundef nonnull %52) #6
  %53 = getelementptr inbounds i8, ptr %.065, i64 4
  %54 = getelementptr inbounds i8, ptr %.065, i64 80
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(34) %53, i8 0, i64 34, i1 false)
  %55 = load ptr, ptr %22, align 8, !tbaa !22
  %56 = getelementptr inbounds %struct._ENetChannel, ptr %55, i64 %.059
  %57 = icmp ult ptr %54, %56
  br i1 %57, label %.lr.ph66, label %._crit_edge, !llvm.loop !33

._crit_edge:                                      ; preds = %.lr.ph66, %46
  store i8 -126, ptr %5, align 1, !tbaa !34
  %58 = getelementptr inbounds i8, ptr %5, i64 1
  store i8 -1, ptr %58, align 1, !tbaa !34
  %59 = getelementptr inbounds i8, ptr %.05764, i64 26
  %60 = load i16, ptr %59, align 2, !tbaa !35
  %61 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext %60)
  %62 = getelementptr inbounds i8, ptr %5, i64 4
  store i16 %61, ptr %62, align 1, !tbaa !34
  %63 = getelementptr inbounds i8, ptr %.05764, i64 33
  %64 = load i8, ptr %63, align 1, !tbaa !36
  %65 = getelementptr inbounds i8, ptr %5, i64 6
  store i8 %64, ptr %65, align 1, !tbaa !34
  %66 = getelementptr inbounds i8, ptr %.05764, i64 32
  %67 = load i8, ptr %66, align 8, !tbaa !37
  %68 = getelementptr inbounds i8, ptr %5, i64 7
  store i8 %67, ptr %68, align 1, !tbaa !34
  %69 = getelementptr inbounds i8, ptr %.05764, i64 208
  %70 = load i32, ptr %69, align 8, !tbaa !38
  %71 = tail call i32 @__bswap_32(i32 noundef %70)
  %72 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %71, ptr %72, align 1, !tbaa !34
  %73 = load i32, ptr %47, align 4, !tbaa !27
  %74 = tail call i32 @__bswap_32(i32 noundef %73)
  %75 = getelementptr inbounds i8, ptr %5, i64 12
  store i32 %74, ptr %75, align 1, !tbaa !34
  %76 = trunc nuw nsw i64 %.059 to i32
  %77 = tail call i32 @__bswap_32(i32 noundef %76)
  %78 = getelementptr inbounds i8, ptr %5, i64 16
  store i32 %77, ptr %78, align 1, !tbaa !34
  %79 = getelementptr inbounds i8, ptr %0, i64 12
  %80 = load i32, ptr %79, align 4, !tbaa !39
  %81 = tail call i32 @__bswap_32(i32 noundef %80)
  %82 = getelementptr inbounds i8, ptr %5, i64 20
  store i32 %81, ptr %82, align 1, !tbaa !34
  %83 = load i32, ptr %33, align 8, !tbaa !26
  %84 = tail call i32 @__bswap_32(i32 noundef %83)
  %85 = getelementptr inbounds i8, ptr %5, i64 24
  store i32 %84, ptr %85, align 1, !tbaa !34
  %86 = getelementptr inbounds i8, ptr %.05764, i64 164
  %87 = load i32, ptr %86, align 4, !tbaa !40
  %88 = tail call i32 @__bswap_32(i32 noundef %87)
  %89 = getelementptr inbounds i8, ptr %5, i64 28
  store i32 %88, ptr %89, align 1, !tbaa !34
  %90 = getelementptr inbounds i8, ptr %.05764, i64 156
  %91 = load i32, ptr %90, align 4, !tbaa !41
  %92 = tail call i32 @__bswap_32(i32 noundef %91)
  %93 = getelementptr inbounds i8, ptr %5, i64 32
  store i32 %92, ptr %93, align 1, !tbaa !34
  %94 = getelementptr inbounds i8, ptr %.05764, i64 160
  %95 = load i32, ptr %94, align 8, !tbaa !42
  %96 = tail call i32 @__bswap_32(i32 noundef %95)
  %97 = getelementptr inbounds i8, ptr %5, i64 36
  store i32 %96, ptr %97, align 1, !tbaa !34
  %98 = load i32, ptr %32, align 4, !tbaa !25
  %99 = getelementptr inbounds i8, ptr %5, i64 40
  store i32 %98, ptr %99, align 1, !tbaa !34
  %100 = tail call i32 @__bswap_32(i32 noundef %3)
  %101 = getelementptr inbounds i8, ptr %5, i64 44
  store i32 %100, ptr %101, align 1, !tbaa !34
  %102 = call ptr @enet_peer_queue_outgoing_command(ptr noundef nonnull %.05764, ptr noundef nonnull %5, ptr noundef null, i32 noundef 0, i16 noundef zeroext 0) #6
  br label %.loopexit

.loopexit:                                        ; preds = %16, %4, %19, %._crit_edge
  %.058 = phi ptr [ %.05764, %._crit_edge ], [ null, %19 ], [ null, %4 ], [ null, %16 ]
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #6
  ret ptr %.058
}

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

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

declare ptr @enet_peer_queue_outgoing_command(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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, !12, i64 40}
!6 = !{!"_ENetHost", !7, i64 0, !10, i64 4, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !12, i64 40, !13, i64 48, !13, i64 56, !7, i64 64, !14, i64 72, !7, i64 88, !13, i64 96, !11, i64 104, !8, i64 106, !13, i64 1648, !8, i64 1656, !13, i64 2696, !12, i64 2704, !16, i64 2712, !8, i64 2744, !10, i64 10936, !12, i64 10944, !13, i64 10952, !7, i64 10960, !7, i64 10964, !7, i64 10968, !7, i64 10972, !12, i64 10976, !13, i64 10984, !13, i64 10992, !13, i64 11000, !13, i64 11008, !13, i64 11016}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_ENetAddress", !7, i64 0, !11, i64 4}
!11 = !{!"short", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!"_ENetList", !15, i64 0}
!15 = !{!"_ENetListNode", !12, i64 0, !12, i64 8}
!16 = !{!"_ENetCompressor", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!17 = !{!6, !13, i64 48}
!18 = !{!19, !7, i64 56}
!19 = !{!"_ENetPeer", !15, i64 0, !12, i64 16, !11, i64 24, !11, i64 26, !7, i64 28, !8, i64 32, !8, i64 33, !10, i64 36, !12, i64 48, !7, i64 56, !12, i64 64, !13, i64 72, !7, i64 80, !7, i64 84, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100, !7, i64 104, !7, i64 108, !7, i64 112, !7, i64 116, !7, i64 120, !7, i64 124, !7, i64 128, !7, i64 132, !7, i64 136, !7, i64 140, !7, i64 144, !7, i64 148, !7, i64 152, !7, i64 156, !7, i64 160, !7, i64 164, !7, i64 168, !7, i64 172, !7, i64 176, !7, i64 180, !7, i64 184, !7, i64 188, !7, i64 192, !7, i64 196, !7, i64 200, !7, i64 204, !7, i64 208, !7, i64 212, !7, i64 216, !11, i64 220, !14, i64 224, !14, i64 240, !14, i64 256, !14, i64 272, !14, i64 288, !14, i64 304, !7, i64 320, !11, i64 324, !11, i64 326, !8, i64 328, !7, i64 456, !13, i64 464}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!19, !12, i64 64}
!23 = !{!19, !13, i64 72}
!24 = !{!6, !7, i64 28}
!25 = !{!19, !7, i64 28}
!26 = !{!6, !7, i64 16}
!27 = !{!19, !7, i64 212}
!28 = !{!29, !11, i64 0}
!29 = !{!"_ENetChannel", !11, i64 0, !11, i64 2, !11, i64 4, !8, i64 6, !11, i64 38, !11, i64 40, !14, i64 48, !14, i64 64}
!30 = !{!29, !11, i64 2}
!31 = !{!29, !11, i64 38}
!32 = !{!29, !11, i64 40}
!33 = distinct !{!33, !21}
!34 = !{!8, !8, i64 0}
!35 = !{!19, !11, i64 26}
!36 = !{!19, !8, i64 33}
!37 = !{!19, !8, i64 32}
!38 = !{!19, !7, i64 208}
!39 = !{!6, !7, i64 12}
!40 = !{!19, !7, i64 164}
!41 = !{!19, !7, i64 156}
!42 = !{!19, !7, i64 160}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass