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

; 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_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] }

@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

; Function Attrs: nounwind
declare i32 @asprintf(ptr noundef, ptr noundef, ...) #1

declare void @PRINT_ERR(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @ntttcp_server_listen(ptr noundef) #3

declare void @PRINT_ERR_FREE(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @ntttcp_server_epoll(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @ntttcp_server_select(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @run_ntttcp_receiver_tcp_stream(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %8, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call i32 @ntttcp_server_listen(ptr noundef %9)
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.ntttcp_stream_server, ptr %11, i32 0, i32 11
  store i32 %10, ptr %12, align 8, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.ntttcp_stream_server, ptr %13, i32 0, i32 11
  %15 = load i32, ptr %14, align 8, !tbaa !9
  %16 = icmp slt i32 %15, 0
  br i1 %16, label %17, label %27

17:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ntttcp_stream_server, ptr %18, i32 0, i32 4
  %20 = load i32, ptr %19, align 8, !tbaa !15
  %21 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %3, ptr noundef @.str.36, i32 noundef %20) #4
  store i32 %21, ptr %5, align 4, !tbaa !16
  %22 = load i32, ptr %5, align 4, !tbaa !16
  %23 = icmp slt i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %17
  call void @PRINT_ERR(ptr noundef @.str.2)
  br label %25

25:                                               ; preds = %24, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  call void @PRINT_ERR_FREE(ptr noundef %26)
  br label %65

27:                                               ; preds = %1
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ntttcp_stream_server, ptr %28, i32 0, i32 10
  %30 = load i8, ptr %29, align 4, !tbaa !17, !range !18, !noundef !19
  %31 = trunc i8 %30 to i1
  %32 = zext i1 %31 to i32
  %33 = icmp eq i32 %32, 1
  br i1 %33, label %34, label %49

34:                                               ; preds = %27
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = call i32 @ntttcp_server_epoll(ptr noundef %35)
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %48

38:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ntttcp_stream_server, ptr %39, i32 0, i32 4
  %41 = load i32, ptr %40, align 8, !tbaa !15
  %42 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %3, ptr noundef @.str.37, i32 noundef %41) #4
  store i32 %42, ptr %6, align 4, !tbaa !16
  %43 = load i32, ptr %6, align 4, !tbaa !16
  %44 = icmp slt i32 %43, 0
  br i1 %44, label %45, label %46

45:                                               ; preds = %38
  call void @PRINT_ERR(ptr noundef @.str.2)
  br label %46

46:                                               ; preds = %45, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  call void @PRINT_ERR_FREE(ptr noundef %47)
  br label %48

48:                                               ; preds = %46, %34
  br label %64

49:                                               ; preds = %27
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = call i32 @ntttcp_server_select(ptr noundef %50)
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %63

53:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ntttcp_stream_server, ptr %54, i32 0, i32 4
  %56 = load i32, ptr %55, align 8, !tbaa !15
  %57 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %3, ptr noundef @.str.38, i32 noundef %56) #4
  store i32 %57, ptr %7, align 4, !tbaa !16
  %58 = load i32, ptr %7, align 4, !tbaa !16
  %59 = icmp slt i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %53
  call void @PRINT_ERR(ptr noundef @.str.2)
  br label %61

61:                                               ; preds = %60, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  call void @PRINT_ERR_FREE(ptr noundef %62)
  br label %63

63:                                               ; preds = %61, %49
  br label %64

64:                                               ; preds = %63, %48
  br label %65

65:                                               ; preds = %64, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret ptr null
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 #4 = { 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 48}
!10 = !{!"ntttcp_stream_server", !6, i64 0, !11, i64 8, !11, i64 12, !6, i64 16, !11, i64 24, !12, i64 32, !13, i64 40, !13, i64 41, !13, i64 42, !13, i64 43, !13, i64 44, !11, i64 48, !11, i64 52, !14, i64 56, !14, i64 184, !11, i64 312, !12, i64 320}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"", !7, i64 0}
!15 = !{!10, !11, i64 24}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !13, i64 44}
!18 = !{i8 0, i8 2}
!19 = !{}


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

@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

; Function Attrs: nounwind
declare i32 @asprintf(ptr noundef, ptr noundef, ...) local_unnamed_addr #1

declare void @PRINT_ERR(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @ntttcp_server_listen(ptr noundef) local_unnamed_addr #3

declare void @PRINT_ERR_FREE(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @ntttcp_server_epoll(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @ntttcp_server_select(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @run_ntttcp_receiver_tcp_stream(ptr noundef %0) local_unnamed_addr #3 {
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  store ptr null, ptr %2, align 8, !tbaa !5
  %3 = tail call i32 @ntttcp_server_listen(ptr noundef %0)
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 %3, ptr %4, align 8, !tbaa !9
  %5 = icmp slt i32 %3, 0
  br i1 %5, label %6, label %11

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load i32, ptr %7, align 8, !tbaa !15
  %9 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %2, ptr noundef nonnull @.str.36, i32 noundef %8) #4
  %10 = icmp slt i32 %9, 0
  br i1 %10, label %.sink.split.sink.split, label %.sink.split

11:                                               ; preds = %1
  %12 = getelementptr inbounds i8, ptr %0, i64 44
  %13 = load i8, ptr %12, align 4, !tbaa !16, !range !17, !noundef !18
  %14 = trunc nuw i8 %13 to i1
  br i1 %14, label %15, label %22

15:                                               ; preds = %11
  %16 = tail call i32 @ntttcp_server_epoll(ptr noundef nonnull %0)
  %.not12 = icmp eq i32 %16, 0
  br i1 %.not12, label %29, label %17

17:                                               ; preds = %15
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  %19 = load i32, ptr %18, align 8, !tbaa !15
  %20 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %2, ptr noundef nonnull @.str.37, i32 noundef %19) #4
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %.sink.split.sink.split, label %.sink.split

22:                                               ; preds = %11
  %23 = tail call i32 @ntttcp_server_select(ptr noundef nonnull %0)
  %.not = icmp eq i32 %23, 0
  br i1 %.not, label %29, label %24

24:                                               ; preds = %22
  %25 = getelementptr inbounds i8, ptr %0, i64 24
  %26 = load i32, ptr %25, align 8, !tbaa !15
  %27 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %2, ptr noundef nonnull @.str.38, i32 noundef %26) #4
  %28 = icmp slt i32 %27, 0
  br i1 %28, label %.sink.split.sink.split, label %.sink.split

.sink.split.sink.split:                           ; preds = %24, %17, %6
  call void @PRINT_ERR(ptr noundef nonnull @.str.2) #4
  br label %.sink.split

.sink.split:                                      ; preds = %.sink.split.sink.split, %24, %17, %6
  %.sink = load ptr, ptr %2, align 8, !tbaa !5
  call void @PRINT_ERR_FREE(ptr noundef %.sink) #4
  br label %29

29:                                               ; preds = %.sink.split, %15, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret ptr null
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 #4 = { 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 48}
!10 = !{!"ntttcp_stream_server", !6, i64 0, !11, i64 8, !11, i64 12, !6, i64 16, !11, i64 24, !12, i64 32, !13, i64 40, !13, i64 41, !13, i64 42, !13, i64 43, !13, i64 44, !11, i64 48, !11, i64 52, !14, i64 56, !14, i64 184, !11, i64 312, !12, i64 320}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"", !7, i64 0}
!15 = !{!10, !11, i64 24}
!16 = !{!10, !13, i64 44}
!17 = !{i8 0, i8 2}
!18 = !{}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass