; 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.XSocketInfo = type { [128 x i8], [256 x i8], i32, i32, i16 }
%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
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

; 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

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

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

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

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

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

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

32:                                               ; preds = %27
  store i32 -2, ptr %3, align 4
  br label %212

33:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 396, ptr %6) #3
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.xapi_endpoint_, ptr %34, i32 0, i32 6
  %36 = load i16, ptr %35, align 4, !tbaa !15
  %37 = icmp ne i16 %36, 0
  br i1 %37, label %46, label %38

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

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

46:                                               ; preds = %38, %33
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.xapi_endpoint_, ptr %47, i32 0, i32 9
  %49 = load i8, ptr %48, align 1, !tbaa !16
  %50 = icmp ne i8 %49, 0
  br i1 %50, label %51, label %58

51:                                               ; preds = %46
  call void @XSock_InitInfo(ptr noundef %6)
  %52 = getelementptr inbounds %struct.XSocketInfo, ptr %6, i32 0, i32 0
  %53 = getelementptr inbounds [128 x i8], ptr %52, i64 0, i64 0
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.xapi_endpoint_, ptr %54, i32 0, i32 3
  %56 = load ptr, ptr %55, align 8, !tbaa !14
  %57 = call i64 @xstrncpy(ptr noundef %53, i64 noundef 128, ptr noundef %56)
  br label %68

58:                                               ; preds = %46
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.xapi_endpoint_, ptr %59, i32 0, i32 3
  %61 = load ptr, ptr %60, align 8, !tbaa !14
  %62 = call i32 @XSock_GetAddrInfo(ptr noundef %6, ptr noundef %61)
  %63 = icmp slt i32 %62, 0
  br i1 %63, label %64, label %67

64:                                               ; preds = %58
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = call i32 @XAPI_ErrorCb(ptr noundef %65, ptr noundef null, i32 noundef 0, i8 noundef zeroext 10)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %211

67:                                               ; preds = %58
  br label %68

68:                                               ; preds = %67, %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.xapi_endpoint_, ptr %70, i32 0, i32 0
  %72 = load i32, ptr %71, align 8, !tbaa !9
  %73 = call ptr @XAPI_NewData(ptr noundef %69, i32 noundef %72)
  store ptr %73, ptr %8, align 8, !tbaa !5
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = icmp eq ptr %74, null
  br i1 %75, label %76, label %79

76:                                               ; preds = %68
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = call i32 @XAPI_ErrorCb(ptr noundef %77, 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

79:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.xapi_endpoint_, ptr %80, i32 0, i32 4
  %82 = load ptr, ptr %81, align 8, !tbaa !17
  %83 = icmp ne ptr %82, null
  br i1 %83, label %84, label %88

84:                                               ; preds = %79
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.xapi_endpoint_, ptr %85, i32 0, i32 4
  %87 = load ptr, ptr %86, align 8, !tbaa !17
  br label %89

88:                                               ; preds = %79
  br label %89

89:                                               ; preds = %88, %84
  %90 = phi ptr [ %87, %84 ], [ @.str.27, %88 ]
  store ptr %90, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.xapi_endpoint_, ptr %91, i32 0, i32 5
  %93 = load i32, ptr %92, align 8, !tbaa !18
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %95, label %99

95:                                               ; preds = %89
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.xapi_endpoint_, ptr %96, i32 0, i32 5
  %98 = load i32, ptr %97, align 8, !tbaa !18
  br label %100

99:                                               ; preds = %89
  br label %100

100:                                              ; preds = %99, %95
  %101 = phi i32 [ %98, %95 ], [ 5, %99 ]
  store i32 %101, ptr %10, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %102 = load ptr, ptr %8, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.xapi_data_, ptr %102, i32 0, i32 4
  store ptr %103, ptr %11, align 8, !tbaa !5
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.xapi_data_, ptr %104, i32 0, i32 0
  %106 = getelementptr inbounds [128 x i8], ptr %105, i64 0, i64 0
  %107 = getelementptr inbounds %struct.XSocketInfo, ptr %6, i32 0, i32 0
  %108 = getelementptr inbounds [128 x i8], ptr %107, i64 0, i64 0
  %109 = call i64 @xstrncpy(ptr noundef %106, i64 noundef 128, ptr noundef %108)
  %110 = load ptr, ptr %8, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.xapi_data_, ptr %110, i32 0, i32 2
  %112 = getelementptr inbounds [2048 x i8], ptr %111, i64 0, i64 0
  %113 = load ptr, ptr %9, align 8, !tbaa !5
  %114 = call i64 @xstrncpy(ptr noundef %112, i64 noundef 2048, ptr noundef %113)
  %115 = load ptr, ptr %5, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.xapi_endpoint_, ptr %115, i32 0, i32 2
  %117 = load ptr, ptr %116, align 8, !tbaa !20
  %118 = load ptr, ptr %8, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.xapi_data_, ptr %118, i32 0, i32 18
  store ptr %117, ptr %119, align 8, !tbaa !21
  %120 = load ptr, ptr %5, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.xapi_endpoint_, ptr %120, i32 0, i32 6
  %122 = load i16, ptr %121, align 4, !tbaa !15
  %123 = load ptr, ptr %8, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.xapi_data_, ptr %123, i32 0, i32 3
  store i16 %122, ptr %124, align 8, !tbaa !26
  %125 = load ptr, ptr %8, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.xapi_data_, ptr %125, i32 0, i32 16
  store i32 3, ptr %126, align 4, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 16896, ptr %12, align 4, !tbaa !19
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.xapi_endpoint_, ptr %127, i32 0, i32 10
  %129 = load i8, ptr %128, align 2, !tbaa !28
  %130 = icmp ne i8 %129, 0
  br i1 %130, label %131, label %134

131:                                              ; preds = %100
  %132 = load i32, ptr %12, align 4, !tbaa !19
  %133 = or i32 %132, 16
  store i32 %133, ptr %12, align 4, !tbaa !19
  br label %134

134:                                              ; preds = %131, %100
  %135 = load ptr, ptr %5, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.xapi_endpoint_, ptr %135, i32 0, i32 9
  %137 = load i8, ptr %136, align 1, !tbaa !16
  %138 = icmp ne i8 %137, 0
  br i1 %138, label %139, label %142

139:                                              ; preds = %134
  %140 = load i32, ptr %12, align 4, !tbaa !19
  %141 = or i32 %140, 8
  store i32 %141, ptr %12, align 4, !tbaa !19
  br label %145

142:                                              ; preds = %134
  %143 = load i32, ptr %12, align 4, !tbaa !19
  %144 = or i32 %143, 1
  store i32 %144, ptr %12, align 4, !tbaa !19
  br label %145

145:                                              ; preds = %142, %139
  %146 = load ptr, ptr %11, align 8, !tbaa !5
  %147 = load i32, ptr %12, align 4, !tbaa !19
  %148 = load ptr, ptr %8, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.xapi_data_, ptr %148, i32 0, i32 0
  %150 = getelementptr inbounds [128 x i8], ptr %149, i64 0, i64 0
  %151 = load ptr, ptr %5, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.xapi_endpoint_, ptr %151, i32 0, i32 6
  %153 = load i16, ptr %152, align 4, !tbaa !15
  %154 = call i32 @XSock_Create(ptr noundef %146, i32 noundef %147, ptr noundef %150, i16 noundef zeroext %153)
  %155 = load ptr, ptr %11, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.XSocket, ptr %155, i32 0, i32 5
  %157 = load i32, ptr %156, align 8, !tbaa !29
  %158 = icmp eq i32 %157, -1
  br i1 %158, label %159, label %167

159:                                              ; preds = %145
  %160 = load ptr, ptr %4, align 8, !tbaa !5
  %161 = load ptr, ptr %8, align 8, !tbaa !5
  %162 = load ptr, ptr %11, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.XSocket, ptr %162, i32 0, i32 0
  %164 = load i32, ptr %163, align 8, !tbaa !30
  %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 %8)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %209

167:                                              ; preds = %145
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %168 = load ptr, ptr %4, align 8, !tbaa !5
  %169 = call ptr @XAPI_GetOrCreateEvents(ptr noundef %168)
  store ptr %169, ptr %13, align 8, !tbaa !5
  %170 = load ptr, ptr %13, 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 %8)
  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 %14) #3
  %174 = load ptr, ptr %13, align 8, !tbaa !5
  %175 = load ptr, ptr %8, align 8, !tbaa !5
  %176 = load ptr, ptr %11, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.XSocket, ptr %176, i32 0, i32 5
  %178 = load i32, ptr %177, align 8, !tbaa !29
  %179 = load i32, ptr %10, align 4, !tbaa !19
  %180 = call ptr @XEvents_RegisterEvent(ptr noundef %174, ptr noundef %175, i32 noundef %178, i32 noundef %179, i32 noundef 3)
  store ptr %180, ptr %14, align 8, !tbaa !5
  %181 = load ptr, ptr %14, 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 %8, 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 %8)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %207

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

198:                                              ; preds = %187
  %199 = load ptr, ptr %13, align 8, !tbaa !5
  %200 = load ptr, ptr %8, align 8, !tbaa !5
  %201 = getelementptr inbounds %struct.xapi_data_, ptr %200, i32 0, i32 14
  %202 = load ptr, ptr %201, align 8, !tbaa !31
  %203 = call i32 @XEvents_Delete(ptr noundef %199, ptr noundef %202)
  %204 = load ptr, ptr %8, align 8, !tbaa !5
  %205 = getelementptr inbounds %struct.xapi_data_, ptr %204, i32 0, i32 14
  store ptr null, ptr %205, align 8, !tbaa !31
  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 %14) #3
  br label %208

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

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

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

211:                                              ; preds = %210, %64, %43
  call void @llvm.lifetime.end.p0(i64 396, ptr %6) #3
  br label %212

212:                                              ; preds = %211, %32, %26, %20
  %213 = load i32, ptr %3, align 4
  ret i32 %213
}

declare void @XSock_InitInfo(ptr noundef) #2

declare i32 @XSock_GetAddrInfo(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 94}
!29 = !{!23, !11, i64 128}
!30 = !{!23, !11, i64 0}
!31 = !{!22, !6, i64 2544}
!32 = !{!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"

%struct.XSocketInfo = type { [128 x i8], [256 x i8], i32, i32, i16 }

@.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
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

; 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: nounwind uwtable
define dso_local noundef i32 @XAPI_Connect(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #1 {
  %3 = alloca %struct.XSocketInfo, align 4
  %4 = alloca ptr, align 8
  %5 = icmp ne ptr %0, null
  %6 = icmp ne ptr %1, null
  %or.cond = and i1 %5, %6
  br i1 %or.cond, label %7, label %92

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

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

12:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 396, ptr nonnull %3) #3
  %13 = getelementptr inbounds i8, ptr %1, i64 84
  %14 = load i16, ptr %13, align 4, !tbaa !14
  %.not53 = icmp eq i16 %14, 0
  %15 = getelementptr inbounds i8, ptr %1, i64 93
  %16 = load i8, ptr %15, align 1, !tbaa !15
  %.not54 = icmp eq i8 %16, 0
  br i1 %.not53, label %17, label %21

17:                                               ; preds = %12
  br i1 %.not54, label %19, label %.thread

.thread:                                          ; preds = %17
  %18 = getelementptr inbounds i8, ptr %1, i64 93
  br label %23

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

21:                                               ; preds = %12
  %22 = getelementptr inbounds i8, ptr %1, i64 93
  br i1 %.not54, label %27, label %23

23:                                               ; preds = %.thread, %21
  %24 = phi ptr [ %18, %.thread ], [ %22, %21 ]
  call void @XSock_InitInfo(ptr noundef nonnull %3) #3
  %25 = load ptr, ptr %10, align 8, !tbaa !13
  %26 = call i64 @xstrncpy(ptr noundef nonnull %3, i64 noundef 128, ptr noundef %25) #3
  br label %32

27:                                               ; preds = %21
  %28 = call i32 @XSock_GetAddrInfo(ptr noundef nonnull %3, ptr noundef nonnull %11) #3
  %29 = icmp slt i32 %28, 0
  br i1 %29, label %30, label %32

30:                                               ; preds = %27
  %31 = call i32 @XAPI_ErrorCb(ptr noundef nonnull %0, ptr noundef null, i32 noundef 0, i8 noundef zeroext 10)
  br label %91

32:                                               ; preds = %27, %23
  %33 = phi ptr [ %22, %27 ], [ %24, %23 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %34 = load i32, ptr %1, align 8, !tbaa !5
  %35 = call ptr @XAPI_NewData(ptr noundef nonnull %0, i32 noundef %34)
  store ptr %35, ptr %4, align 8, !tbaa !16
  %36 = icmp eq ptr %35, null
  br i1 %36, label %37, label %39

37:                                               ; preds = %32
  %38 = call i32 @XAPI_ErrorCb(ptr noundef nonnull %0, ptr noundef null, i32 noundef 0, i8 noundef zeroext 12)
  br label %90

39:                                               ; preds = %32
  %40 = getelementptr inbounds i8, ptr %1, i64 72
  %41 = load ptr, ptr %40, align 8, !tbaa !17
  %.not56 = icmp eq ptr %41, null
  %spec.select = select i1 %.not56, ptr @.str.27, ptr %41
  %42 = getelementptr inbounds i8, ptr %1, i64 80
  %43 = load i32, ptr %42, align 8, !tbaa !18
  %.not57 = icmp eq i32 %43, 0
  %44 = select i1 %.not57, i32 5, i32 %43
  %45 = getelementptr inbounds i8, ptr %35, i64 2312
  %46 = call i64 @xstrncpy(ptr noundef nonnull %35, i64 noundef 128, ptr noundef nonnull %3) #3
  %47 = getelementptr inbounds i8, ptr %35, i64 256
  %48 = call i64 @xstrncpy(ptr noundef nonnull %47, i64 noundef 2048, ptr noundef nonnull %spec.select) #3
  %49 = getelementptr inbounds i8, ptr %1, i64 56
  %50 = load ptr, ptr %49, align 8, !tbaa !19
  %51 = getelementptr inbounds i8, ptr %35, i64 2568
  store ptr %50, ptr %51, align 8, !tbaa !20
  %52 = load i16, ptr %13, align 4, !tbaa !14
  %53 = getelementptr inbounds i8, ptr %35, i64 2304
  store i16 %52, ptr %53, align 8, !tbaa !25
  %54 = getelementptr inbounds i8, ptr %35, i64 2556
  store i32 3, ptr %54, align 4, !tbaa !26
  %55 = getelementptr inbounds i8, ptr %1, i64 94
  %56 = load i8, ptr %55, align 2, !tbaa !27
  %.not58 = icmp eq i8 %56, 0
  %.044 = select i1 %.not58, i32 16896, i32 16912
  %57 = load i8, ptr %33, align 1, !tbaa !15
  %.not59 = icmp eq i8 %57, 0
  %.145.v = select i1 %.not59, i32 1, i32 8
  %.145 = or disjoint i32 %.145.v, %.044
  %58 = call i32 @XSock_Create(ptr noundef nonnull %45, i32 noundef %.145, ptr noundef nonnull %35, i16 noundef zeroext %52) #3
  %59 = getelementptr inbounds i8, ptr %35, i64 2440
  %60 = load i32, ptr %59, align 8, !tbaa !28
  %61 = icmp eq i32 %60, -1
  br i1 %61, label %62, label %66

62:                                               ; preds = %39
  %63 = load i32, ptr %45, align 8, !tbaa !29
  %64 = trunc i32 %63 to i8
  %65 = call i32 @XAPI_ErrorCb(ptr noundef nonnull %0, ptr noundef nonnull %35, i32 noundef 4, i8 noundef zeroext %64)
  call void @XAPI_FreeData(ptr noundef nonnull %4)
  br label %90

66:                                               ; preds = %39
  %67 = call ptr @XAPI_GetOrCreateEvents(ptr noundef nonnull %0)
  %68 = icmp eq ptr %67, null
  br i1 %68, label %69, label %70

69:                                               ; preds = %66
  call void @XAPI_FreeData(ptr noundef nonnull %4)
  br label %90

70:                                               ; preds = %66
  %71 = load ptr, ptr %4, align 8, !tbaa !16
  %72 = load i32, ptr %59, align 8, !tbaa !28
  %73 = call ptr @XEvents_RegisterEvent(ptr noundef nonnull %67, ptr noundef %71, i32 noundef %72, i32 noundef %44, i32 noundef 3) #3
  %74 = icmp eq ptr %73, null
  %75 = load ptr, ptr %4, align 8, !tbaa !16
  br i1 %74, label %76, label %78

76:                                               ; preds = %70
  %77 = call i32 @XAPI_ErrorCb(ptr noundef nonnull %0, ptr noundef %75, i32 noundef 0, i8 noundef zeroext 9)
  call void @XAPI_FreeData(ptr noundef nonnull %4)
  br label %90

78:                                               ; preds = %70
  %79 = getelementptr inbounds i8, ptr %75, i64 2544
  store ptr %73, ptr %79, align 8, !tbaa !30
  %80 = getelementptr inbounds i8, ptr %75, i64 2464
  store i32 %44, ptr %80, align 8, !tbaa !31
  %81 = call i32 @XAPI_ServiceCb(ptr noundef nonnull %0, ptr noundef %75, i32 noundef 6)
  %82 = icmp slt i32 %81, 0
  br i1 %82, label %83, label %90

83:                                               ; preds = %78
  %84 = load ptr, ptr %4, align 8, !tbaa !16
  %85 = getelementptr inbounds i8, ptr %84, i64 2544
  %86 = load ptr, ptr %85, align 8, !tbaa !30
  %87 = call i32 @XEvents_Delete(ptr noundef nonnull %67, ptr noundef %86) #3
  %88 = load ptr, ptr %4, align 8, !tbaa !16
  %89 = getelementptr inbounds i8, ptr %88, i64 2544
  store ptr null, ptr %89, align 8, !tbaa !30
  br label %90

90:                                               ; preds = %62, %76, %83, %78, %69, %37
  %.3 = phi i32 [ -1, %37 ], [ -1, %62 ], [ -1, %69 ], [ -1, %76 ], [ -1, %83 ], [ 1, %78 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  br label %91

91:                                               ; preds = %90, %30, %19
  %.4 = phi i32 [ %.3, %90 ], [ -1, %30 ], [ -2, %19 ]
  call void @llvm.lifetime.end.p0(i64 396, ptr nonnull %3) #3
  br label %92

92:                                               ; preds = %9, %7, %2, %91
  %.5 = phi i32 [ %.4, %91 ], [ -2, %2 ], [ -2, %7 ], [ -2, %9 ]
  ret i32 %.5
}

declare void @XSock_InitInfo(ptr noundef) local_unnamed_addr #2

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

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 = { 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 94}
!28 = !{!22, !7, i64 128}
!29 = !{!22, !7, i64 0}
!30 = !{!21, !11, i64 2544}
!31 = !{!21, !7, i64 2464}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass