; LLVM IR from shixiongfei/nio4c :: nio4c_socket (nio_resolvehost)

; 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.in6_addr = type { %union.anon.2 }
%union.anon.2 = type { [4 x i32] }
%struct.addrinfo = type { i32, i32, i32, i32, i32, ptr, ptr, ptr }
%struct.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.sockaddr_in6 = type { i16, i16, i32, %struct.in6_addr, i32 }
%struct.niosockaddr_s = type { %struct.sockaddr_storage }
%struct.sockaddr_storage = type { i16, [118 x i8], i64 }

@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@in6addr_any = external constant %struct.in6_addr, align 4

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 i32 @nio_resolvehost(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i16 noundef zeroext %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i16, align 2
  %11 = alloca i32, align 4
  %12 = alloca %struct.addrinfo, align 8
  %13 = alloca ptr, align 8
  %14 = alloca [8 x i8], align 1
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca %struct.sockaddr_in, align 4
  %19 = alloca %struct.sockaddr_in6, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i16 %4, ptr %10, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 0, ptr %11, align 4, !tbaa !9
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %99

22:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 48, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  call void @llvm.memset.p0.i64(ptr align 1 %14, i8 0, i64 8, i1 false)
  call void @llvm.memset.p0.i64(ptr align 8 %12, i8 0, i64 48, i1 false)
  %23 = getelementptr inbounds %struct.addrinfo, ptr %12, i32 0, i32 1
  store i32 0, ptr %23, align 4, !tbaa !13
  %24 = getelementptr inbounds %struct.addrinfo, ptr %12, i32 0, i32 2
  store i32 2, ptr %24, align 8, !tbaa !15
  %25 = getelementptr inbounds %struct.addrinfo, ptr %12, i32 0, i32 0
  store i32 1, ptr %25, align 8, !tbaa !16
  %26 = getelementptr inbounds [8 x i8], ptr %14, i64 0, i64 0
  %27 = load i16, ptr %10, align 2, !tbaa !11
  %28 = zext i16 %27 to i32
  %29 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %26, ptr noundef @.str.1, i32 noundef %28) #7
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds [8 x i8], ptr %14, i64 0, i64 0
  %32 = call i32 @getaddrinfo(ptr noundef %30, ptr noundef %31, ptr noundef %12, ptr noundef %13)
  %33 = icmp eq i32 0, %32
  br i1 %33, label %34, label %98

34:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %35, ptr %15, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %92, %34
  %37 = load ptr, ptr %15, align 8, !tbaa !5
  %38 = icmp ne ptr null, %37
  br i1 %38, label %39, label %43

39:                                               ; preds = %36
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = icmp slt i32 %40, %41
  br label %43

43:                                               ; preds = %39, %36
  %44 = phi i1 [ false, %36 ], [ %42, %39 ]
  br i1 %44, label %45, label %96

45:                                               ; preds = %43
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = icmp eq i32 2, %46
  br i1 %47, label %48, label %68

48:                                               ; preds = %45
  %49 = load ptr, ptr %15, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.addrinfo, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 4, !tbaa !13
  %52 = icmp eq i32 2, %51
  br i1 %52, label %53, label %68

53:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %54 = load ptr, ptr %15, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.addrinfo, ptr %54, i32 0, i32 5
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  store ptr %56, ptr %16, align 8, !tbaa !5
  %57 = load i16, ptr %10, align 2, !tbaa !11
  %58 = call zeroext i16 @__bswap_16(i16 noundef zeroext %57)
  %59 = load ptr, ptr %16, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.sockaddr_in, ptr %59, i32 0, i32 1
  store i16 %58, ptr %60, align 2, !tbaa !18
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = load i32, ptr %11, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %11, align 4, !tbaa !9
  %64 = sext i32 %62 to i64
  %65 = getelementptr inbounds %struct.niosockaddr_s, ptr %61, i64 %64
  %66 = getelementptr inbounds %struct.niosockaddr_s, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %16, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %66, ptr align 4 %67, i64 16, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %68

68:                                               ; preds = %53, %48, %45
  %69 = load i32, ptr %8, align 4, !tbaa !9
  %70 = icmp eq i32 10, %69
  br i1 %70, label %71, label %91

71:                                               ; preds = %68
  %72 = load ptr, ptr %15, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.addrinfo, ptr %72, i32 0, i32 1
  %74 = load i32, ptr %73, align 4, !tbaa !13
  %75 = icmp eq i32 10, %74
  br i1 %75, label %76, label %91

76:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %77 = load ptr, ptr %15, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.addrinfo, ptr %77, i32 0, i32 5
  %79 = load ptr, ptr %78, align 8, !tbaa !17
  store ptr %79, ptr %17, align 8, !tbaa !5
  %80 = load i16, ptr %10, align 2, !tbaa !11
  %81 = call zeroext i16 @__bswap_16(i16 noundef zeroext %80)
  %82 = load ptr, ptr %17, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.sockaddr_in6, ptr %82, i32 0, i32 1
  store i16 %81, ptr %83, align 2, !tbaa !21
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = load i32, ptr %11, align 4, !tbaa !9
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %11, align 4, !tbaa !9
  %87 = sext i32 %85 to i64
  %88 = getelementptr inbounds %struct.niosockaddr_s, ptr %84, i64 %87
  %89 = getelementptr inbounds %struct.niosockaddr_s, ptr %88, i32 0, i32 0
  %90 = load ptr, ptr %17, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %89, ptr align 4 %90, i64 28, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  br label %91

91:                                               ; preds = %76, %71, %68
  br label %92

92:                                               ; preds = %91
  %93 = load ptr, ptr %15, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.addrinfo, ptr %93, i32 0, i32 7
  %95 = load ptr, ptr %94, align 8, !tbaa !24
  store ptr %95, ptr %15, align 8, !tbaa !5
  br label %36, !llvm.loop !25

96:                                               ; preds = %43
  %97 = load ptr, ptr %13, align 8, !tbaa !5
  call void @freeaddrinfo(ptr noundef %97) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %98

98:                                               ; preds = %96, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr %12) #7
  br label %132

99:                                               ; preds = %5
  %100 = load i32, ptr %8, align 4, !tbaa !9
  %101 = icmp eq i32 2, %100
  br i1 %101, label %102, label %116

102:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 16, ptr %18) #7
  call void @llvm.memset.p0.i64(ptr align 4 %18, i8 0, i64 16, i1 false)
  %103 = getelementptr inbounds %struct.sockaddr_in, ptr %18, i32 0, i32 0
  store i16 2, ptr %103, align 4, !tbaa !27
  %104 = load i16, ptr %10, align 2, !tbaa !11
  %105 = call zeroext i16 @__bswap_16(i16 noundef zeroext %104)
  %106 = getelementptr inbounds %struct.sockaddr_in, ptr %18, i32 0, i32 1
  store i16 %105, ptr %106, align 2, !tbaa !18
  %107 = call i32 @__bswap_32(i32 noundef 0)
  %108 = getelementptr inbounds %struct.sockaddr_in, ptr %18, i32 0, i32 2
  %109 = getelementptr inbounds %struct.in_addr, ptr %108, i32 0, i32 0
  store i32 %107, ptr %109, align 4, !tbaa !28
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = load i32, ptr %11, align 4, !tbaa !9
  %112 = add nsw i32 %111, 1
  store i32 %112, ptr %11, align 4, !tbaa !9
  %113 = sext i32 %111 to i64
  %114 = getelementptr inbounds %struct.niosockaddr_s, ptr %110, i64 %113
  %115 = getelementptr inbounds %struct.niosockaddr_s, ptr %114, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %115, ptr align 4 %18, i64 16, i1 false)
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #7
  br label %116

116:                                              ; preds = %102, %99
  %117 = load i32, ptr %8, align 4, !tbaa !9
  %118 = icmp eq i32 10, %117
  br i1 %118, label %119, label %131

119:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 28, ptr %19) #7
  call void @llvm.memset.p0.i64(ptr align 4 %19, i8 0, i64 28, i1 false)
  %120 = getelementptr inbounds %struct.sockaddr_in6, ptr %19, i32 0, i32 0
  store i16 10, ptr %120, align 4, !tbaa !29
  %121 = load i16, ptr %10, align 2, !tbaa !11
  %122 = call zeroext i16 @__bswap_16(i16 noundef zeroext %121)
  %123 = getelementptr inbounds %struct.sockaddr_in6, ptr %19, i32 0, i32 1
  store i16 %122, ptr %123, align 2, !tbaa !21
  %124 = getelementptr inbounds %struct.sockaddr_in6, ptr %19, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %124, ptr align 4 @in6addr_any, i64 16, i1 false), !tbaa.struct !30
  %125 = load ptr, ptr %6, align 8, !tbaa !5
  %126 = load i32, ptr %11, align 4, !tbaa !9
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %11, align 4, !tbaa !9
  %128 = sext i32 %126 to i64
  %129 = getelementptr inbounds %struct.niosockaddr_s, ptr %125, i64 %128
  %130 = getelementptr inbounds %struct.niosockaddr_s, ptr %129, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %130, ptr align 4 %19, i64 28, i1 false)
  call void @llvm.lifetime.end.p0(i64 28, ptr %19) #7
  br label %131

131:                                              ; preds = %119, %116
  br label %132

132:                                              ; preds = %131, %98
  %133 = load i32, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  ret i32 %133
}

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

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #4

declare i32 @getaddrinfo(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #5

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

; Function Attrs: nounwind
declare void @freeaddrinfo(ptr noundef) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { inlinehint 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 #7 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!14, !10, i64 4}
!14 = !{!"addrinfo", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!15 = !{!14, !10, i64 8}
!16 = !{!14, !10, i64 0}
!17 = !{!14, !6, i64 24}
!18 = !{!19, !12, i64 2}
!19 = !{!"sockaddr_in", !12, i64 0, !12, i64 2, !20, i64 4, !7, i64 8}
!20 = !{!"in_addr", !10, i64 0}
!21 = !{!22, !12, i64 2}
!22 = !{!"sockaddr_in6", !12, i64 0, !12, i64 2, !10, i64 4, !23, i64 8, !10, i64 24}
!23 = !{!"in6_addr", !7, i64 0}
!24 = !{!14, !6, i64 40}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!19, !12, i64 0}
!28 = !{!19, !10, i64 4}
!29 = !{!22, !12, i64 0}
!30 = !{i64 0, i64 16, !31}
!31 = !{!7, !7, i64 0}


; 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.in6_addr = type { %union.anon.2 }
%union.anon.2 = type { [4 x i32] }
%struct.addrinfo = type { i32, i32, i32, i32, i32, ptr, ptr, ptr }
%struct.niosockaddr_s = type { %struct.sockaddr_storage }
%struct.sockaddr_storage = type { i16, [118 x i8], i64 }

@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@in6addr_any = external local_unnamed_addr constant %struct.in6_addr, align 4

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 i32 @nio_resolvehost(ptr nocapture noundef writeonly %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i16 noundef zeroext %4) local_unnamed_addr #2 {
  %6 = alloca %struct.addrinfo, align 8
  %7 = alloca ptr, align 8
  %8 = alloca [8 x i8], align 8
  %.sroa.6.sroa.5 = alloca [3 x i32], align 8
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %50, label %9

9:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %6) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #8
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #8
  store i64 0, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr %6, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %6, i8 0, i64 48, i1 false)
  store i32 2, ptr %10, align 8, !tbaa !9
  store i32 1, ptr %6, align 8, !tbaa !12
  %11 = zext i16 %4 to i32
  %12 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %11) #8
  %13 = call i32 @getaddrinfo(ptr noundef nonnull %3, ptr noundef nonnull %8, ptr noundef nonnull %6, ptr noundef nonnull %7) #8
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %.preheader, label %49

.preheader:                                       ; preds = %9
  %.03540 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp ne ptr %.03540, null
  %16 = icmp sgt i32 %1, 0
  %17 = and i1 %15, %16
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  switch i32 %2, label %._crit_edge [
    i32 2, label %.lr.ph.split.us
    i32 10, label %.lr.ph.split.us43
  ]

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.thread.us
  %.03542.us = phi ptr [ %.035.us, %.thread.us ], [ %.03540, %.lr.ph ]
  %.041.us = phi i32 [ %.2.us, %.thread.us ], [ 0, %.lr.ph ]
  %18 = getelementptr inbounds i8, ptr %.03542.us, i64 4
  %19 = load i32, ptr %18, align 4, !tbaa !13
  %20 = icmp eq i32 %19, 2
  br i1 %20, label %21, label %.thread.us

21:                                               ; preds = %.lr.ph.split.us
  %22 = getelementptr inbounds i8, ptr %.03542.us, i64 24
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = call zeroext i16 @__bswap_16(i16 noundef zeroext %4)
  %25 = getelementptr inbounds i8, ptr %23, i64 2
  store i16 %24, ptr %25, align 2, !tbaa !15
  %26 = add nsw i32 %.041.us, 1
  %27 = sext i32 %.041.us to i64
  %28 = getelementptr inbounds %struct.niosockaddr_s, ptr %0, i64 %27
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %28, ptr noundef nonnull align 4 dereferenceable(16) %23, i64 16, i1 false)
  br label %.thread.us

.thread.us:                                       ; preds = %21, %.lr.ph.split.us
  %.2.us = phi i32 [ %.041.us, %.lr.ph.split.us ], [ %26, %21 ]
  %29 = getelementptr inbounds i8, ptr %.03542.us, i64 40
  %.035.us = load ptr, ptr %29, align 8, !tbaa !5
  %30 = icmp ne ptr %.035.us, null
  %31 = icmp slt i32 %.2.us, %1
  %32 = select i1 %30, i1 %31, i1 false
  br i1 %32, label %.lr.ph.split.us, label %._crit_edge, !llvm.loop !19

.lr.ph.split.us43:                                ; preds = %.lr.ph, %.thread.us46
  %.03542.us44 = phi ptr [ %.035.us48, %.thread.us46 ], [ %.03540, %.lr.ph ]
  %.041.us45 = phi i32 [ %.2.us47, %.thread.us46 ], [ 0, %.lr.ph ]
  %33 = getelementptr inbounds i8, ptr %.03542.us44, i64 4
  %34 = load i32, ptr %33, align 4, !tbaa !13
  %35 = icmp eq i32 %34, 10
  br i1 %35, label %36, label %.thread.us46

36:                                               ; preds = %.lr.ph.split.us43
  %37 = getelementptr inbounds i8, ptr %.03542.us44, i64 24
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  %39 = call zeroext i16 @__bswap_16(i16 noundef zeroext %4)
  %40 = getelementptr inbounds i8, ptr %38, i64 2
  store i16 %39, ptr %40, align 2, !tbaa !21
  %41 = add nsw i32 %.041.us45, 1
  %42 = sext i32 %.041.us45 to i64
  %43 = getelementptr inbounds %struct.niosockaddr_s, ptr %0, i64 %42
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(28) %43, ptr noundef nonnull align 4 dereferenceable(28) %38, i64 28, i1 false)
  br label %.thread.us46

.thread.us46:                                     ; preds = %36, %.lr.ph.split.us43
  %.2.us47 = phi i32 [ %41, %36 ], [ %.041.us45, %.lr.ph.split.us43 ]
  %44 = getelementptr inbounds i8, ptr %.03542.us44, i64 40
  %.035.us48 = load ptr, ptr %44, align 8, !tbaa !5
  %45 = icmp ne ptr %.035.us48, null
  %46 = icmp slt i32 %.2.us47, %1
  %47 = select i1 %45, i1 %46, i1 false
  br i1 %47, label %.lr.ph.split.us43, label %._crit_edge, !llvm.loop !19

._crit_edge:                                      ; preds = %.thread.us46, %.thread.us, %.lr.ph, %.preheader
  %.0.lcssa = phi i32 [ 0, %.preheader ], [ 0, %.lr.ph ], [ %.2.us, %.thread.us ], [ %.2.us47, %.thread.us46 ]
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  call void @freeaddrinfo(ptr noundef %48) #8
  br label %49

49:                                               ; preds = %._crit_edge, %9
  %.3 = phi i32 [ %.0.lcssa, %._crit_edge ], [ 0, %9 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %6) #8
  br label %55

50:                                               ; preds = %5
  switch i32 %2, label %55 [
    i32 2, label %.thread38
    i32 10, label %53
  ]

.thread38:                                        ; preds = %50
  %51 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext %4)
  %52 = tail call i32 @__bswap_32(i32 noundef 0)
  store i16 2, ptr %0, align 8
  %.sroa.52.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 2
  store i16 %51, ptr %.sroa.52.0..sroa_idx, align 2
  %.sroa.63.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %52, ptr %.sroa.63.0..sroa_idx, align 4
  %.sroa.74.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  store i64 0, ptr %.sroa.74.0..sroa_idx, align 8
  br label %55

53:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %.sroa.6.sroa.5)
  %54 = tail call zeroext i16 @__bswap_16(i16 noundef zeroext %4)
  %.sroa.6.sroa.0.4.copyload = load i32, ptr @in6addr_any, align 4
  %.sroa.6.sroa.0.4.insert.ext = zext i32 %.sroa.6.sroa.0.4.copyload to i64
  %.sroa.6.sroa.0.4.insert.shift = shl nuw i64 %.sroa.6.sroa.0.4.insert.ext, 32
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(12) %.sroa.6.sroa.5, ptr noundef nonnull align 4 dereferenceable(12) getelementptr inbounds (i8, ptr @in6addr_any, i64 4), i64 12, i1 false), !tbaa.struct !24
  store i16 10, ptr %0, align 8
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 2
  store i16 %54, ptr %.sroa.5.0..sroa_idx, align 2
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 4
  store i64 %.sroa.6.sroa.0.4.insert.shift, ptr %.sroa.6.0..sroa_idx, align 4
  %.sroa.6.sroa.5.0..sroa.6.0..sroa_idx.sroa_idx = getelementptr inbounds i8, ptr %0, i64 12
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %.sroa.6.sroa.5.0..sroa.6.0..sroa_idx.sroa_idx, ptr noundef nonnull align 8 dereferenceable(12) %.sroa.6.sroa.5, i64 12, i1 false)
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 24
  store i32 0, ptr %.sroa.7.0..sroa_idx, align 8
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %.sroa.6.sroa.5)
  br label %55

55:                                               ; preds = %50, %.thread38, %53, %49
  %.5 = phi i32 [ %.3, %49 ], [ 1, %53 ], [ 1, %.thread38 ], [ 0, %50 ]
  ret i32 %.5
}

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

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

declare i32 @getaddrinfo(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

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

; Function Attrs: nounwind
declare void @freeaddrinfo(ptr noundef) local_unnamed_addr #7

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { inlinehint 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 #7 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #8 = { 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 8}
!10 = !{!"addrinfo", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!10, !11, i64 4}
!14 = !{!10, !6, i64 24}
!15 = !{!16, !17, i64 2}
!16 = !{!"sockaddr_in", !17, i64 0, !17, i64 2, !18, i64 4, !7, i64 8}
!17 = !{!"short", !7, i64 0}
!18 = !{!"in_addr", !11, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!22, !17, i64 2}
!22 = !{!"sockaddr_in6", !17, i64 0, !17, i64 2, !11, i64 4, !23, i64 8, !11, i64 24}
!23 = !{!"in6_addr", !7, i64 0}
!24 = !{i64 0, i64 12, !25}
!25 = !{!7, !7, i64 0}


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