; LLVM IR from uNetworking/uSockets :: examples (peer_verify_test)

; 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.us_socket_context_options_t = type { ptr, ptr, ptr, ptr, ptr, ptr, i32 }

@listen_socket = external dso_local global ptr, align 8
@server_received_data = external dso_local global i8, align 1
@client_received_data = external dso_local global i8, align 1
@.str.10 = external hidden unnamed_addr constant [152 x i8], align 1
@server_context = external dso_local global ptr, align 8
@port = external dso_local global i32, align 4
@.str.11 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [34 x i8], align 1
@client_context = external dso_local global ptr, align 8
@stderr = external global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @on_wakeup(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @on_pre(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @on_post(ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_server_socket_writable(ptr noundef) #0

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_client_socket_writable(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_server_socket_close(ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_client_socket_close(ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_server_socket_end(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_client_socket_end(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_server_socket_data(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_client_socket_data(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_server_socket_open(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_client_socket_open(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_client_socket_timeout(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_server_socket_timeout(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @expect_peer_verify(ptr noundef %0, i1 noundef zeroext %1, ptr noundef byval(%struct.us_socket_context_options_t) align 8 %2, ptr noundef byval(%struct.us_socket_context_options_t) align 8 %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  %9 = zext i1 %1 to i8
  store i8 %9, ptr %6, align 1, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.us_socket_context_options_t, ptr %2, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = getelementptr inbounds %struct.us_socket_context_options_t, ptr %2, i32 0, i32 1
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  %15 = getelementptr inbounds %struct.us_socket_context_options_t, ptr %2, i32 0, i32 4
  %16 = load ptr, ptr %15, align 8, !tbaa !15
  %17 = getelementptr inbounds %struct.us_socket_context_options_t, ptr %3, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = getelementptr inbounds %struct.us_socket_context_options_t, ptr %3, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = getelementptr inbounds %struct.us_socket_context_options_t, ptr %3, i32 0, i32 4
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str.10, ptr noundef %10, ptr noundef %12, ptr noundef %14, ptr noundef %16, ptr noundef %18, ptr noundef %20, ptr noundef %22)
  %24 = call i64 @time(ptr noundef null) #5
  %25 = trunc i64 %24 to i32
  call void @srand(i32 noundef %25) #5
  store i8 0, ptr @server_received_data, align 1, !tbaa !9
  store i8 0, ptr @client_received_data, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %26 = call ptr @us_create_loop(ptr noundef null, ptr noundef @on_wakeup, ptr noundef @on_pre, ptr noundef @on_post, i32 noundef 0)
  store ptr %26, ptr %7, align 8, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = call ptr @us_create_socket_context(i32 noundef 1, ptr noundef %27, i32 noundef 16, ptr noundef byval(%struct.us_socket_context_options_t) align 8 %2)
  store ptr %28, ptr @server_context, align 8, !tbaa !5
  %29 = load ptr, ptr @server_context, align 8, !tbaa !5
  call void @us_socket_context_on_open(i32 noundef 1, ptr noundef %29, ptr noundef @on_server_socket_open)
  %30 = load ptr, ptr @server_context, align 8, !tbaa !5
  call void @us_socket_context_on_data(i32 noundef 1, ptr noundef %30, ptr noundef @on_server_socket_data)
  %31 = load ptr, ptr @server_context, align 8, !tbaa !5
  call void @us_socket_context_on_writable(i32 noundef 1, ptr noundef %31, ptr noundef @on_server_socket_writable)
  %32 = load ptr, ptr @server_context, align 8, !tbaa !5
  call void @us_socket_context_on_close(i32 noundef 1, ptr noundef %32, ptr noundef @on_server_socket_close)
  %33 = load ptr, ptr @server_context, align 8, !tbaa !5
  call void @us_socket_context_on_timeout(i32 noundef 1, ptr noundef %33, ptr noundef @on_server_socket_timeout)
  %34 = load ptr, ptr @server_context, align 8, !tbaa !5
  call void @us_socket_context_on_end(i32 noundef 1, ptr noundef %34, ptr noundef @on_server_socket_end)
  store i32 3000, ptr @port, align 4, !tbaa !16
  %35 = load ptr, ptr @server_context, align 8, !tbaa !5
  %36 = load i32, ptr @port, align 4, !tbaa !16
  %37 = call ptr @us_socket_context_listen(i32 noundef 1, ptr noundef %35, ptr noundef @.str.11, i32 noundef %36, i32 noundef 0, i32 noundef 16)
  store ptr %37, ptr @listen_socket, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %42, %4
  %39 = load ptr, ptr @listen_socket, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  %41 = xor i1 %40, true
  br i1 %41, label %42, label %47

42:                                               ; preds = %38
  %43 = load ptr, ptr @server_context, align 8, !tbaa !5
  %44 = load i32, ptr @port, align 4, !tbaa !16
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr @port, align 4, !tbaa !16
  %46 = call ptr @us_socket_context_listen(i32 noundef 1, ptr noundef %43, ptr noundef @.str.11, i32 noundef %45, i32 noundef 0, i32 noundef 16)
  store ptr %46, ptr @listen_socket, align 8, !tbaa !5
  br label %38, !llvm.loop !17

47:                                               ; preds = %38
  %48 = load i32, ptr @port, align 4, !tbaa !16
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, i32 noundef %48)
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = call ptr @us_create_socket_context(i32 noundef 1, ptr noundef %50, i32 noundef 16, ptr noundef byval(%struct.us_socket_context_options_t) align 8 %3)
  store ptr %51, ptr @client_context, align 8, !tbaa !5
  %52 = load ptr, ptr @client_context, align 8, !tbaa !5
  call void @us_socket_context_on_open(i32 noundef 1, ptr noundef %52, ptr noundef @on_client_socket_open)
  %53 = load ptr, ptr @client_context, align 8, !tbaa !5
  call void @us_socket_context_on_data(i32 noundef 1, ptr noundef %53, ptr noundef @on_client_socket_data)
  %54 = load ptr, ptr @client_context, align 8, !tbaa !5
  call void @us_socket_context_on_writable(i32 noundef 1, ptr noundef %54, ptr noundef @on_client_socket_writable)
  %55 = load ptr, ptr @client_context, align 8, !tbaa !5
  call void @us_socket_context_on_close(i32 noundef 1, ptr noundef %55, ptr noundef @on_client_socket_close)
  %56 = load ptr, ptr @client_context, align 8, !tbaa !5
  call void @us_socket_context_on_timeout(i32 noundef 1, ptr noundef %56, ptr noundef @on_client_socket_timeout)
  %57 = load ptr, ptr @client_context, align 8, !tbaa !5
  call void @us_socket_context_on_end(i32 noundef 1, ptr noundef %57, ptr noundef @on_client_socket_end)
  %58 = load ptr, ptr @client_context, align 8, !tbaa !5
  %59 = load i32, ptr @port, align 4, !tbaa !16
  %60 = call ptr @us_socket_context_connect(i32 noundef 1, ptr noundef %58, ptr noundef @.str.11, i32 noundef %59, ptr noundef null, i32 noundef 0, i32 noundef 16)
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  call void @us_loop_run(ptr noundef %61)
  %62 = load ptr, ptr @server_context, align 8, !tbaa !5
  call void @us_socket_context_free(i32 noundef 1, ptr noundef %62)
  %63 = load ptr, ptr @client_context, align 8, !tbaa !5
  call void @us_socket_context_free(i32 noundef 1, ptr noundef %63)
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  call void @us_loop_free(ptr noundef %64)
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #5
  %65 = load i8, ptr @server_received_data, align 1, !tbaa !9, !range !19, !noundef !20
  %66 = trunc i8 %65 to i1
  br i1 %66, label %67, label %70

67:                                               ; preds = %47
  %68 = load i8, ptr @client_received_data, align 1, !tbaa !9, !range !19, !noundef !20
  %69 = trunc i8 %68 to i1
  br label %70

70:                                               ; preds = %67, %47
  %71 = phi i1 [ false, %47 ], [ %69, %67 ]
  %72 = zext i1 %71 to i8
  store i8 %72, ptr %8, align 1, !tbaa !9
  %73 = load i8, ptr %6, align 1, !tbaa !9, !range !19, !noundef !20
  %74 = trunc i8 %73 to i1
  %75 = xor i1 %74, true
  %76 = xor i1 %75, true
  %77 = zext i1 %76 to i32
  %78 = load i8, ptr %8, align 1, !tbaa !9, !range !19, !noundef !20
  %79 = trunc i8 %78 to i1
  %80 = xor i1 %79, true
  %81 = xor i1 %80, true
  %82 = zext i1 %81 to i32
  %83 = icmp ne i32 %77, %82
  br i1 %83, label %84, label %95

84:                                               ; preds = %70
  %85 = load ptr, ptr @stderr, align 8, !tbaa !5
  %86 = load i8, ptr %6, align 1, !tbaa !9, !range !19, !noundef !20
  %87 = trunc i8 %86 to i1
  %88 = zext i1 %87 to i64
  %89 = select i1 %87, ptr @.str.14, ptr @.str.15
  %90 = load i8, ptr %8, align 1, !tbaa !9, !range !19, !noundef !20
  %91 = trunc i8 %90 to i1
  %92 = zext i1 %91 to i64
  %93 = select i1 %91, ptr @.str.14, ptr @.str.15
  %94 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %85, ptr noundef @.str.13, ptr noundef %89, ptr noundef %93) #5
  call void @exit(i32 noundef 1) #6
  unreachable

95:                                               ; preds = %70
  %96 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret i32 0
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) #4

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #4

declare ptr @us_create_loop(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

declare ptr @us_create_socket_context(i32 noundef, ptr noundef, i32 noundef, ptr noundef byval(%struct.us_socket_context_options_t) align 8) #2

declare void @us_socket_context_on_open(i32 noundef, ptr noundef, ptr noundef) #2

declare void @us_socket_context_on_data(i32 noundef, ptr noundef, ptr noundef) #2

declare void @us_socket_context_on_writable(i32 noundef, ptr noundef, ptr noundef) #2

declare void @us_socket_context_on_close(i32 noundef, ptr noundef, ptr noundef) #2

declare void @us_socket_context_on_timeout(i32 noundef, ptr noundef, ptr noundef) #2

declare void @us_socket_context_on_end(i32 noundef, ptr noundef, ptr noundef) #2

declare ptr @us_socket_context_listen(i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #2

declare ptr @us_socket_context_connect(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef) #2

declare void @us_loop_run(ptr noundef) #2

declare void @us_socket_context_free(i32 noundef, ptr noundef) #2

declare void @us_loop_free(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn 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 #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 }
attributes #6 = { noreturn 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, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"us_socket_context_options_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !13, i64 48}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !6, i64 32}
!16 = !{!13, !13, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{i8 0, i8 2}
!20 = !{}


; 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.us_socket_context_options_t = type { ptr, ptr, ptr, ptr, ptr, ptr, i32 }

@listen_socket = external dso_local local_unnamed_addr global ptr, align 8
@server_received_data = external dso_local local_unnamed_addr global i8, align 1
@client_received_data = external dso_local local_unnamed_addr global i8, align 1
@.str.10 = external hidden unnamed_addr constant [152 x i8], align 1
@server_context = external dso_local local_unnamed_addr global ptr, align 8
@port = external dso_local local_unnamed_addr global i32, align 4
@.str.11 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [34 x i8], align 1
@client_context = external dso_local local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @on_wakeup(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @on_pre(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @on_post(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_server_socket_writable(ptr noundef) #0

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_client_socket_writable(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_server_socket_close(ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_client_socket_close(ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_server_socket_end(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_client_socket_end(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_server_socket_data(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_client_socket_data(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_server_socket_open(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_client_socket_open(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_client_socket_timeout(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @on_server_socket_timeout(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @expect_peer_verify(ptr noundef %0, i1 noundef zeroext %1, ptr noundef byval(%struct.us_socket_context_options_t) align 8 %2, ptr noundef byval(%struct.us_socket_context_options_t) align 8 %3) local_unnamed_addr #0 {
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %2, i64 32
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %3, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %3, i64 32
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10, ptr noundef %0, ptr noundef %5, ptr noundef %7, ptr noundef %9, ptr noundef %10, ptr noundef %12, ptr noundef %14)
  %16 = tail call i64 @time(ptr noundef null) #5
  %17 = trunc i64 %16 to i32
  tail call void @srand(i32 noundef %17) #5
  store i8 0, ptr @server_received_data, align 1, !tbaa !13
  store i8 0, ptr @client_received_data, align 1, !tbaa !13
  %18 = tail call ptr @us_create_loop(ptr noundef null, ptr noundef nonnull @on_wakeup, ptr noundef nonnull @on_pre, ptr noundef nonnull @on_post, i32 noundef 0) #5
  %19 = tail call ptr @us_create_socket_context(i32 noundef 1, ptr noundef %18, i32 noundef 16, ptr noundef nonnull byval(%struct.us_socket_context_options_t) align 8 %2) #5
  store ptr %19, ptr @server_context, align 8, !tbaa !15
  tail call void @us_socket_context_on_open(i32 noundef 1, ptr noundef %19, ptr noundef nonnull @on_server_socket_open) #5
  %20 = load ptr, ptr @server_context, align 8, !tbaa !15
  tail call void @us_socket_context_on_data(i32 noundef 1, ptr noundef %20, ptr noundef nonnull @on_server_socket_data) #5
  %21 = load ptr, ptr @server_context, align 8, !tbaa !15
  tail call void @us_socket_context_on_writable(i32 noundef 1, ptr noundef %21, ptr noundef nonnull @on_server_socket_writable) #5
  %22 = load ptr, ptr @server_context, align 8, !tbaa !15
  tail call void @us_socket_context_on_close(i32 noundef 1, ptr noundef %22, ptr noundef nonnull @on_server_socket_close) #5
  %23 = load ptr, ptr @server_context, align 8, !tbaa !15
  tail call void @us_socket_context_on_timeout(i32 noundef 1, ptr noundef %23, ptr noundef nonnull @on_server_socket_timeout) #5
  %24 = load ptr, ptr @server_context, align 8, !tbaa !15
  tail call void @us_socket_context_on_end(i32 noundef 1, ptr noundef %24, ptr noundef nonnull @on_server_socket_end) #5
  store i32 3000, ptr @port, align 4, !tbaa !16
  %25 = load ptr, ptr @server_context, align 8, !tbaa !15
  %26 = tail call ptr @us_socket_context_listen(i32 noundef 1, ptr noundef %25, ptr noundef nonnull @.str.11, i32 noundef 3000, i32 noundef 0, i32 noundef 16) #5
  store ptr %26, ptr @listen_socket, align 8, !tbaa !15
  %.not9 = icmp eq ptr %26, null
  br i1 %.not9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4, %.lr.ph
  %27 = load ptr, ptr @server_context, align 8, !tbaa !15
  %28 = load i32, ptr @port, align 4, !tbaa !16
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr @port, align 4, !tbaa !16
  %30 = tail call ptr @us_socket_context_listen(i32 noundef 1, ptr noundef %27, ptr noundef nonnull @.str.11, i32 noundef %29, i32 noundef 0, i32 noundef 16) #5
  store ptr %30, ptr @listen_socket, align 8, !tbaa !15
  %.not = icmp eq ptr %30, null
  br i1 %.not, label %.lr.ph, label %._crit_edge, !llvm.loop !17

._crit_edge:                                      ; preds = %.lr.ph, %4
  %31 = load i32, ptr @port, align 4, !tbaa !16
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %31)
  %33 = tail call ptr @us_create_socket_context(i32 noundef 1, ptr noundef %18, i32 noundef 16, ptr noundef nonnull byval(%struct.us_socket_context_options_t) align 8 %3) #5
  store ptr %33, ptr @client_context, align 8, !tbaa !15
  tail call void @us_socket_context_on_open(i32 noundef 1, ptr noundef %33, ptr noundef nonnull @on_client_socket_open) #5
  %34 = load ptr, ptr @client_context, align 8, !tbaa !15
  tail call void @us_socket_context_on_data(i32 noundef 1, ptr noundef %34, ptr noundef nonnull @on_client_socket_data) #5
  %35 = load ptr, ptr @client_context, align 8, !tbaa !15
  tail call void @us_socket_context_on_writable(i32 noundef 1, ptr noundef %35, ptr noundef nonnull @on_client_socket_writable) #5
  %36 = load ptr, ptr @client_context, align 8, !tbaa !15
  tail call void @us_socket_context_on_close(i32 noundef 1, ptr noundef %36, ptr noundef nonnull @on_client_socket_close) #5
  %37 = load ptr, ptr @client_context, align 8, !tbaa !15
  tail call void @us_socket_context_on_timeout(i32 noundef 1, ptr noundef %37, ptr noundef nonnull @on_client_socket_timeout) #5
  %38 = load ptr, ptr @client_context, align 8, !tbaa !15
  tail call void @us_socket_context_on_end(i32 noundef 1, ptr noundef %38, ptr noundef nonnull @on_client_socket_end) #5
  %39 = load ptr, ptr @client_context, align 8, !tbaa !15
  %40 = load i32, ptr @port, align 4, !tbaa !16
  %41 = tail call ptr @us_socket_context_connect(i32 noundef 1, ptr noundef %39, ptr noundef nonnull @.str.11, i32 noundef %40, ptr noundef null, i32 noundef 0, i32 noundef 16) #5
  tail call void @us_loop_run(ptr noundef %18) #5
  %42 = load ptr, ptr @server_context, align 8, !tbaa !15
  tail call void @us_socket_context_free(i32 noundef 1, ptr noundef %42) #5
  %43 = load ptr, ptr @client_context, align 8, !tbaa !15
  tail call void @us_socket_context_free(i32 noundef 1, ptr noundef %43) #5
  tail call void @us_loop_free(ptr noundef %18) #5
  %44 = load i8, ptr @server_received_data, align 1, !tbaa !13, !range !19, !noundef !20
  %45 = trunc nuw i8 %44 to i1
  %46 = load i8, ptr @client_received_data, align 1, !range !19
  %47 = trunc nuw i8 %46 to i1
  %48 = select i1 %45, i1 %47, i1 false
  %49 = xor i1 %48, %1
  br i1 %49, label %50, label %55

50:                                               ; preds = %._crit_edge
  %51 = load ptr, ptr @stderr, align 8, !tbaa !15
  %52 = select i1 %1, ptr @.str.14, ptr @.str.15
  %53 = select i1 %48, ptr @.str.14, ptr @.str.15
  %54 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %51, ptr noundef nonnull @.str.13, ptr noundef nonnull %52, ptr noundef nonnull %53) #6
  tail call void @exit(i32 noundef 1) #7
  unreachable

55:                                               ; preds = %._crit_edge
  %56 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  ret i32 0
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #3

declare ptr @us_create_loop(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

declare ptr @us_create_socket_context(i32 noundef, ptr noundef, i32 noundef, ptr noundef byval(%struct.us_socket_context_options_t) align 8) local_unnamed_addr #4

declare void @us_socket_context_on_open(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @us_socket_context_on_data(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @us_socket_context_on_writable(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @us_socket_context_on_close(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @us_socket_context_on_timeout(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @us_socket_context_on_end(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare ptr @us_socket_context_listen(i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4

declare ptr @us_socket_context_connect(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #4

declare void @us_loop_run(ptr noundef) local_unnamed_addr #4

declare void @us_socket_context_free(i32 noundef, ptr noundef) local_unnamed_addr #4

declare void @us_loop_free(ptr noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { 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 #1 = { 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 #2 = { noreturn 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 = { 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 #4 = { "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 }
attributes #6 = { cold nounwind }
attributes #7 = { noreturn 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, !7, i64 0}
!6 = !{!"us_socket_context_options_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !7, i64 32}
!13 = !{!14, !14, i64 0}
!14 = !{!"_Bool", !8, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!10, !10, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{i8 0, i8 2}
!20 = !{}


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