; LLVM IR from golems/ach :: src/achd (transport)

; 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.achd_cx = type { %struct.achd_headers, i32, i32, i32, i32, ptr, i32, %struct.ach_channel, ptr }
%struct.achd_headers = type { ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i64, ptr, ptr, i32, i32, ptr }
%struct.ach_channel = type { %union.anon }
%union.anon = type { [16 x i64] }
%struct.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.pollfd = type { i32, i16, i16 }
%struct.achd_conn = type { i32, %struct.timespec, %struct.timespec, %struct.achd_headers, %struct.achd_headers, i32, i32, i32, i64, ptr, ptr, ptr }
%struct.timespec = type { i64, i64 }
%struct.ach_pipe_frame_t = type { [8 x i8], [8 x i8], [1 x i8] }

@cx = external global %struct.achd_cx, align 8
@ach_verbosity = external global i32, align 4
@.str.19 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [35 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: nounwind willreturn memory(none)
declare ptr @__errno_location() #1

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

declare void @ach_log(i32 noundef, ptr noundef, ...) #3

; Function Attrs: nounwind
declare ptr @inet_ntoa(i32) #4

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

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

declare i32 @achd_reconnect(ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #6

declare void @ach_pipe_set_size(ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @put_frame(ptr noundef) #7

; Function Attrs: nounwind uwtable
declare hidden void @udp_peer(ptr noundef, ptr noundef) #7

; Function Attrs: nounwind uwtable
declare hidden i32 @udp_poll(ptr noundef) #7

; Function Attrs: nounwind uwtable
define dso_local void @achd_pull_udp(ptr noundef %0) #7 {
  %2 = alloca ptr, align 8
  %3 = alloca %struct.sockaddr_in, align 4
  %4 = alloca [2 x %struct.pollfd], align 16
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %struct.sockaddr_in, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #8
  call void @llvm.memset.p0.i64(ptr align 4 %3, i8 0, i64 16, i1 false)
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  call void @udp_peer(ptr noundef %10, ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #8
  %11 = getelementptr inbounds %struct.pollfd, ptr %4, i32 0, i32 0
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.achd_conn, ptr %12, i32 0, i32 7
  %14 = load i32, ptr %13, align 8, !tbaa !9
  store i32 %14, ptr %11, align 8, !tbaa !15
  %15 = getelementptr inbounds %struct.pollfd, ptr %4, i32 0, i32 1
  store i16 1, ptr %15, align 4, !tbaa !18
  %16 = getelementptr inbounds %struct.pollfd, ptr %4, i32 0, i32 2
  store i16 0, ptr %16, align 2, !tbaa !19
  %17 = getelementptr inbounds %struct.pollfd, ptr %4, i64 1
  %18 = getelementptr inbounds %struct.pollfd, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.achd_conn, ptr %19, i32 0, i32 5
  %21 = load i32, ptr %20, align 8, !tbaa !20
  store i32 %21, ptr %18, align 8, !tbaa !15
  %22 = getelementptr inbounds %struct.pollfd, ptr %17, i32 0, i32 1
  store i16 1, ptr %22, align 4, !tbaa !18
  %23 = getelementptr inbounds %struct.pollfd, ptr %17, i32 0, i32 2
  store i16 0, ptr %23, align 2, !tbaa !19
  br label %24

24:                                               ; preds = %169, %167, %1
  %25 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 6), align 8, !tbaa !21
  %26 = icmp ne i32 %25, 0
  %27 = xor i1 %26, true
  br i1 %27, label %28, label %170

28:                                               ; preds = %24
  %29 = getelementptr inbounds [2 x %struct.pollfd], ptr %4, i64 0, i64 0
  %30 = getelementptr inbounds %struct.pollfd, ptr %29, i32 0, i32 2
  store i16 0, ptr %30, align 2, !tbaa !19
  br label %31

31:                                               ; preds = %80, %28
  %32 = getelementptr inbounds [2 x %struct.pollfd], ptr %4, i64 0, i64 0
  %33 = getelementptr inbounds %struct.pollfd, ptr %32, i32 0, i32 2
  %34 = load i16, ptr %33, align 2, !tbaa !19
  %35 = sext i16 %34 to i32
  %36 = and i32 %35, 1
  %37 = icmp ne i32 %36, 0
  %38 = xor i1 %37, true
  br i1 %38, label %39, label %81

39:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  %40 = getelementptr inbounds [2 x %struct.pollfd], ptr %4, i64 0, i64 0
  %41 = call i32 @udp_poll(ptr noundef %40)
  store i32 %41, ptr %5, align 4, !tbaa !24
  %42 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 6), align 8, !tbaa !21
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %50

44:                                               ; preds = %39
  %45 = load i32, ptr @ach_verbosity, align 4, !tbaa !24
  %46 = add nsw i32 5, %45
  %47 = icmp sle i32 7, %46
  br i1 %47, label %48, label %49

48:                                               ; preds = %44
  call void (i32, ptr, ...) @ach_log(i32 noundef 7, ptr noundef @.str.19)
  br label %49

49:                                               ; preds = %48, %44
  store i32 1, ptr %6, align 4
  br label %78

50:                                               ; preds = %39
  %51 = load i32, ptr %5, align 4, !tbaa !24
  %52 = icmp slt i32 %51, 0
  br i1 %52, label %53, label %62

53:                                               ; preds = %50
  %54 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 3), align 8, !tbaa !25
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %60

56:                                               ; preds = %53
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = call i32 @achd_reconnect(ptr noundef %57)
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  call void @udp_peer(ptr noundef %59, ptr noundef %3)
  br label %61

60:                                               ; preds = %53
  store i32 1, ptr %6, align 4
  br label %78

61:                                               ; preds = %56
  br label %76

62:                                               ; preds = %50
  %63 = getelementptr inbounds [2 x %struct.pollfd], ptr %4, i64 0, i64 0
  %64 = getelementptr inbounds %struct.pollfd, ptr %63, i32 0, i32 2
  %65 = load i16, ptr %64, align 2, !tbaa !19
  %66 = sext i16 %65 to i32
  %67 = and i32 %66, 1
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %75, label %69

69:                                               ; preds = %62
  %70 = load i32, ptr @ach_verbosity, align 4, !tbaa !24
  %71 = add nsw i32 5, %70
  %72 = icmp sle i32 3, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %69
  call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef @.str.20)
  br label %74

74:                                               ; preds = %73, %69
  br label %75

75:                                               ; preds = %74, %62
  br label %76

76:                                               ; preds = %75, %61
  br label %77

77:                                               ; preds = %76
  store i32 0, ptr %6, align 4
  br label %78

78:                                               ; preds = %77, %60, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  %79 = load i32, ptr %6, align 4
  switch i32 %79, label %171 [
    i32 0, label %80
  ]

80:                                               ; preds = %78
  br label %31, !llvm.loop !26

81:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #8
  call void @llvm.memset.p0.i64(ptr align 4 %7, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  store i32 16, ptr %8, align 4, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  store i64 -1, ptr %9, align 8, !tbaa !28
  br label %82

82:                                               ; preds = %106, %81
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.achd_conn, ptr %83, i32 0, i32 7
  %85 = load i32, ptr %84, align 8, !tbaa !9
  %86 = load ptr, ptr %2, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.achd_conn, ptr %86, i32 0, i32 9
  %88 = load ptr, ptr %87, align 8, !tbaa !29
  %89 = getelementptr inbounds %struct.ach_pipe_frame_t, ptr %88, i32 0, i32 2
  %90 = getelementptr inbounds [1 x i8], ptr %89, i64 0, i64 0
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.achd_conn, ptr %91, i32 0, i32 8
  %93 = load i64, ptr %92, align 8, !tbaa !30
  %94 = call i64 @recvfrom(i32 noundef %85, ptr noundef %90, i64 noundef %93, i32 noundef 0, ptr noundef %7, ptr noundef %8)
  store i64 %94, ptr %9, align 8, !tbaa !28
  br label %95

95:                                               ; preds = %82
  %96 = load i64, ptr %9, align 8, !tbaa !28
  %97 = icmp slt i64 %96, 0
  br i1 %97, label %98, label %106

98:                                               ; preds = %95
  %99 = call ptr @__errno_location() #9
  %100 = load i32, ptr %99, align 4, !tbaa !24
  %101 = icmp eq i32 4, %100
  br i1 %101, label %102, label %106

102:                                              ; preds = %98
  %103 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 6), align 8, !tbaa !21
  %104 = icmp ne i32 %103, 0
  %105 = xor i1 %104, true
  br label %106

106:                                              ; preds = %102, %98, %95
  %107 = phi i1 [ false, %98 ], [ false, %95 ], [ %105, %102 ]
  br i1 %107, label %82, label %108, !llvm.loop !31

108:                                              ; preds = %106
  %109 = load i32, ptr getelementptr inbounds (%struct.achd_cx, ptr @cx, i32 0, i32 6), align 8, !tbaa !21
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %111, label %112

111:                                              ; preds = %108
  store i32 3, ptr %6, align 4
  br label %167

112:                                              ; preds = %108
  %113 = getelementptr inbounds %struct.sockaddr_in, ptr %7, i32 0, i32 2
  %114 = getelementptr inbounds %struct.sockaddr_in, ptr %3, i32 0, i32 2
  %115 = call i32 @memcmp(ptr noundef %113, ptr noundef %114, i64 noundef 4) #10
  %116 = icmp ne i32 0, %115
  br i1 %116, label %125, label %117

117:                                              ; preds = %112
  %118 = getelementptr inbounds %struct.sockaddr_in, ptr %7, i32 0, i32 1
  %119 = load i16, ptr %118, align 2, !tbaa !32
  %120 = zext i16 %119 to i32
  %121 = getelementptr inbounds %struct.sockaddr_in, ptr %3, i32 0, i32 1
  %122 = load i16, ptr %121, align 2, !tbaa !32
  %123 = zext i16 %122 to i32
  %124 = icmp ne i32 %120, %123
  br i1 %124, label %125, label %147

125:                                              ; preds = %117, %112
  %126 = load i32, ptr @ach_verbosity, align 4, !tbaa !24
  %127 = add nsw i32 5, %126
  %128 = icmp sle i32 4, %127
  br i1 %128, label %129, label %146

129:                                              ; preds = %125
  %130 = getelementptr inbounds %struct.sockaddr_in, ptr %7, i32 0, i32 2
  %131 = getelementptr inbounds %struct.in_addr, ptr %130, i32 0, i32 0
  %132 = load i32, ptr %131, align 4
  %133 = call ptr @inet_ntoa(i32 %132) #8
  %134 = getelementptr inbounds %struct.sockaddr_in, ptr %7, i32 0, i32 1
  %135 = load i16, ptr %134, align 2, !tbaa !32
  %136 = call zeroext i16 @__bswap_16(i16 noundef zeroext %135)
  %137 = zext i16 %136 to i32
  %138 = getelementptr inbounds %struct.sockaddr_in, ptr %3, i32 0, i32 2
  %139 = getelementptr inbounds %struct.in_addr, ptr %138, i32 0, i32 0
  %140 = load i32, ptr %139, align 4
  %141 = call ptr @inet_ntoa(i32 %140) #8
  %142 = getelementptr inbounds %struct.sockaddr_in, ptr %3, i32 0, i32 1
  %143 = load i16, ptr %142, align 2, !tbaa !32
  %144 = call zeroext i16 @__bswap_16(i16 noundef zeroext %143)
  %145 = zext i16 %144 to i32
  call void (i32, ptr, ...) @ach_log(i32 noundef 4, ptr noundef @.str.21, ptr noundef %133, i32 noundef %137, ptr noundef %141, i32 noundef %145)
  br label %146

146:                                              ; preds = %129, %125
  store i32 2, ptr %6, align 4
  br label %167, !llvm.loop !35

147:                                              ; preds = %117
  %148 = load i32, ptr @ach_verbosity, align 4, !tbaa !24
  %149 = add nsw i32 5, %148
  %150 = icmp sle i32 7, %149
  br i1 %150, label %151, label %161

151:                                              ; preds = %147
  %152 = load i64, ptr %9, align 8, !tbaa !28
  %153 = getelementptr inbounds %struct.sockaddr_in, ptr %7, i32 0, i32 2
  %154 = getelementptr inbounds %struct.in_addr, ptr %153, i32 0, i32 0
  %155 = load i32, ptr %154, align 4
  %156 = call ptr @inet_ntoa(i32 %155) #8
  %157 = getelementptr inbounds %struct.sockaddr_in, ptr %7, i32 0, i32 1
  %158 = load i16, ptr %157, align 2, !tbaa !32
  %159 = call zeroext i16 @__bswap_16(i16 noundef zeroext %158)
  %160 = zext i16 %159 to i32
  call void (i32, ptr, ...) @ach_log(i32 noundef 7, ptr noundef @.str.22, i64 noundef %152, ptr noundef %156, i32 noundef %160)
  br label %161

161:                                              ; preds = %151, %147
  %162 = load ptr, ptr %2, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.achd_conn, ptr %162, i32 0, i32 9
  %164 = load ptr, ptr %163, align 8, !tbaa !29
  %165 = load i64, ptr %9, align 8, !tbaa !28
  call void @ach_pipe_set_size(ptr noundef %164, i64 noundef %165)
  %166 = load ptr, ptr %2, align 8, !tbaa !5
  call void @put_frame(ptr noundef %166)
  store i32 0, ptr %6, align 4
  br label %167

167:                                              ; preds = %161, %146, %111
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #8
  %168 = load i32, ptr %6, align 4
  switch i32 %168, label %174 [
    i32 0, label %169
    i32 3, label %170
    i32 2, label %24
  ]

169:                                              ; preds = %167
  br label %24, !llvm.loop !35

170:                                              ; preds = %167, %24
  store i32 0, ptr %6, align 4
  br label %171

171:                                              ; preds = %170, %78
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #8
  %172 = load i32, ptr %6, align 4
  switch i32 %172, label %174 [
    i32 0, label %173
    i32 1, label %173
  ]

173:                                              ; preds = %171, %171
  ret void

174:                                              ; preds = %171, %167
  unreachable
}

declare i64 @recvfrom(i32 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(none) "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 = { "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 = { 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 = { 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 willreturn memory(read) "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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(none) }
attributes #10 = { nounwind willreturn memory(read) }

!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 224}
!10 = !{!"achd_conn", !11, i64 0, !12, i64 8, !12, i64 24, !14, i64 40, !14, i64 128, !11, i64 216, !11, i64 220, !11, i64 224, !13, i64 232, !6, i64 240, !6, i64 248, !6, i64 256}
!11 = !{!"int", !7, i64 0}
!12 = !{!"timespec", !13, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!"achd_headers", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !13, i64 48, !6, i64 56, !6, i64 64, !11, i64 72, !11, i64 76, !6, i64 80}
!15 = !{!16, !11, i64 0}
!16 = !{!"pollfd", !11, i64 0, !17, i64 4, !17, i64 6}
!17 = !{!"short", !7, i64 0}
!18 = !{!16, !17, i64 4}
!19 = !{!16, !17, i64 6}
!20 = !{!10, !11, i64 216}
!21 = !{!22, !11, i64 112}
!22 = !{!"achd_cx", !14, i64 0, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !6, i64 104, !11, i64 112, !23, i64 120, !6, i64 248}
!23 = !{!"ach_channel", !7, i64 0}
!24 = !{!11, !11, i64 0}
!25 = !{!22, !11, i64 96}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!13, !13, i64 0}
!29 = !{!10, !6, i64 240}
!30 = !{!10, !13, i64 232}
!31 = distinct !{!31, !27}
!32 = !{!33, !17, i64 2}
!33 = !{!"sockaddr_in", !17, i64 0, !17, i64 2, !34, i64 4, !7, i64 8}
!34 = !{!"in_addr", !11, i64 0}
!35 = distinct !{!35, !27}


; 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.achd_cx = type { %struct.achd_headers, i32, i32, i32, i32, ptr, i32, %struct.ach_channel, ptr }
%struct.achd_headers = type { ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i64, ptr, ptr, i32, i32, ptr }
%struct.ach_channel = type { %union.anon }
%union.anon = type { [16 x i64] }
%struct.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.pollfd = type { i32, i16, i16 }

@cx = external local_unnamed_addr global %struct.achd_cx, align 8
@ach_verbosity = external local_unnamed_addr global i32, align 4
@.str.19 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [35 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 nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() 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 @ach_log(i32 noundef, ptr noundef, ...) local_unnamed_addr #3

; Function Attrs: nounwind
declare ptr @inet_ntoa(i32) local_unnamed_addr #4

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

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

declare i32 @achd_reconnect(ptr noundef) local_unnamed_addr #3

declare void @ach_pipe_set_size(ptr noundef, i64 noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare hidden void @udp_peer(ptr noundef, ptr noundef) local_unnamed_addr #6

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

; Function Attrs: nounwind uwtable
define dso_local void @achd_pull_udp(ptr noundef %0) local_unnamed_addr #6 {
  %2 = alloca %struct.sockaddr_in, align 4
  %3 = alloca [2 x %struct.pollfd], align 16
  %4 = alloca %struct.sockaddr_in, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %2, i8 0, i64 16, i1 false)
  call void @udp_peer(ptr noundef %0, ptr noundef nonnull %2)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #7
  %6 = getelementptr inbounds i8, ptr %0, i64 224
  %7 = load i32, ptr %6, align 8, !tbaa !5
  store i32 %7, ptr %3, align 16, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %3, i64 4
  store i16 1, ptr %8, align 4, !tbaa !17
  %9 = getelementptr inbounds i8, ptr %3, i64 6
  %10 = getelementptr inbounds i8, ptr %3, i64 8
  %11 = getelementptr inbounds i8, ptr %0, i64 216
  %12 = load i32, ptr %11, align 8, !tbaa !18
  store i32 %12, ptr %10, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %3, i64 12
  store i16 1, ptr %13, align 4, !tbaa !17
  %14 = getelementptr inbounds i8, ptr %3, i64 14
  store i16 0, ptr %14, align 2, !tbaa !19
  %.old = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 112), align 8, !tbaa !20
  %.not.old = icmp eq i32 %.old, 0
  br i1 %.not.old, label %.preheader, label %.critedge25

.preheader:                                       ; preds = %1
  %15 = getelementptr inbounds i8, ptr %0, i64 240
  %16 = getelementptr inbounds i8, ptr %0, i64 232
  %17 = getelementptr inbounds i8, ptr %4, i64 4
  %18 = getelementptr inbounds i8, ptr %2, i64 4
  %19 = getelementptr inbounds i8, ptr %4, i64 2
  %20 = getelementptr inbounds i8, ptr %2, i64 2
  br label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %82, %.preheader
  store i16 0, ptr %9, align 2, !tbaa !19
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %39
  %21 = call i32 @udp_poll(ptr noundef nonnull %3)
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 112), align 8, !tbaa !20
  %.not20 = icmp eq i32 %22, 0
  br i1 %.not20, label %27, label %23

23:                                               ; preds = %.lr.ph
  %24 = load i32, ptr @ach_verbosity, align 4, !tbaa !23
  %25 = icmp sgt i32 %24, 1
  br i1 %25, label %26, label %.critedge25

26:                                               ; preds = %23
  call void (i32, ptr, ...) @ach_log(i32 noundef 7, ptr noundef nonnull @.str.19) #7
  br label %.critedge25

27:                                               ; preds = %.lr.ph
  %28 = icmp slt i32 %21, 0
  br i1 %28, label %29, label %33

29:                                               ; preds = %27
  %30 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 96), align 8, !tbaa !24
  %.not22 = icmp eq i32 %30, 0
  br i1 %.not22, label %.critedge25, label %31

31:                                               ; preds = %29
  %32 = call i32 @achd_reconnect(ptr noundef %0) #7
  call void @udp_peer(ptr noundef %0, ptr noundef nonnull %2)
  br label %39

33:                                               ; preds = %27
  %34 = load i16, ptr %9, align 2, !tbaa !19
  %35 = and i16 %34, 1
  %.not21 = icmp eq i16 %35, 0
  %36 = load i32, ptr @ach_verbosity, align 4
  %37 = icmp sgt i32 %36, -3
  %or.cond = select i1 %.not21, i1 %37, i1 false
  br i1 %or.cond, label %38, label %39

38:                                               ; preds = %33
  call void (i32, ptr, ...) @ach_log(i32 noundef 3, ptr noundef nonnull @.str.20) #7
  br label %39

39:                                               ; preds = %33, %38, %31
  %40 = load i16, ptr %9, align 2, !tbaa !19
  %41 = and i16 %40, 1
  %.not15 = icmp eq i16 %41, 0
  br i1 %.not15, label %.lr.ph, label %._crit_edge, !llvm.loop !25

._crit_edge:                                      ; preds = %39
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %4, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  store i32 16, ptr %5, align 4, !tbaa !23
  br label %42

42:                                               ; preds = %49, %._crit_edge
  %43 = load i32, ptr %6, align 8, !tbaa !5
  %44 = load ptr, ptr %15, align 8, !tbaa !27
  %45 = getelementptr inbounds i8, ptr %44, i64 16
  %46 = load i64, ptr %16, align 8, !tbaa !28
  %47 = call i64 @recvfrom(i32 noundef %43, ptr noundef nonnull %45, i64 noundef %46, i32 noundef 0, ptr noundef nonnull %4, ptr noundef nonnull %5) #7
  %48 = icmp slt i64 %47, 0
  br i1 %48, label %49, label %.critedgethread-pre-split

49:                                               ; preds = %42
  %50 = tail call ptr @__errno_location() #8
  %51 = load i32, ptr %50, align 4, !tbaa !23
  %52 = icmp eq i32 %51, 4
  %53 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 112), align 8
  %.not16 = icmp eq i32 %53, 0
  %or.cond26 = select i1 %52, i1 %.not16, i1 false
  br i1 %or.cond26, label %42, label %.critedge, !llvm.loop !29

.critedgethread-pre-split:                        ; preds = %42
  %.pr = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 112), align 8, !tbaa !20
  br label %.critedge

.critedge:                                        ; preds = %49, %.critedgethread-pre-split
  %54 = phi i32 [ %.pr, %.critedgethread-pre-split ], [ %53, %49 ]
  %.not17 = icmp eq i32 %54, 0
  br i1 %.not17, label %55, label %.thread

.thread:                                          ; preds = %.critedge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #7
  br label %.critedge25

55:                                               ; preds = %.critedge
  %lhsv = load i32, ptr %17, align 4
  %rhsv = load i32, ptr %18, align 4
  %.not33 = icmp eq i32 %lhsv, %rhsv
  br i1 %.not33, label %56, label %59

56:                                               ; preds = %55
  %57 = load i16, ptr %19, align 2, !tbaa !30
  %58 = load i16, ptr %20, align 2, !tbaa !30
  %.not19 = icmp eq i16 %57, %58
  br i1 %.not19, label %72, label %59

59:                                               ; preds = %56, %55
  %60 = load i32, ptr @ach_verbosity, align 4, !tbaa !23
  %61 = icmp sgt i32 %60, -2
  br i1 %61, label %62, label %82, !llvm.loop !33

62:                                               ; preds = %59
  %63 = call ptr @inet_ntoa(i32 %lhsv) #7
  %64 = load i16, ptr %19, align 2, !tbaa !30
  %65 = call zeroext i16 @__bswap_16(i16 noundef zeroext %64)
  %66 = zext i16 %65 to i32
  %67 = load i32, ptr %18, align 4
  %68 = call ptr @inet_ntoa(i32 %67) #7
  %69 = load i16, ptr %20, align 2, !tbaa !30
  %70 = call zeroext i16 @__bswap_16(i16 noundef zeroext %69)
  %71 = zext i16 %70 to i32
  call void (i32, ptr, ...) @ach_log(i32 noundef 4, ptr noundef nonnull @.str.21, ptr noundef %63, i32 noundef %66, ptr noundef %68, i32 noundef %71) #7
  br label %82, !llvm.loop !33

72:                                               ; preds = %56
  %73 = load i32, ptr @ach_verbosity, align 4, !tbaa !23
  %74 = icmp sgt i32 %73, 1
  br i1 %74, label %75, label %80

75:                                               ; preds = %72
  %76 = call ptr @inet_ntoa(i32 %lhsv) #7
  %77 = load i16, ptr %19, align 2, !tbaa !30
  %78 = call zeroext i16 @__bswap_16(i16 noundef zeroext %77)
  %79 = zext i16 %78 to i32
  call void (i32, ptr, ...) @ach_log(i32 noundef 7, ptr noundef nonnull @.str.22, i64 noundef %47, ptr noundef %76, i32 noundef %79) #7
  br label %80

80:                                               ; preds = %75, %72
  %81 = load ptr, ptr %15, align 8, !tbaa !27
  call void @ach_pipe_set_size(ptr noundef %81, i64 noundef %47) #7
  call void @put_frame(ptr noundef nonnull %0)
  br label %82

82:                                               ; preds = %59, %62, %80
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #7
  %83 = load i32, ptr getelementptr inbounds (i8, ptr @cx, i64 112), align 8
  %.not = icmp eq i32 %83, 0
  br i1 %.not, label %.lr.ph.preheader, label %.critedge25

.critedge25:                                      ; preds = %82, %29, %.thread, %26, %23, %1
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #7
  ret void
}

declare i64 @recvfrom(i32 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { "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 = { 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 = { 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 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 }
attributes #8 = { nounwind willreturn memory(none) }

!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 224}
!6 = !{!"achd_conn", !7, i64 0, !10, i64 8, !10, i64 24, !12, i64 40, !12, i64 128, !7, i64 216, !7, i64 220, !7, i64 224, !11, i64 232, !13, i64 240, !13, i64 248, !13, i64 256}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"timespec", !11, i64 0, !11, i64 8}
!11 = !{!"long", !8, i64 0}
!12 = !{!"achd_headers", !13, i64 0, !13, i64 8, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !11, i64 48, !13, i64 56, !13, i64 64, !7, i64 72, !7, i64 76, !13, i64 80}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!15, !7, i64 0}
!15 = !{!"pollfd", !7, i64 0, !16, i64 4, !16, i64 6}
!16 = !{!"short", !8, i64 0}
!17 = !{!15, !16, i64 4}
!18 = !{!6, !7, i64 216}
!19 = !{!15, !16, i64 6}
!20 = !{!21, !7, i64 112}
!21 = !{!"achd_cx", !12, i64 0, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100, !13, i64 104, !7, i64 112, !22, i64 120, !13, i64 248}
!22 = !{!"ach_channel", !8, i64 0}
!23 = !{!7, !7, i64 0}
!24 = !{!21, !7, i64 96}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!6, !13, i64 240}
!28 = !{!6, !11, i64 232}
!29 = distinct !{!29, !26}
!30 = !{!31, !16, i64 2}
!31 = !{!"sockaddr_in", !16, i64 0, !16, i64 2, !32, i64 4, !8, i64 8}
!32 = !{!"in_addr", !7, i64 0}
!33 = distinct !{!33, !26}


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