; LLVM IR from godzilla-foundation/godzilla-community :: core/deps/nanomsg-1.1.5/src/protocols/reqrep (xrep)

; 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.nn_msg = type { %struct.nn_chunkref, %struct.nn_chunkref, %struct.nn_chunkref }
%struct.nn_chunkref = type { %union.anon }
%union.anon = type { ptr, [24 x i8] }
%struct.nn_xrep = type { %struct.nn_sockbase, i32, %struct.nn_hash, %struct.nn_fq }
%struct.nn_sockbase = type { ptr, ptr }
%struct.nn_hash = type { i32, i32, ptr }
%struct.nn_fq = type { %struct.nn_priolist }
%struct.nn_priolist = type { [16 x %struct.nn_priolist_slot], i32 }
%struct.nn_priolist_slot = type { %struct.nn_list, ptr }
%struct.nn_list = type { ptr, ptr }
%struct.nn_xrep_data = type { ptr, %struct.nn_hash_item, %struct.nn_fq_data, i32 }
%struct.nn_hash_item = type { i32, %struct.nn_list_item }
%struct.nn_list_item = type { ptr, ptr }
%struct.nn_fq_data = type { %struct.nn_priolist_data }
%struct.nn_priolist_data = type { ptr, i32, %struct.nn_list_item }

@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [124 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [17 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(none)
declare i64 @llvm.expect.i64(i64, i64) #1

declare void @nn_backtrace_print() #2

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

declare i32 @fflush(ptr noundef) #2

; Function Attrs: noreturn
declare void @nn_err_abort() #4

; 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 i32 @nn_xrep_send(ptr noundef %0, ptr noundef %1) #5 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %16

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 0
  br label %17

16:                                               ; preds = %2
  br label %17

17:                                               ; preds = %16, %13
  %18 = phi ptr [ %15, %13 ], [ null, %16 ]
  store ptr %18, ptr %8, align 8, !tbaa !5
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.nn_msg, ptr %19, i32 0, i32 0
  %21 = call i64 @nn_chunkref_size(ptr noundef %20)
  %22 = icmp ult i64 %21, 4
  %23 = zext i1 %22 to i32
  %24 = sext i32 %23 to i64
  %25 = call i64 @llvm.expect.i64(i64 %24, i64 0)
  %26 = icmp ne i64 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %17
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  call void @nn_msg_term(ptr noundef %28)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %96

29:                                               ; preds = %17
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.nn_msg, ptr %30, i32 0, i32 0
  %32 = call ptr @nn_chunkref_data(ptr noundef %31)
  %33 = call i32 @nn_getl(ptr noundef %32)
  store i32 %33, ptr %7, align 4, !tbaa !9
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.nn_msg, ptr %34, i32 0, i32 0
  call void @nn_chunkref_trim(ptr noundef %35, i64 noundef 4)
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.nn_xrep, ptr %36, i32 0, i32 2
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = call ptr @nn_hash_get(ptr noundef %37, i32 noundef %38)
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %47

41:                                               ; preds = %29
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.nn_xrep, ptr %42, i32 0, i32 2
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = call ptr @nn_hash_get(ptr noundef %43, i32 noundef %44)
  %46 = getelementptr inbounds i8, ptr %45, i64 -8
  br label %48

47:                                               ; preds = %29
  br label %48

48:                                               ; preds = %47, %41
  %49 = phi ptr [ %46, %41 ], [ null, %47 ]
  store ptr %49, ptr %9, align 8, !tbaa !5
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %58

52:                                               ; preds = %48
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.nn_xrep_data, ptr %53, i32 0, i32 3
  %55 = load i32, ptr %54, align 8, !tbaa !11
  %56 = and i32 %55, 1
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %60, label %58

58:                                               ; preds = %52, %48
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  call void @nn_msg_term(ptr noundef %59)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %96

60:                                               ; preds = %52
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.nn_xrep_data, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !17
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = call i32 @nn_pipe_send(ptr noundef %63, ptr noundef %64)
  store i32 %65, ptr %6, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %60
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = icmp sge i32 %67, 0
  %69 = xor i1 %68, true
  %70 = zext i1 %69 to i32
  %71 = sext i32 %70 to i64
  %72 = call i64 @llvm.expect.i64(i64 %71, i64 0)
  %73 = icmp ne i64 %72, 0
  br i1 %73, label %74, label %84

74:                                               ; preds = %66
  call void @nn_backtrace_print()
  %75 = load ptr, ptr @stderr, align 8, !tbaa !5
  %76 = load i32, ptr %6, align 4, !tbaa !9
  %77 = sub nsw i32 0, %76
  %78 = call ptr @nn_err_strerror(i32 noundef %77)
  %79 = load i32, ptr %6, align 4, !tbaa !9
  %80 = sub nsw i32 0, %79
  %81 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %75, ptr noundef @.str.5, ptr noundef %78, i32 noundef %80, ptr noundef @.str.2, i32 noundef 184) #6
  %82 = load ptr, ptr @stderr, align 8, !tbaa !5
  %83 = call i32 @fflush(ptr noundef %82)
  call void @nn_err_abort() #7
  unreachable

84:                                               ; preds = %66
  br label %85

85:                                               ; preds = %84
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %6, align 4, !tbaa !9
  %88 = and i32 %87, 1
  %89 = icmp ne i32 %88, 0
  br i1 %89, label %90, label %95

90:                                               ; preds = %86
  %91 = load ptr, ptr %9, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.nn_xrep_data, ptr %91, i32 0, i32 3
  %93 = load i32, ptr %92, align 8, !tbaa !11
  %94 = and i32 %93, -2
  store i32 %94, ptr %92, align 8, !tbaa !11
  br label %95

95:                                               ; preds = %90, %86
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %96

96:                                               ; preds = %95, %58, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %97 = load i32, ptr %3, align 4
  ret i32 %97
}

declare i64 @nn_chunkref_size(ptr noundef) #2

declare void @nn_msg_term(ptr noundef) #2

declare i32 @nn_getl(ptr noundef) #2

declare ptr @nn_chunkref_data(ptr noundef) #2

declare void @nn_chunkref_trim(ptr noundef, i64 noundef) #2

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

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

declare ptr @nn_err_strerror(i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 "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 = { noreturn "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 = { noreturn }

!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 = !{!12, !10, i64 64}
!12 = !{!"nn_xrep_data", !6, i64 0, !13, i64 8, !15, i64 32, !10, i64 64}
!13 = !{!"nn_hash_item", !10, i64 0, !14, i64 8}
!14 = !{!"nn_list_item", !6, i64 0, !6, i64 8}
!15 = !{!"nn_fq_data", !16, i64 0}
!16 = !{!"nn_priolist_data", !6, i64 0, !10, i64 8, !14, i64 16}
!17 = !{!12, !6, i64 0}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [124 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [17 x i8], align 1

declare void @nn_backtrace_print() local_unnamed_addr #0

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

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: noreturn
declare void @nn_err_abort() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @nn_xrep_send(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = tail call i64 @nn_chunkref_size(ptr noundef %1) #4
  %4 = icmp ult i64 %3, 4
  br i1 %4, label %5, label %6, !prof !5

5:                                                ; preds = %2
  tail call void @nn_msg_term(ptr noundef %1) #4
  br label %33

6:                                                ; preds = %2
  %7 = tail call ptr @nn_chunkref_data(ptr noundef %1) #4
  %8 = tail call i32 @nn_getl(ptr noundef %7) #4
  tail call void @nn_chunkref_trim(ptr noundef %1, i64 noundef 4) #4
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = tail call ptr @nn_hash_get(ptr noundef nonnull %9, i32 noundef %8) #4
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %.thread, label %11

11:                                               ; preds = %6
  %12 = tail call ptr @nn_hash_get(ptr noundef nonnull %9, i32 noundef %8) #4
  %13 = getelementptr inbounds i8, ptr %12, i64 56
  %14 = load i32, ptr %13, align 8, !tbaa !6
  %15 = and i32 %14, 1
  %.not21 = icmp eq i32 %15, 0
  br i1 %.not21, label %.thread, label %16

.thread:                                          ; preds = %6, %11
  tail call void @nn_msg_term(ptr noundef %1) #4
  br label %33

16:                                               ; preds = %11
  %17 = getelementptr inbounds i8, ptr %12, i64 -8
  %18 = load ptr, ptr %17, align 8, !tbaa !16
  %19 = tail call i32 @nn_pipe_send(ptr noundef %18, ptr noundef %1) #4
  %20 = icmp slt i32 %19, 0
  br i1 %20, label %21, label %28, !prof !5

21:                                               ; preds = %16
  tail call void @nn_backtrace_print() #4
  %22 = load ptr, ptr @stderr, align 8, !tbaa !17
  %23 = sub nsw i32 0, %19
  %24 = tail call ptr @nn_err_strerror(i32 noundef %23) #4
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str.5, ptr noundef %24, i32 noundef %23, ptr noundef nonnull @.str.2, i32 noundef 184) #5
  %26 = load ptr, ptr @stderr, align 8, !tbaa !17
  %27 = tail call i32 @fflush(ptr noundef %26)
  tail call void @nn_err_abort() #6
  unreachable

28:                                               ; preds = %16
  %29 = and i32 %19, 1
  %.not22 = icmp eq i32 %29, 0
  br i1 %.not22, label %33, label %30

30:                                               ; preds = %28
  %31 = load i32, ptr %13, align 8, !tbaa !6
  %32 = and i32 %31, -2
  store i32 %32, ptr %13, align 8, !tbaa !6
  br label %33

33:                                               ; preds = %28, %30, %.thread, %5
  ret i32 0
}

declare i64 @nn_chunkref_size(ptr noundef) local_unnamed_addr #0

declare void @nn_msg_term(ptr noundef) local_unnamed_addr #0

declare i32 @nn_getl(ptr noundef) local_unnamed_addr #0

declare ptr @nn_chunkref_data(ptr noundef) local_unnamed_addr #0

declare void @nn_chunkref_trim(ptr noundef, i64 noundef) local_unnamed_addr #0

declare ptr @nn_hash_get(ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @nn_pipe_send(ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @nn_err_strerror(i32 noundef) local_unnamed_addr #0

attributes #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 "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 }
attributes #5 = { cold 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 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!6 = !{!7, !12, i64 64}
!7 = !{!"nn_xrep_data", !8, i64 0, !11, i64 8, !14, i64 32, !12, i64 64}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"nn_hash_item", !12, i64 0, !13, i64 8}
!12 = !{!"int", !9, i64 0}
!13 = !{!"nn_list_item", !8, i64 0, !8, i64 8}
!14 = !{!"nn_fq_data", !15, i64 0}
!15 = !{!"nn_priolist_data", !8, i64 0, !12, i64 8, !13, i64 16}
!16 = !{!7, !8, i64 0}
!17 = !{!8, !8, i64 0}


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