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

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

@.str.9 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [51 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

declare void @PRINT_ERR(ptr noundef) #1

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

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

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #1

declare i64 @read(i32 noundef, ptr noundef, i64 noundef) #1

declare void @PRINT_INFO(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @request_to_start(i32 noundef %0, i32 noundef %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %9 = load i32, ptr %5, align 4, !tbaa !5
  %10 = call i32 @__bswap_32(i32 noundef %9)
  store i32 %10, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = call i64 @write(i32 noundef %11, ptr noundef %6, i64 noundef 4)
  %13 = icmp slt i64 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  call void @PRINT_ERR(ptr noundef @.str.9)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %36

15:                                               ; preds = %2
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = call i64 @read(i32 noundef %16, ptr noundef %7, i64 noundef 4)
  %18 = icmp sle i64 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %15
  call void @PRINT_ERR(ptr noundef @.str.10)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %36

20:                                               ; preds = %15
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = call i32 @__bswap_32(i32 noundef %21)
  %23 = icmp eq i32 %22, 87
  br i1 %23, label %24, label %30

24:                                               ; preds = %20
  call void @PRINT_INFO(ptr noundef @.str.14)
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = call i64 @read(i32 noundef %25, ptr noundef %7, i64 noundef 4)
  %27 = icmp sle i64 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %24
  call void @PRINT_ERR(ptr noundef @.str.10)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %36

29:                                               ; preds = %24
  br label %30

30:                                               ; preds = %29, %20
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = call i32 @__bswap_32(i32 noundef %31)
  %33 = icmp ne i32 %32, 82
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  call void @PRINT_ERR(ptr noundef @.str.15)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %36

35:                                               ; preds = %30
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %36

36:                                               ; preds = %35, %34, %28, %19, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %37 = load i32, ptr %3, align 4
  ret i32 %37
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; 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.9 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [51 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

declare void @PRINT_ERR(ptr noundef) local_unnamed_addr #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: inlinehint nounwind uwtable
declare hidden i32 @__bswap_32(i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #3

; Function Attrs: nofree
declare noundef i64 @read(i32 noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #3

declare void @PRINT_INFO(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @request_to_start(i32 noundef %0, i32 noundef %1) local_unnamed_addr #4 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %5 = tail call i32 @__bswap_32(i32 noundef %1)
  store i32 %5, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  %6 = call i64 @write(i32 noundef %0, ptr noundef nonnull %3, i64 noundef 4) #5
  %7 = icmp slt i64 %6, 0
  br i1 %7, label %.sink.split, label %8

8:                                                ; preds = %2
  %9 = call i64 @read(i32 noundef %0, ptr noundef nonnull %4, i64 noundef 4) #5
  %10 = icmp slt i64 %9, 1
  br i1 %10, label %.sink.split, label %11

11:                                               ; preds = %8
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = tail call i32 @__bswap_32(i32 noundef %12)
  %14 = icmp eq i32 %13, 87
  br i1 %14, label %15, label %18

15:                                               ; preds = %11
  tail call void @PRINT_INFO(ptr noundef nonnull @.str.14) #5
  %16 = call i64 @read(i32 noundef %0, ptr noundef nonnull %4, i64 noundef 4) #5
  %17 = icmp slt i64 %16, 1
  br i1 %17, label %.sink.split, label %._crit_edge

._crit_edge:                                      ; preds = %15
  %.pre = load i32, ptr %4, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %._crit_edge, %11
  %19 = phi i32 [ %.pre, %._crit_edge ], [ %12, %11 ]
  %20 = tail call i32 @__bswap_32(i32 noundef %19)
  %.not = icmp eq i32 %20, 82
  br i1 %.not, label %21, label %.sink.split

.sink.split:                                      ; preds = %18, %15, %8, %2
  %.str.15.sink = phi ptr [ @.str.9, %2 ], [ @.str.10, %8 ], [ @.str.10, %15 ], [ @.str.15, %18 ]
  %.0.ph = phi i32 [ -1, %2 ], [ -1, %8 ], [ -1, %15 ], [ 0, %18 ]
  tail call void @PRINT_ERR(ptr noundef nonnull %.str.15.sink) #5
  br label %21

21:                                               ; preds = %.sink.split, %18
  %.0 = phi i32 [ 1, %18 ], [ %.0.ph, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #3 = { nofree "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 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 #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass