; LLVM IR from jonhoo/volley :: servers/c-threaded (main)

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

@done = external hidden global i32, align 4
@.str.9 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [34 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: inlinehint nounwind uwtable
declare hidden i32 @__bswap_32(i32 noundef) #1

declare void @perror(ptr noundef) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

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

; Function Attrs: nounwind uwtable
define dso_local ptr @handle_client(ptr noundef %0) #5 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %7, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  br label %8

8:                                                ; preds = %72, %1
  %9 = load i32, ptr @done, align 4, !tbaa !9
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %73

11:                                               ; preds = %8
  br label %12

12:                                               ; preds = %29, %11
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = call i64 @recvfrom(i32 noundef %13, ptr noundef %5, i64 noundef 4, i32 noundef 256, ptr noundef null, ptr noundef null)
  %15 = trunc i64 %14 to i32
  store i32 %15, ptr %3, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %12
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = icmp eq i32 %17, -1
  br i1 %18, label %19, label %29

19:                                               ; preds = %16
  %20 = call ptr @__errno_location() #7
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = icmp eq i32 %21, 11
  br i1 %22, label %27, label %23

23:                                               ; preds = %19
  %24 = call ptr @__errno_location() #7
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = icmp eq i32 %25, 4
  br label %27

27:                                               ; preds = %23, %19
  %28 = phi i1 [ true, %19 ], [ %26, %23 ]
  br label %29

29:                                               ; preds = %27, %16
  %30 = phi i1 [ false, %16 ], [ %28, %27 ]
  br i1 %30, label %12, label %31, !llvm.loop !11

31:                                               ; preds = %29
  %32 = load i32, ptr %3, align 4, !tbaa !9
  %33 = icmp eq i32 %32, -1
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  call void @perror(ptr noundef @.str.9)
  br label %73

35:                                               ; preds = %31
  %36 = load i32, ptr %3, align 4, !tbaa !9
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  br label %73

39:                                               ; preds = %35
  %40 = load i32, ptr %5, align 4, !tbaa !9
  %41 = call i32 @__bswap_32(i32 noundef %40)
  store i32 %41, ptr %5, align 4, !tbaa !9
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %45

44:                                               ; preds = %39
  store i32 1, ptr @done, align 4, !tbaa !9
  br label %73

45:                                               ; preds = %39
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = add i32 %46, 1
  %48 = call i32 @__bswap_32(i32 noundef %47)
  store i32 %48, ptr %5, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %66, %45
  %50 = load i32, ptr %4, align 4, !tbaa !9
  %51 = call i64 @sendto(i32 noundef %50, ptr noundef %5, i64 noundef 4, i32 noundef 0, ptr noundef null, i32 noundef 0)
  %52 = trunc i64 %51 to i32
  store i32 %52, ptr %3, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %49
  %54 = load i32, ptr %3, align 4, !tbaa !9
  %55 = icmp eq i32 %54, -1
  br i1 %55, label %56, label %66

56:                                               ; preds = %53
  %57 = call ptr @__errno_location() #7
  %58 = load i32, ptr %57, align 4, !tbaa !9
  %59 = icmp eq i32 %58, 11
  br i1 %59, label %64, label %60

60:                                               ; preds = %56
  %61 = call ptr @__errno_location() #7
  %62 = load i32, ptr %61, align 4, !tbaa !9
  %63 = icmp eq i32 %62, 4
  br label %64

64:                                               ; preds = %60, %56
  %65 = phi i1 [ true, %56 ], [ %63, %60 ]
  br label %66

66:                                               ; preds = %64, %53
  %67 = phi i1 [ false, %53 ], [ %65, %64 ]
  br i1 %67, label %49, label %68, !llvm.loop !13

68:                                               ; preds = %66
  %69 = load i32, ptr %3, align 4, !tbaa !9
  %70 = icmp eq i32 %69, -1
  br i1 %70, label %71, label %72

71:                                               ; preds = %68
  call void @perror(ptr noundef @.str.10)
  br label %73

72:                                               ; preds = %68
  br label %8, !llvm.loop !14

73:                                               ; preds = %71, %44, %38, %34, %8
  %74 = load i32, ptr %4, align 4, !tbaa !9
  %75 = call i32 @close(i32 noundef %74)
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %76) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  ret ptr null
}

declare i32 @close(i32 noundef) #2

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

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

declare i64 @sendto(i32 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 #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 = { 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 }
attributes #7 = { 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, !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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

@done = external hidden local_unnamed_addr global i32, align 4
@.str.9 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [34 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: inlinehint nounwind uwtable
declare hidden i32 @__bswap_32(i32 noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare void @perror(ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @handle_client(ptr nocapture noundef %0) local_unnamed_addr #5 {
  %2 = alloca i32, align 4
  %3 = load i32, ptr %0, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %4 = load i32, ptr @done, align 4, !tbaa !5
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %.critedge2, label %.loopexit

.critedge19.loopexit:                             ; preds = %.critedge6.backedge, %18
  %6 = load i32, ptr @done, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %.critedge2.backedge, label %.loopexit

.critedge2.backedge:                              ; preds = %.critedge19.loopexit, %10, %10
  br label %.critedge2

.critedge2:                                       ; preds = %1, %.critedge2.backedge
  %8 = call i64 @recvfrom(i32 noundef %3, ptr noundef nonnull %2, i64 noundef 4, i32 noundef 256, ptr noundef null, ptr noundef null) #7
  %9 = trunc i64 %8 to i32
  switch i32 %9, label %13 [
    i32 -1, label %10
    i32 0, label %.loopexit
  ]

10:                                               ; preds = %.critedge2
  %11 = tail call ptr @__errno_location() #8
  %12 = load i32, ptr %11, align 4, !tbaa !5
  switch i32 %12, label %.critedge [
    i32 11, label %.critedge2.backedge
    i32 4, label %.critedge2.backedge
  ]

.critedge:                                        ; preds = %10
  call void @perror(ptr noundef nonnull @.str.9) #9
  br label %.loopexit

13:                                               ; preds = %.critedge2
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = call i32 @__bswap_32(i32 noundef %14)
  store i32 %15, ptr %2, align 4, !tbaa !5
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %13
  store i32 1, ptr @done, align 4, !tbaa !5
  br label %.loopexit

18:                                               ; preds = %13
  %19 = add i32 %15, 1
  %20 = call i32 @__bswap_32(i32 noundef %19)
  store i32 %20, ptr %2, align 4, !tbaa !5
  %21 = call i64 @sendto(i32 noundef %3, ptr noundef nonnull %2, i64 noundef 4, i32 noundef 0, ptr noundef null, i32 noundef 0) #7
  %22 = and i64 %21, 4294967295
  %23 = icmp eq i64 %22, 4294967295
  br i1 %23, label %.lr.ph, label %.critedge19.loopexit

.lr.ph:                                           ; preds = %18
  %24 = tail call ptr @__errno_location() #8
  br label %25

25:                                               ; preds = %.lr.ph, %.critedge6.backedge
  %26 = load i32, ptr %24, align 4, !tbaa !5
  switch i32 %26, label %.critedge4 [
    i32 11, label %.critedge6.backedge
    i32 4, label %.critedge6.backedge
  ]

.critedge6.backedge:                              ; preds = %25, %25
  %27 = call i64 @sendto(i32 noundef %3, ptr noundef nonnull %2, i64 noundef 4, i32 noundef 0, ptr noundef null, i32 noundef 0) #7
  %28 = and i64 %27, 4294967295
  %29 = icmp eq i64 %28, 4294967295
  br i1 %29, label %25, label %.critedge19.loopexit

.critedge4:                                       ; preds = %25
  call void @perror(ptr noundef nonnull @.str.10) #9
  br label %.loopexit

.loopexit:                                        ; preds = %.critedge19.loopexit, %.critedge2, %1, %.critedge4, %17, %.critedge
  %30 = call i32 @close(i32 noundef %3) #7
  call void @free(ptr noundef %0) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  ret ptr null
}

declare i32 @close(i32 noundef) local_unnamed_addr #6

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

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

declare i64 @sendto(i32 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 = { "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) }
attributes #9 = { cold }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass