; LLVM IR from microsoft/ntttcp-for-linux :: src (ntttcp)

; 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.ntttcp_test_endpoint = type { i32, ptr, i32, i32, %struct.timeval, %struct.timeval, i32, i32, i8, ptr, ptr, ptr, i8, ptr, i32, [8 x i32] }
%struct.timeval = type { i64, i64 }
%struct.ntttcp_stream_client = type { ptr, i32, i32, ptr, i32, i32, i32, i64, i64, i64, i8, i8, i8, i8, i8, i32, i32, i64 }
%struct.ntttcp_stream_server = type { ptr, i32, i32, ptr, i32, i64, i8, i8, i8, i8, i8, i32, i32, %struct.fd_set, %struct.fd_set, i32, i64 }
%struct.fd_set = type { [16 x i64] }

; 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
define dso_local void @set_ntttcp_test_endpoint_test_continuous(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.ntttcp_test_endpoint, ptr %4, i32 0, i32 0
  %6 = load i32, ptr %5, align 8, !tbaa !9
  %7 = icmp eq i32 %6, 1
  br i1 %7, label %8, label %28

8:                                                ; preds = %1
  store i32 0, ptr %3, align 4, !tbaa !15
  br label %9

9:                                                ; preds = %24, %8
  %10 = load i32, ptr %3, align 4, !tbaa !15
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.ntttcp_test_endpoint, ptr %11, i32 0, i32 7
  %13 = load i32, ptr %12, align 4, !tbaa !16
  %14 = icmp ult i32 %10, %13
  br i1 %14, label %15, label %27

15:                                               ; preds = %9
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ntttcp_test_endpoint, ptr %16, i32 0, i32 9
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %19 = load i32, ptr %3, align 4, !tbaa !15
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds ptr, ptr %18, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ntttcp_stream_client, ptr %22, i32 0, i32 13
  store i8 1, ptr %23, align 1, !tbaa !18
  br label %24

24:                                               ; preds = %15
  %25 = load i32, ptr %3, align 4, !tbaa !15
  %26 = add i32 %25, 1
  store i32 %26, ptr %3, align 4, !tbaa !15
  br label %9, !llvm.loop !20

27:                                               ; preds = %9
  br label %48

28:                                               ; preds = %1
  store i32 0, ptr %3, align 4, !tbaa !15
  br label %29

29:                                               ; preds = %44, %28
  %30 = load i32, ptr %3, align 4, !tbaa !15
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ntttcp_test_endpoint, ptr %31, i32 0, i32 7
  %33 = load i32, ptr %32, align 4, !tbaa !16
  %34 = icmp ult i32 %30, %33
  br i1 %34, label %35, label %47

35:                                               ; preds = %29
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ntttcp_test_endpoint, ptr %36, i32 0, i32 10
  %38 = load ptr, ptr %37, align 8, !tbaa !22
  %39 = load i32, ptr %3, align 4, !tbaa !15
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds ptr, ptr %38, i64 %40
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ntttcp_stream_server, ptr %42, i32 0, i32 8
  store i8 1, ptr %43, align 2, !tbaa !23
  br label %44

44:                                               ; preds = %35
  %45 = load i32, ptr %3, align 4, !tbaa !15
  %46 = add i32 %45, 1
  store i32 %46, ptr %3, align 4, !tbaa !15
  br label %29, !llvm.loop !26

47:                                               ; preds = %29
  br label %48

48:                                               ; preds = %47, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

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 = { 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 = !{!"ntttcp_test_endpoint", !11, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !12, i64 24, !12, i64 40, !11, i64 56, !11, i64 60, !14, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !14, i64 96, !6, i64 104, !11, i64 112, !7, i64 116}
!11 = !{!"int", !7, i64 0}
!12 = !{!"timeval", !13, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !11, i64 60}
!17 = !{!10, !6, i64 72}
!18 = !{!19, !14, i64 67}
!19 = !{!"ntttcp_stream_client", !6, i64 0, !11, i64 8, !11, i64 12, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !14, i64 64, !14, i64 65, !14, i64 66, !14, i64 67, !14, i64 68, !11, i64 72, !11, i64 76, !13, i64 80}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!10, !6, i64 80}
!23 = !{!24, !14, i64 42}
!24 = !{!"ntttcp_stream_server", !6, i64 0, !11, i64 8, !11, i64 12, !6, i64 16, !11, i64 24, !13, i64 32, !14, i64 40, !14, i64 41, !14, i64 42, !14, i64 43, !14, i64 44, !11, i64 48, !11, i64 52, !25, i64 56, !25, i64 184, !11, i64 312, !13, i64 320}
!25 = !{!"", !7, i64 0}
!26 = distinct !{!26, !21}


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

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @set_ntttcp_test_endpoint_test_continuous(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i32, ptr %0, align 8, !tbaa !5
  %3 = icmp eq i32 %2, 1
  %4 = getelementptr inbounds i8, ptr %0, i64 60
  %5 = load i32, ptr %4, align 4, !tbaa !14
  %.not15 = icmp eq i32 %5, 0
  br i1 %3, label %.preheader, label %.preheader10

.preheader10:                                     ; preds = %1
  br i1 %.not15, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader10
  %6 = getelementptr inbounds i8, ptr %0, i64 80
  %7 = load ptr, ptr %6, align 8, !tbaa !15
  %wide.trip.count = zext i32 %5 to i64
  %xtraiter = and i64 %wide.trip.count, 7
  %8 = icmp ult i32 %5, 8
  br i1 %8, label %.loopexit.loopexit25.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 4294967288
  br label %37

.preheader:                                       ; preds = %1
  br i1 %.not15, label %.loopexit, label %.lr.ph14

.lr.ph14:                                         ; preds = %.preheader
  %9 = getelementptr inbounds i8, ptr %0, i64 72
  %10 = load ptr, ptr %9, align 8, !tbaa !16
  %wide.trip.count21 = zext i32 %5 to i64
  %xtraiter27 = and i64 %wide.trip.count21, 7
  %11 = icmp ult i32 %5, 8
  br i1 %11, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph14.new

.lr.ph14.new:                                     ; preds = %.lr.ph14
  %unroll_iter30 = and i64 %wide.trip.count21, 4294967288
  br label %12

12:                                               ; preds = %12, %.lr.ph14.new
  %indvars.iv18 = phi i64 [ 0, %.lr.ph14.new ], [ %indvars.iv.next19.7, %12 ]
  %niter31 = phi i64 [ 0, %.lr.ph14.new ], [ %niter31.next.7, %12 ]
  %13 = getelementptr inbounds ptr, ptr %10, i64 %indvars.iv18
  %14 = load ptr, ptr %13, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %14, i64 67
  store i8 1, ptr %15, align 1, !tbaa !18
  %indvars.iv.next19 = or disjoint i64 %indvars.iv18, 1
  %16 = getelementptr inbounds ptr, ptr %10, i64 %indvars.iv.next19
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %17, i64 67
  store i8 1, ptr %18, align 1, !tbaa !18
  %indvars.iv.next19.1 = or disjoint i64 %indvars.iv18, 2
  %19 = getelementptr inbounds ptr, ptr %10, i64 %indvars.iv.next19.1
  %20 = load ptr, ptr %19, align 8, !tbaa !17
  %21 = getelementptr inbounds i8, ptr %20, i64 67
  store i8 1, ptr %21, align 1, !tbaa !18
  %indvars.iv.next19.2 = or disjoint i64 %indvars.iv18, 3
  %22 = getelementptr inbounds ptr, ptr %10, i64 %indvars.iv.next19.2
  %23 = load ptr, ptr %22, align 8, !tbaa !17
  %24 = getelementptr inbounds i8, ptr %23, i64 67
  store i8 1, ptr %24, align 1, !tbaa !18
  %indvars.iv.next19.3 = or disjoint i64 %indvars.iv18, 4
  %25 = getelementptr inbounds ptr, ptr %10, i64 %indvars.iv.next19.3
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = getelementptr inbounds i8, ptr %26, i64 67
  store i8 1, ptr %27, align 1, !tbaa !18
  %indvars.iv.next19.4 = or disjoint i64 %indvars.iv18, 5
  %28 = getelementptr inbounds ptr, ptr %10, i64 %indvars.iv.next19.4
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  %30 = getelementptr inbounds i8, ptr %29, i64 67
  store i8 1, ptr %30, align 1, !tbaa !18
  %indvars.iv.next19.5 = or disjoint i64 %indvars.iv18, 6
  %31 = getelementptr inbounds ptr, ptr %10, i64 %indvars.iv.next19.5
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %33 = getelementptr inbounds i8, ptr %32, i64 67
  store i8 1, ptr %33, align 1, !tbaa !18
  %indvars.iv.next19.6 = or disjoint i64 %indvars.iv18, 7
  %34 = getelementptr inbounds ptr, ptr %10, i64 %indvars.iv.next19.6
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  %36 = getelementptr inbounds i8, ptr %35, i64 67
  store i8 1, ptr %36, align 1, !tbaa !18
  %indvars.iv.next19.7 = add nuw nsw i64 %indvars.iv18, 8
  %niter31.next.7 = add i64 %niter31, 8
  %niter31.ncmp.7 = icmp eq i64 %niter31.next.7, %unroll_iter30
  br i1 %niter31.ncmp.7, label %.loopexit.loopexit.unr-lcssa, label %12, !llvm.loop !20

37:                                               ; preds = %37, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.7, %37 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.7, %37 ]
  %38 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv
  %39 = load ptr, ptr %38, align 8, !tbaa !17
  %40 = getelementptr inbounds i8, ptr %39, i64 42
  store i8 1, ptr %40, align 2, !tbaa !22
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %41 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv.next
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = getelementptr inbounds i8, ptr %42, i64 42
  store i8 1, ptr %43, align 2, !tbaa !22
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %44 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv.next.1
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  %46 = getelementptr inbounds i8, ptr %45, i64 42
  store i8 1, ptr %46, align 2, !tbaa !22
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %47 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv.next.2
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  %49 = getelementptr inbounds i8, ptr %48, i64 42
  store i8 1, ptr %49, align 2, !tbaa !22
  %indvars.iv.next.3 = or disjoint i64 %indvars.iv, 4
  %50 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv.next.3
  %51 = load ptr, ptr %50, align 8, !tbaa !17
  %52 = getelementptr inbounds i8, ptr %51, i64 42
  store i8 1, ptr %52, align 2, !tbaa !22
  %indvars.iv.next.4 = or disjoint i64 %indvars.iv, 5
  %53 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv.next.4
  %54 = load ptr, ptr %53, align 8, !tbaa !17
  %55 = getelementptr inbounds i8, ptr %54, i64 42
  store i8 1, ptr %55, align 2, !tbaa !22
  %indvars.iv.next.5 = or disjoint i64 %indvars.iv, 6
  %56 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv.next.5
  %57 = load ptr, ptr %56, align 8, !tbaa !17
  %58 = getelementptr inbounds i8, ptr %57, i64 42
  store i8 1, ptr %58, align 2, !tbaa !22
  %indvars.iv.next.6 = or disjoint i64 %indvars.iv, 7
  %59 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv.next.6
  %60 = load ptr, ptr %59, align 8, !tbaa !17
  %61 = getelementptr inbounds i8, ptr %60, i64 42
  store i8 1, ptr %61, align 2, !tbaa !22
  %indvars.iv.next.7 = add nuw nsw i64 %indvars.iv, 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %.loopexit.loopexit25.unr-lcssa, label %37, !llvm.loop !25

.loopexit.loopexit.unr-lcssa:                     ; preds = %12, %.lr.ph14
  %indvars.iv18.unr = phi i64 [ 0, %.lr.ph14 ], [ %indvars.iv.next19.7, %12 ]
  %lcmp.mod29.not = icmp eq i64 %xtraiter27, 0
  br i1 %lcmp.mod29.not, label %.loopexit, label %.epil.preheader26

.epil.preheader26:                                ; preds = %.loopexit.loopexit.unr-lcssa, %.epil.preheader26
  %indvars.iv18.epil = phi i64 [ %indvars.iv.next19.epil, %.epil.preheader26 ], [ %indvars.iv18.unr, %.loopexit.loopexit.unr-lcssa ]
  %epil.iter28 = phi i64 [ %epil.iter28.next, %.epil.preheader26 ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  %62 = getelementptr inbounds ptr, ptr %10, i64 %indvars.iv18.epil
  %63 = load ptr, ptr %62, align 8, !tbaa !17
  %64 = getelementptr inbounds i8, ptr %63, i64 67
  store i8 1, ptr %64, align 1, !tbaa !18
  %indvars.iv.next19.epil = add nuw nsw i64 %indvars.iv18.epil, 1
  %epil.iter28.next = add i64 %epil.iter28, 1
  %epil.iter28.cmp.not = icmp eq i64 %epil.iter28.next, %xtraiter27
  br i1 %epil.iter28.cmp.not, label %.loopexit, label %.epil.preheader26, !llvm.loop !26

.loopexit.loopexit25.unr-lcssa:                   ; preds = %37, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.7, %37 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.epil.preheader

.epil.preheader:                                  ; preds = %.loopexit.loopexit25.unr-lcssa, %.epil.preheader
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.epil.preheader ], [ %indvars.iv.unr, %.loopexit.loopexit25.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %.loopexit.loopexit25.unr-lcssa ]
  %65 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv.epil
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  %67 = getelementptr inbounds i8, ptr %66, i64 42
  store i8 1, ptr %67, align 2, !tbaa !22
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.loopexit, label %.epil.preheader, !llvm.loop !28

.loopexit:                                        ; preds = %.loopexit.loopexit25.unr-lcssa, %.epil.preheader, %.loopexit.loopexit.unr-lcssa, %.epil.preheader26, %.preheader10, %.preheader
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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" }

!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 = !{!"ntttcp_test_endpoint", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 20, !11, i64 24, !11, i64 40, !7, i64 56, !7, i64 60, !13, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !13, i64 96, !10, i64 104, !7, i64 112, !8, i64 116}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"timeval", !12, i64 0, !12, i64 8}
!12 = !{!"long", !8, i64 0}
!13 = !{!"_Bool", !8, i64 0}
!14 = !{!6, !7, i64 60}
!15 = !{!6, !10, i64 80}
!16 = !{!6, !10, i64 72}
!17 = !{!10, !10, i64 0}
!18 = !{!19, !13, i64 67}
!19 = !{!"ntttcp_stream_client", !10, i64 0, !7, i64 8, !7, i64 12, !10, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !13, i64 64, !13, i64 65, !13, i64 66, !13, i64 67, !13, i64 68, !7, i64 72, !7, i64 76, !12, i64 80}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!23, !13, i64 42}
!23 = !{!"ntttcp_stream_server", !10, i64 0, !7, i64 8, !7, i64 12, !10, i64 16, !7, i64 24, !12, i64 32, !13, i64 40, !13, i64 41, !13, i64 42, !13, i64 43, !13, i64 44, !7, i64 48, !7, i64 52, !24, i64 56, !24, i64 184, !7, i64 312, !12, i64 320}
!24 = !{!"", !8, i64 0}
!25 = distinct !{!25, !21}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.unroll.disable"}
!28 = distinct !{!28, !27}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass