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

; 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_rep = type { %struct.nn_xrep, i32, %struct.nn_chunkref }
%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_chunkref = type { %union.anon }
%union.anon = type { ptr, [24 x i8] }
%struct.nn_msg = type { %struct.nn_chunkref, %struct.nn_chunkref, %struct.nn_chunkref }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [123 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1

declare void @nn_chunkref_term(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
define dso_local i32 @nn_rep_send(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = 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 8, ptr %7) #6
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %14

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

14:                                               ; preds = %2
  br label %15

15:                                               ; preds = %14, %11
  %16 = phi ptr [ %13, %11 ], [ null, %14 ]
  store ptr %16, ptr %7, align 8, !tbaa !5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.nn_rep, ptr %17, i32 0, i32 1
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = and i32 %19, 1
  %21 = icmp ne i32 %20, 0
  %22 = xor i1 %21, true
  %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 %28

27:                                               ; preds = %15
  store i32 -156384766, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %88

28:                                               ; preds = %15
  br label %29

29:                                               ; preds = %28
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.nn_msg, ptr %30, i32 0, i32 0
  %32 = call i64 @nn_chunkref_size(ptr noundef %31)
  %33 = icmp eq i64 %32, 0
  %34 = xor i1 %33, true
  %35 = zext i1 %34 to i32
  %36 = sext i32 %35 to i64
  %37 = call i64 @llvm.expect.i64(i64 %36, i64 0)
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %39, label %44

39:                                               ; preds = %29
  call void @nn_backtrace_print()
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 102) #6
  %42 = load ptr, ptr @stderr, align 8, !tbaa !5
  %43 = call i32 @fflush(ptr noundef %42)
  call void @nn_err_abort() #7
  unreachable

44:                                               ; preds = %29
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.nn_msg, ptr %47, i32 0, i32 0
  call void @nn_chunkref_term(ptr noundef %48)
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.nn_msg, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.nn_rep, ptr %51, i32 0, i32 2
  call void @nn_chunkref_mv(ptr noundef %50, ptr noundef %52)
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.nn_rep, ptr %53, i32 0, i32 1
  %55 = load i32, ptr %54, align 8, !tbaa !9
  %56 = and i32 %55, -2
  store i32 %56, ptr %54, align 8, !tbaa !9
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.nn_rep, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds %struct.nn_xrep, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = call i32 @nn_xrep_send(ptr noundef %59, ptr noundef %60)
  store i32 %61, ptr %6, align 4, !tbaa !18
  br label %62

62:                                               ; preds = %46
  %63 = load i32, ptr %6, align 4, !tbaa !18
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %68, label %65

65:                                               ; preds = %62
  %66 = load i32, ptr %6, align 4, !tbaa !18
  %67 = icmp eq i32 %66, -11
  br label %68

68:                                               ; preds = %65, %62
  %69 = phi i1 [ true, %62 ], [ %67, %65 ]
  %70 = xor i1 %69, true
  %71 = zext i1 %70 to i32
  %72 = sext i32 %71 to i64
  %73 = call i64 @llvm.expect.i64(i64 %72, i64 0)
  %74 = icmp ne i64 %73, 0
  br i1 %74, label %75, label %85

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

85:                                               ; preds = %68
  br label %86

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %88

88:                                               ; preds = %87, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %89 = load i32, ptr %3, align 4
  ret i32 %89
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #3

declare i64 @nn_chunkref_size(ptr noundef) #0

declare void @nn_backtrace_print() #0

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

declare i32 @fflush(ptr noundef) #0

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

declare void @nn_chunkref_mv(ptr noundef, ptr noundef) #0

declare i32 @nn_xrep_send(ptr noundef, ptr noundef) #0

declare ptr @nn_err_strerror(i32 noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = { 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 #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, !13, i64 432}
!10 = !{!"nn_rep", !11, i64 0, !13, i64 432, !17, i64 440}
!11 = !{!"nn_xrep", !12, i64 0, !13, i64 16, !14, i64 24, !15, i64 40}
!12 = !{!"nn_sockbase", !6, i64 0, !6, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!"nn_hash", !13, i64 0, !13, i64 4, !6, i64 8}
!15 = !{!"nn_fq", !16, i64 0}
!16 = !{!"nn_priolist", !7, i64 0, !13, i64 384}
!17 = !{!"nn_chunkref", !7, i64 0}
!18 = !{!13, !13, 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 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [123 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1

declare void @nn_chunkref_term(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -156384766, 1) i32 @nn_rep_send(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 432
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = and i32 %4, 1
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %25, label %6, !prof !17

6:                                                ; preds = %2
  %7 = tail call i64 @nn_chunkref_size(ptr noundef %1) #4
  %.not14 = icmp eq i64 %7, 0
  br i1 %.not14, label %13, label %8, !prof !18

8:                                                ; preds = %6
  tail call void @nn_backtrace_print() #4
  %9 = load ptr, ptr @stderr, align 8, !tbaa !19
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 102) #5
  %11 = load ptr, ptr @stderr, align 8, !tbaa !19
  %12 = tail call i32 @fflush(ptr noundef %11)
  tail call void @nn_err_abort() #6
  unreachable

13:                                               ; preds = %6
  tail call void @nn_chunkref_term(ptr noundef %1) #4
  %14 = getelementptr inbounds i8, ptr %0, i64 440
  tail call void @nn_chunkref_mv(ptr noundef %1, ptr noundef nonnull %14) #4
  %15 = load i32, ptr %3, align 8, !tbaa !5
  %16 = and i32 %15, -2
  store i32 %16, ptr %3, align 8, !tbaa !5
  %17 = tail call i32 @nn_xrep_send(ptr noundef nonnull %0, ptr noundef %1) #4
  switch i32 %17, label %18 [
    i32 -11, label %25
    i32 0, label %25
  ]

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

25:                                               ; preds = %13, %13, %2
  %.0 = phi i32 [ -156384766, %2 ], [ 0, %13 ], [ 0, %13 ]
  ret i32 %.0
}

declare i64 @nn_chunkref_size(ptr noundef) local_unnamed_addr #0

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 #2

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

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

declare void @nn_chunkref_mv(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @nn_xrep_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 = { 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 = { 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 #3 = { 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 #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 = !{!6, !12, i64 432}
!6 = !{!"nn_rep", !7, i64 0, !12, i64 432, !16, i64 440}
!7 = !{!"nn_xrep", !8, i64 0, !12, i64 16, !13, i64 24, !14, i64 40}
!8 = !{!"nn_sockbase", !9, i64 0, !9, i64 8}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"int", !10, i64 0}
!13 = !{!"nn_hash", !12, i64 0, !12, i64 4, !9, i64 8}
!14 = !{!"nn_fq", !15, i64 0}
!15 = !{!"nn_priolist", !10, i64 0, !12, i64 384}
!16 = !{!"nn_chunkref", !10, i64 0}
!17 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!18 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!19 = !{!9, !9, i64 0}


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