; LLVM IR from kala13x/libxutils :: src/net (api)

; 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.xapi_endpoint_ = type { i32, %struct.XSocketCert, ptr, ptr, ptr, i32, i16, i32, i8, i8, i8 }
%struct.XSocketCert = type { ptr, ptr, ptr, ptr, ptr, i32 }
%struct.xapi_data_ = type { [128 x i8], [128 x i8], [2048 x i8], i16, %struct.XSocket, i32, i8, i8, i8, i8, i8, i8, %struct.XByteBuffer, %struct.XByteBuffer, ptr, i32, i32, ptr, ptr, ptr }
%struct.XSocket = type { i32, %union.xsock_addr_t, i32, i32, i16, i32, i32, i32, i32, ptr }
%union.xsock_addr_t = type { %struct.sockaddr_in, [96 x i8] }
%struct.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.XByteBuffer = type { ptr, i64, i64, i16, i16, i32 }

@.str.27 = external hidden unnamed_addr constant [2 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @XAPI_ErrorCb(ptr noundef, ptr noundef, i32 noundef, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @XAPI_GetOrCreateEvents(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @XAPI_Listen(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %19

16:                                               ; preds = %2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %16, %2
  store i32 -2, ptr %3, align 4
  br label %211

20:                                               ; preds = %16
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.xapi_endpoint_, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !9
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %26, label %25

25:                                               ; preds = %20
  store i32 -2, ptr %3, align 4
  br label %211

26:                                               ; preds = %20
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.xapi_endpoint_, ptr %27, i32 0, i32 3
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = icmp ne ptr %29, null
  br i1 %30, label %32, label %31

31:                                               ; preds = %26
  store i32 -2, ptr %3, align 4
  br label %211

32:                                               ; preds = %26
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.xapi_endpoint_, ptr %33, i32 0, i32 6
  %35 = load i16, ptr %34, align 4, !tbaa !15
  %36 = icmp ne i16 %35, 0
  br i1 %36, label %45, label %37

37:                                               ; preds = %32
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.xapi_endpoint_, ptr %38, i32 0, i32 9
  %40 = load i8, ptr %39, align 1, !tbaa !16
  %41 = icmp ne i8 %40, 0
  br i1 %41, label %45, label %42

42:                                               ; preds = %37
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = call i32 @XAPI_ErrorCb(ptr noundef %43, ptr noundef null, i32 noundef 0, i8 noundef zeroext 3)
  store i32 -2, ptr %3, align 4
  br label %211

45:                                               ; preds = %37, %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.xapi_endpoint_, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 8, !tbaa !9
  %50 = call ptr @XAPI_NewData(ptr noundef %46, i32 noundef %49)
  store ptr %50, ptr %6, align 8, !tbaa !5
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = icmp eq ptr %51, null
  br i1 %52, label %53, label %56

53:                                               ; preds = %45
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = call i32 @XAPI_ErrorCb(ptr noundef %54, ptr noundef null, i32 noundef 0, i8 noundef zeroext 12)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %210

56:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.xapi_endpoint_, ptr %57, i32 0, i32 4
  %59 = load ptr, ptr %58, align 8, !tbaa !17
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %65

61:                                               ; preds = %56
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.xapi_endpoint_, ptr %62, i32 0, i32 4
  %64 = load ptr, ptr %63, align 8, !tbaa !17
  br label %66

65:                                               ; preds = %56
  br label %66

66:                                               ; preds = %65, %61
  %67 = phi ptr [ %64, %61 ], [ @.str.27, %65 ]
  store ptr %67, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.xapi_endpoint_, ptr %68, i32 0, i32 5
  %70 = load i32, ptr %69, align 8, !tbaa !18
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %72, label %76

72:                                               ; preds = %66
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.xapi_endpoint_, ptr %73, i32 0, i32 5
  %75 = load i32, ptr %74, align 8, !tbaa !18
  br label %77

76:                                               ; preds = %66
  br label %77

77:                                               ; preds = %76, %72
  %78 = phi i32 [ %75, %72 ], [ 1, %76 ]
  store i32 %78, ptr %9, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.xapi_data_, ptr %79, i32 0, i32 4
  store ptr %80, ptr %10, align 8, !tbaa !5
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.xapi_data_, ptr %81, i32 0, i32 0
  %83 = getelementptr inbounds [128 x i8], ptr %82, i64 0, i64 0
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.xapi_endpoint_, ptr %84, i32 0, i32 3
  %86 = load ptr, ptr %85, align 8, !tbaa !14
  %87 = call i64 @xstrncpy(ptr noundef %83, i64 noundef 128, ptr noundef %86)
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.xapi_data_, ptr %88, i32 0, i32 2
  %90 = getelementptr inbounds [2048 x i8], ptr %89, i64 0, i64 0
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = call i64 @xstrncpy(ptr noundef %90, i64 noundef 2048, ptr noundef %91)
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.xapi_endpoint_, ptr %93, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !20
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.xapi_data_, ptr %96, i32 0, i32 18
  store ptr %95, ptr %97, align 8, !tbaa !21
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.xapi_endpoint_, ptr %98, i32 0, i32 6
  %100 = load i16, ptr %99, align 4, !tbaa !15
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.xapi_data_, ptr %101, i32 0, i32 3
  store i16 %100, ptr %102, align 8, !tbaa !26
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.xapi_data_, ptr %103, i32 0, i32 16
  store i32 2, ptr %104, align 4, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 1024, ptr %11, align 4, !tbaa !19
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.xapi_endpoint_, ptr %105, i32 0, i32 8
  %107 = load i8, ptr %106, align 4, !tbaa !28
  %108 = icmp ne i8 %107, 0
  br i1 %108, label %109, label %112

109:                                              ; preds = %77
  %110 = load i32, ptr %11, align 4, !tbaa !19
  %111 = or i32 %110, 32768
  store i32 %111, ptr %11, align 4, !tbaa !19
  br label %112

112:                                              ; preds = %109, %77
  %113 = load ptr, ptr %5, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.xapi_endpoint_, ptr %113, i32 0, i32 10
  %115 = load i8, ptr %114, align 2, !tbaa !29
  %116 = icmp ne i8 %115, 0
  br i1 %116, label %117, label %120

117:                                              ; preds = %112
  %118 = load i32, ptr %11, align 4, !tbaa !19
  %119 = or i32 %118, 16
  store i32 %119, ptr %11, align 4, !tbaa !19
  br label %120

120:                                              ; preds = %117, %112
  %121 = load ptr, ptr %5, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.xapi_endpoint_, ptr %121, i32 0, i32 9
  %123 = load i8, ptr %122, align 1, !tbaa !16
  %124 = icmp ne i8 %123, 0
  br i1 %124, label %125, label %128

125:                                              ; preds = %120
  %126 = load i32, ptr %11, align 4, !tbaa !19
  %127 = or i32 %126, 8
  store i32 %127, ptr %11, align 4, !tbaa !19
  br label %131

128:                                              ; preds = %120
  %129 = load i32, ptr %11, align 4, !tbaa !19
  %130 = or i32 %129, 1
  store i32 %130, ptr %11, align 4, !tbaa !19
  br label %131

131:                                              ; preds = %128, %125
  %132 = load ptr, ptr %10, align 8, !tbaa !5
  %133 = load i32, ptr %11, align 4, !tbaa !19
  %134 = load ptr, ptr %5, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.xapi_endpoint_, ptr %134, i32 0, i32 3
  %136 = load ptr, ptr %135, align 8, !tbaa !14
  %137 = load ptr, ptr %5, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.xapi_endpoint_, ptr %137, i32 0, i32 6
  %139 = load i16, ptr %138, align 4, !tbaa !15
  %140 = call i32 @XSock_Create(ptr noundef %132, i32 noundef %133, ptr noundef %136, i16 noundef zeroext %139)
  %141 = load ptr, ptr %5, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.xapi_endpoint_, ptr %141, i32 0, i32 10
  %143 = load i8, ptr %142, align 2, !tbaa !29
  %144 = icmp ne i8 %143, 0
  br i1 %144, label %145, label %150

145:                                              ; preds = %131
  %146 = load ptr, ptr %10, align 8, !tbaa !5
  %147 = load ptr, ptr %5, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.xapi_endpoint_, ptr %147, i32 0, i32 1
  %149 = call i32 @XSock_SetSSLCert(ptr noundef %146, ptr noundef %148)
  br label %150

150:                                              ; preds = %145, %131
  %151 = load ptr, ptr %10, align 8, !tbaa !5
  %152 = call i32 @XSock_ReuseAddr(ptr noundef %151, i8 noundef zeroext 1)
  %153 = load ptr, ptr %10, align 8, !tbaa !5
  %154 = call i32 @XSock_NonBlock(ptr noundef %153, i8 noundef zeroext 1)
  %155 = load ptr, ptr %10, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.XSocket, ptr %155, i32 0, i32 5
  %157 = load i32, ptr %156, align 8, !tbaa !30
  %158 = icmp eq i32 %157, -1
  br i1 %158, label %159, label %167

159:                                              ; preds = %150
  %160 = load ptr, ptr %4, align 8, !tbaa !5
  %161 = load ptr, ptr %6, align 8, !tbaa !5
  %162 = load ptr, ptr %10, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.XSocket, ptr %162, i32 0, i32 0
  %164 = load i32, ptr %163, align 8, !tbaa !31
  %165 = trunc i32 %164 to i8
  %166 = call i32 @XAPI_ErrorCb(ptr noundef %160, ptr noundef %161, i32 noundef 4, i8 noundef zeroext %165)
  call void @XAPI_FreeData(ptr noundef %6)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %209

167:                                              ; preds = %150
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %168 = load ptr, ptr %4, align 8, !tbaa !5
  %169 = call ptr @XAPI_GetOrCreateEvents(ptr noundef %168)
  store ptr %169, ptr %12, align 8, !tbaa !5
  %170 = load ptr, ptr %12, align 8, !tbaa !5
  %171 = icmp eq ptr %170, null
  br i1 %171, label %172, label %173

172:                                              ; preds = %167
  call void @XAPI_FreeData(ptr noundef %6)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %208

173:                                              ; preds = %167
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %174 = load ptr, ptr %12, align 8, !tbaa !5
  %175 = load ptr, ptr %6, align 8, !tbaa !5
  %176 = load ptr, ptr %10, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.XSocket, ptr %176, i32 0, i32 5
  %178 = load i32, ptr %177, align 8, !tbaa !30
  %179 = load i32, ptr %9, align 4, !tbaa !19
  %180 = call ptr @XEvents_RegisterEvent(ptr noundef %174, ptr noundef %175, i32 noundef %178, i32 noundef %179, i32 noundef 2)
  store ptr %180, ptr %13, align 8, !tbaa !5
  %181 = load ptr, ptr %13, align 8, !tbaa !5
  %182 = icmp eq ptr %181, null
  br i1 %182, label %183, label %187

183:                                              ; preds = %173
  %184 = load ptr, ptr %4, align 8, !tbaa !5
  %185 = load ptr, ptr %6, align 8, !tbaa !5
  %186 = call i32 @XAPI_ErrorCb(ptr noundef %184, ptr noundef %185, i32 noundef 0, i8 noundef zeroext 9)
  call void @XAPI_FreeData(ptr noundef %6)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %207

187:                                              ; preds = %173
  %188 = load ptr, ptr %13, align 8, !tbaa !5
  %189 = load ptr, ptr %6, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct.xapi_data_, ptr %189, i32 0, i32 14
  store ptr %188, ptr %190, align 8, !tbaa !32
  %191 = load i32, ptr %9, align 4, !tbaa !19
  %192 = load ptr, ptr %6, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.xapi_data_, ptr %192, i32 0, i32 5
  store i32 %191, ptr %193, align 8, !tbaa !33
  %194 = load ptr, ptr %4, align 8, !tbaa !5
  %195 = load ptr, ptr %6, align 8, !tbaa !5
  %196 = call i32 @XAPI_ServiceCb(ptr noundef %194, ptr noundef %195, i32 noundef 7)
  %197 = icmp slt i32 %196, 0
  br i1 %197, label %198, label %206

198:                                              ; preds = %187
  %199 = load ptr, ptr %12, align 8, !tbaa !5
  %200 = load ptr, ptr %6, align 8, !tbaa !5
  %201 = getelementptr inbounds %struct.xapi_data_, ptr %200, i32 0, i32 14
  %202 = load ptr, ptr %201, align 8, !tbaa !32
  %203 = call i32 @XEvents_Delete(ptr noundef %199, ptr noundef %202)
  %204 = load ptr, ptr %6, align 8, !tbaa !5
  %205 = getelementptr inbounds %struct.xapi_data_, ptr %204, i32 0, i32 14
  store ptr null, ptr %205, align 8, !tbaa !32
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %207

206:                                              ; preds = %187
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %207

207:                                              ; preds = %206, %198, %183
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %208

208:                                              ; preds = %207, %172
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %209

209:                                              ; preds = %208, %159
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %210

210:                                              ; preds = %209, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %211

211:                                              ; preds = %210, %42, %31, %25, %19
  %212 = load i32, ptr %3, align 4
  ret i32 %212
}

; Function Attrs: nounwind uwtable
declare hidden ptr @XAPI_NewData(ptr noundef, i32 noundef) #1

declare i64 @xstrncpy(ptr noundef, i64 noundef, ptr noundef) #2

declare i32 @XSock_Create(ptr noundef, i32 noundef, ptr noundef, i16 noundef zeroext) #2

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

declare i32 @XSock_ReuseAddr(ptr noundef, i8 noundef zeroext) #2

declare i32 @XSock_NonBlock(ptr noundef, i8 noundef zeroext) #2

; Function Attrs: nounwind uwtable
declare hidden void @XAPI_FreeData(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare hidden i32 @XAPI_ServiceCb(ptr noundef, ptr noundef, i32 noundef) #1

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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, !11, i64 0}
!10 = !{!"xapi_endpoint_", !11, i64 0, !12, i64 8, !6, i64 56, !6, i64 64, !6, i64 72, !11, i64 80, !13, i64 84, !11, i64 88, !7, i64 92, !7, i64 93, !7, i64 94}
!11 = !{!"int", !7, i64 0}
!12 = !{!"XSocketCert", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40}
!13 = !{!"short", !7, i64 0}
!14 = !{!10, !6, i64 64}
!15 = !{!10, !13, i64 84}
!16 = !{!10, !7, i64 93}
!17 = !{!10, !6, i64 72}
!18 = !{!10, !11, i64 80}
!19 = !{!11, !11, i64 0}
!20 = !{!10, !6, i64 56}
!21 = !{!22, !6, i64 2568}
!22 = !{!"xapi_data_", !7, i64 0, !7, i64 128, !7, i64 256, !13, i64 2304, !23, i64 2312, !11, i64 2464, !7, i64 2468, !7, i64 2469, !7, i64 2470, !7, i64 2471, !7, i64 2472, !7, i64 2473, !24, i64 2480, !24, i64 2512, !6, i64 2544, !11, i64 2552, !11, i64 2556, !6, i64 2560, !6, i64 2568, !6, i64 2576}
!23 = !{!"XSocket", !11, i64 0, !7, i64 4, !11, i64 116, !11, i64 120, !13, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !6, i64 144}
!24 = !{!"XByteBuffer", !6, i64 0, !25, i64 8, !25, i64 16, !13, i64 24, !13, i64 26, !11, i64 28}
!25 = !{!"long", !7, i64 0}
!26 = !{!22, !13, i64 2304}
!27 = !{!22, !11, i64 2556}
!28 = !{!10, !7, i64 92}
!29 = !{!10, !7, i64 94}
!30 = !{!23, !11, i64 128}
!31 = !{!23, !11, i64 0}
!32 = !{!22, !6, i64 2544}
!33 = !{!22, !11, i64 2464}


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

@.str.27 = external hidden unnamed_addr constant [2 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @XAPI_ErrorCb(ptr noundef, ptr noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @XAPI_GetOrCreateEvents(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -2, 2) i32 @XAPI_Listen(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca ptr, align 8
  %4 = icmp ne ptr %0, null
  %5 = icmp ne ptr %1, null
  %or.cond = and i1 %4, %5
  br i1 %or.cond, label %6, label %83

6:                                                ; preds = %2
  %7 = load i32, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %83, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %1, i64 64
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %.not58 = icmp eq ptr %10, null
  br i1 %.not58, label %83, label %11

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %1, i64 84
  %13 = load i16, ptr %12, align 4, !tbaa !14
  %.not59 = icmp eq i16 %13, 0
  br i1 %.not59, label %14, label %19

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %1, i64 93
  %16 = load i8, ptr %15, align 1, !tbaa !15
  %.not60 = icmp eq i8 %16, 0
  br i1 %.not60, label %17, label %19

17:                                               ; preds = %14
  %18 = tail call i32 @XAPI_ErrorCb(ptr noundef nonnull %0, ptr noundef null, i32 noundef 0, i8 noundef zeroext 3)
  br label %83

19:                                               ; preds = %14, %11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %20 = tail call ptr @XAPI_NewData(ptr noundef nonnull %0, i32 noundef %7)
  store ptr %20, ptr %3, align 8, !tbaa !16
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %24

22:                                               ; preds = %19
  %23 = tail call i32 @XAPI_ErrorCb(ptr noundef nonnull %0, ptr noundef null, i32 noundef 0, i8 noundef zeroext 12)
  br label %82

24:                                               ; preds = %19
  %25 = getelementptr inbounds i8, ptr %1, i64 72
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %.not61 = icmp eq ptr %26, null
  %spec.select = select i1 %.not61, ptr @.str.27, ptr %26
  %27 = getelementptr inbounds i8, ptr %1, i64 80
  %28 = load i32, ptr %27, align 8, !tbaa !18
  %29 = tail call i32 @llvm.umax.i32(i32 %28, i32 1)
  %30 = getelementptr inbounds i8, ptr %20, i64 2312
  %31 = load ptr, ptr %9, align 8, !tbaa !13
  %32 = tail call i64 @xstrncpy(ptr noundef nonnull %20, i64 noundef 128, ptr noundef %31) #4
  %33 = getelementptr inbounds i8, ptr %20, i64 256
  %34 = tail call i64 @xstrncpy(ptr noundef nonnull %33, i64 noundef 2048, ptr noundef nonnull %spec.select) #4
  %35 = getelementptr inbounds i8, ptr %1, i64 56
  %36 = load ptr, ptr %35, align 8, !tbaa !19
  %37 = getelementptr inbounds i8, ptr %20, i64 2568
  store ptr %36, ptr %37, align 8, !tbaa !20
  %38 = load i16, ptr %12, align 4, !tbaa !14
  %39 = getelementptr inbounds i8, ptr %20, i64 2304
  store i16 %38, ptr %39, align 8, !tbaa !25
  %40 = getelementptr inbounds i8, ptr %20, i64 2556
  store i32 2, ptr %40, align 4, !tbaa !26
  %41 = getelementptr inbounds i8, ptr %1, i64 92
  %42 = load i8, ptr %41, align 4, !tbaa !27
  %.not63 = icmp eq i8 %42, 0
  %.049 = select i1 %.not63, i32 1024, i32 33792
  %43 = getelementptr inbounds i8, ptr %1, i64 94
  %44 = load i8, ptr %43, align 2, !tbaa !28
  %.not64 = icmp eq i8 %44, 0
  %45 = or disjoint i32 %.049, 16
  %.150 = select i1 %.not64, i32 %.049, i32 %45
  %46 = getelementptr inbounds i8, ptr %1, i64 93
  %47 = load i8, ptr %46, align 1, !tbaa !15
  %.not65 = icmp eq i8 %47, 0
  %.251.v = select i1 %.not65, i32 1, i32 8
  %.251 = or disjoint i32 %.150, %.251.v
  %48 = load ptr, ptr %9, align 8, !tbaa !13
  %49 = tail call i32 @XSock_Create(ptr noundef nonnull %30, i32 noundef %.251, ptr noundef %48, i16 noundef zeroext %38) #4
  %50 = load i8, ptr %43, align 2, !tbaa !28
  %.not66 = icmp eq i8 %50, 0
  br i1 %.not66, label %54, label %51

51:                                               ; preds = %24
  %52 = getelementptr inbounds i8, ptr %1, i64 8
  %53 = tail call i32 @XSock_SetSSLCert(ptr noundef nonnull %30, ptr noundef nonnull %52) #4
  br label %54

54:                                               ; preds = %51, %24
  %55 = tail call i32 @XSock_ReuseAddr(ptr noundef nonnull %30, i8 noundef zeroext 1) #4
  %56 = tail call i32 @XSock_NonBlock(ptr noundef nonnull %30, i8 noundef zeroext 1) #4
  %57 = getelementptr inbounds i8, ptr %20, i64 2440
  %58 = load i32, ptr %57, align 8, !tbaa !29
  %59 = icmp eq i32 %58, -1
  br i1 %59, label %60, label %64

60:                                               ; preds = %54
  %61 = load i32, ptr %30, align 8, !tbaa !30
  %62 = trunc i32 %61 to i8
  %63 = tail call i32 @XAPI_ErrorCb(ptr noundef nonnull %0, ptr noundef nonnull %20, i32 noundef 4, i8 noundef zeroext %62)
  call void @XAPI_FreeData(ptr noundef nonnull %3)
  br label %82

64:                                               ; preds = %54
  %65 = tail call ptr @XAPI_GetOrCreateEvents(ptr noundef nonnull %0)
  %66 = icmp eq ptr %65, null
  br i1 %66, label %67, label %68

67:                                               ; preds = %64
  call void @XAPI_FreeData(ptr noundef nonnull %3)
  br label %82

68:                                               ; preds = %64
  %69 = load i32, ptr %57, align 8, !tbaa !29
  %70 = tail call ptr @XEvents_RegisterEvent(ptr noundef nonnull %65, ptr noundef nonnull %20, i32 noundef %69, i32 noundef %29, i32 noundef 2) #4
  %71 = icmp eq ptr %70, null
  br i1 %71, label %72, label %74

72:                                               ; preds = %68
  %73 = tail call i32 @XAPI_ErrorCb(ptr noundef nonnull %0, ptr noundef nonnull %20, i32 noundef 0, i8 noundef zeroext 9)
  call void @XAPI_FreeData(ptr noundef nonnull %3)
  br label %82

74:                                               ; preds = %68
  %75 = getelementptr inbounds i8, ptr %20, i64 2544
  store ptr %70, ptr %75, align 8, !tbaa !31
  %76 = getelementptr inbounds i8, ptr %20, i64 2464
  store i32 %29, ptr %76, align 8, !tbaa !32
  %77 = tail call i32 @XAPI_ServiceCb(ptr noundef nonnull %0, ptr noundef nonnull %20, i32 noundef 7)
  %78 = icmp slt i32 %77, 0
  br i1 %78, label %79, label %82

79:                                               ; preds = %74
  %80 = load ptr, ptr %75, align 8, !tbaa !31
  %81 = tail call i32 @XEvents_Delete(ptr noundef nonnull %65, ptr noundef %80) #4
  store ptr null, ptr %75, align 8, !tbaa !31
  br label %82

82:                                               ; preds = %60, %72, %79, %74, %67, %22
  %.3 = phi i32 [ -1, %22 ], [ -1, %60 ], [ -1, %67 ], [ -1, %72 ], [ -1, %79 ], [ 1, %74 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  br label %83

83:                                               ; preds = %8, %6, %2, %82, %17
  %.4 = phi i32 [ %.3, %82 ], [ -2, %17 ], [ -2, %2 ], [ -2, %6 ], [ -2, %8 ]
  ret i32 %.4
}

; Function Attrs: nounwind uwtable
declare hidden ptr @XAPI_NewData(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i64 @xstrncpy(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

declare i32 @XSock_Create(ptr noundef, i32 noundef, ptr noundef, i16 noundef zeroext) local_unnamed_addr #2

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

declare i32 @XSock_ReuseAddr(ptr noundef, i8 noundef zeroext) local_unnamed_addr #2

declare i32 @XSock_NonBlock(ptr noundef, i8 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @XAPI_FreeData(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden i32 @XAPI_ServiceCb(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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, !7, i64 0}
!6 = !{!"xapi_endpoint_", !7, i64 0, !10, i64 8, !11, i64 56, !11, i64 64, !11, i64 72, !7, i64 80, !12, i64 84, !7, i64 88, !8, i64 92, !8, i64 93, !8, i64 94}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"XSocketCert", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !7, i64 40}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!6, !11, i64 64}
!14 = !{!6, !12, i64 84}
!15 = !{!6, !8, i64 93}
!16 = !{!11, !11, i64 0}
!17 = !{!6, !11, i64 72}
!18 = !{!6, !7, i64 80}
!19 = !{!6, !11, i64 56}
!20 = !{!21, !11, i64 2568}
!21 = !{!"xapi_data_", !8, i64 0, !8, i64 128, !8, i64 256, !12, i64 2304, !22, i64 2312, !7, i64 2464, !8, i64 2468, !8, i64 2469, !8, i64 2470, !8, i64 2471, !8, i64 2472, !8, i64 2473, !23, i64 2480, !23, i64 2512, !11, i64 2544, !7, i64 2552, !7, i64 2556, !11, i64 2560, !11, i64 2568, !11, i64 2576}
!22 = !{!"XSocket", !7, i64 0, !8, i64 4, !7, i64 116, !7, i64 120, !12, i64 124, !7, i64 128, !7, i64 132, !7, i64 136, !7, i64 140, !11, i64 144}
!23 = !{!"XByteBuffer", !11, i64 0, !24, i64 8, !24, i64 16, !12, i64 24, !12, i64 26, !7, i64 28}
!24 = !{!"long", !8, i64 0}
!25 = !{!21, !12, i64 2304}
!26 = !{!21, !7, i64 2556}
!27 = !{!6, !8, i64 92}
!28 = !{!6, !8, i64 94}
!29 = !{!22, !7, i64 128}
!30 = !{!22, !7, i64 0}
!31 = !{!21, !11, i64 2544}
!32 = !{!21, !7, i64 2464}


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