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

; 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_xreq = type { %struct.nn_sockbase, %struct.nn_lb, %struct.nn_fq }
%struct.nn_sockbase = type { ptr, ptr }
%struct.nn_lb = 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_fq = type { %struct.nn_priolist }
%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] }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [124 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [36 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

declare ptr @nn_err_strerror(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @nn_xreq_recv(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
  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) #7
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %13

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

13:                                               ; preds = %2
  br label %14

14:                                               ; preds = %13, %10
  %15 = phi ptr [ %12, %10 ], [ null, %13 ]
  %16 = getelementptr inbounds %struct.nn_xreq, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call i32 @nn_fq_recv(ptr noundef %16, ptr noundef %17, ptr noundef null)
  store i32 %18, ptr %6, align 4, !tbaa !9
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = icmp eq i32 %19, -11
  br i1 %20, label %21, label %22

21:                                               ; preds = %14
  store i32 -11, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %90

22:                                               ; preds = %14
  br label %23

23:                                               ; preds = %22
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = icmp sge i32 %24, 0
  %26 = xor i1 %25, true
  %27 = zext i1 %26 to i32
  %28 = sext i32 %27 to i64
  %29 = call i64 @llvm.expect.i64(i64 %28, i64 0)
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %31, label %41

31:                                               ; preds = %23
  call void @nn_backtrace_print()
  %32 = load ptr, ptr @stderr, align 8, !tbaa !5
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = sub nsw i32 0, %33
  %35 = call ptr @nn_err_strerror(i32 noundef %34)
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = sub nsw i32 0, %36
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef @.str.7, ptr noundef %35, i32 noundef %37, ptr noundef @.str.2, i32 noundef 185) #7
  %39 = load ptr, ptr @stderr, align 8, !tbaa !5
  %40 = call i32 @fflush(ptr noundef %39)
  call void @nn_err_abort() #8
  unreachable

41:                                               ; preds = %23
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = and i32 %44, 2
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %89, label %47

47:                                               ; preds = %43
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.nn_msg, ptr %48, i32 0, i32 2
  %50 = call i64 @nn_chunkref_size(ptr noundef %49)
  %51 = icmp ult i64 %50, 4
  %52 = zext i1 %51 to i32
  %53 = sext i32 %52 to i64
  %54 = call i64 @llvm.expect.i64(i64 %53, i64 0)
  %55 = icmp ne i64 %54, 0
  br i1 %55, label %56, label %58

56:                                               ; preds = %47
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  call void @nn_msg_term(ptr noundef %57)
  store i32 -11, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %90

58:                                               ; preds = %47
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.nn_msg, ptr %60, i32 0, i32 0
  %62 = call i64 @nn_chunkref_size(ptr noundef %61)
  %63 = icmp eq i64 %62, 0
  %64 = xor i1 %63, true
  %65 = zext i1 %64 to i32
  %66 = sext i32 %65 to i64
  %67 = call i64 @llvm.expect.i64(i64 %66, i64 0)
  %68 = icmp ne i64 %67, 0
  br i1 %68, label %69, label %74

69:                                               ; preds = %59
  call void @nn_backtrace_print()
  %70 = load ptr, ptr @stderr, align 8, !tbaa !5
  %71 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %70, ptr noundef @.str, ptr noundef @.str.8, ptr noundef @.str.2, i32 noundef 196) #7
  %72 = load ptr, ptr @stderr, align 8, !tbaa !5
  %73 = call i32 @fflush(ptr noundef %72)
  call void @nn_err_abort() #8
  unreachable

74:                                               ; preds = %59
  br label %75

75:                                               ; preds = %74
  br label %76

76:                                               ; preds = %75
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.nn_msg, ptr %77, i32 0, i32 0
  call void @nn_chunkref_term(ptr noundef %78)
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.nn_msg, ptr %79, i32 0, i32 0
  call void @nn_chunkref_init(ptr noundef %80, i64 noundef 4)
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.nn_msg, ptr %81, i32 0, i32 0
  %83 = call ptr @nn_chunkref_data(ptr noundef %82)
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.nn_msg, ptr %84, i32 0, i32 2
  %86 = call ptr @nn_chunkref_data(ptr noundef %85)
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %83, ptr align 1 %86, i64 4, i1 false)
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.nn_msg, ptr %87, i32 0, i32 2
  call void @nn_chunkref_trim(ptr noundef %88, i64 noundef 4)
  br label %89

89:                                               ; preds = %76, %43
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %90

90:                                               ; preds = %89, %56, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  %91 = load i32, ptr %3, align 4
  ret i32 %91
}

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

declare i64 @nn_chunkref_size(ptr noundef) #2

declare void @nn_msg_term(ptr noundef) #2

declare void @nn_chunkref_term(ptr noundef) #2

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

declare ptr @nn_chunkref_data(ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

declare void @nn_chunkref_trim(ptr noundef, i64 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { 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}


; 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.2 = external hidden unnamed_addr constant [124 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [36 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

declare ptr @nn_err_strerror(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -11, 1) i32 @nn_xreq_recv(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = getelementptr inbounds i8, ptr %0, i64 408
  %4 = tail call i32 @nn_fq_recv(ptr noundef nonnull %3, ptr noundef %1, ptr noundef null) #4
  %5 = icmp eq i32 %4, -11
  br i1 %5, label %33, label %6

6:                                                ; preds = %2
  %7 = icmp slt i32 %4, 0
  br i1 %7, label %8, label %15, !prof !5

8:                                                ; preds = %6
  tail call void @nn_backtrace_print() #4
  %9 = load ptr, ptr @stderr, align 8, !tbaa !6
  %10 = sub nsw i32 0, %4
  %11 = tail call ptr @nn_err_strerror(i32 noundef %10) #4
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.7, ptr noundef %11, i32 noundef %10, ptr noundef nonnull @.str.2, i32 noundef 185) #5
  %13 = load ptr, ptr @stderr, align 8, !tbaa !6
  %14 = tail call i32 @fflush(ptr noundef %13)
  tail call void @nn_err_abort() #6
  unreachable

15:                                               ; preds = %6
  %16 = and i32 %4, 2
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %17, label %33

17:                                               ; preds = %15
  %18 = getelementptr inbounds i8, ptr %1, i64 64
  %19 = tail call i64 @nn_chunkref_size(ptr noundef nonnull %18) #4
  %20 = icmp ult i64 %19, 4
  br i1 %20, label %21, label %22, !prof !5

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

22:                                               ; preds = %17
  %23 = tail call i64 @nn_chunkref_size(ptr noundef %1) #4
  %.not17 = icmp eq i64 %23, 0
  br i1 %.not17, label %29, label %24, !prof !10

24:                                               ; preds = %22
  tail call void @nn_backtrace_print() #4
  %25 = load ptr, ptr @stderr, align 8, !tbaa !6
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str, ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.2, i32 noundef 196) #5
  %27 = load ptr, ptr @stderr, align 8, !tbaa !6
  %28 = tail call i32 @fflush(ptr noundef %27)
  tail call void @nn_err_abort() #6
  unreachable

29:                                               ; preds = %22
  tail call void @nn_chunkref_term(ptr noundef %1) #4
  tail call void @nn_chunkref_init(ptr noundef %1, i64 noundef 4) #4
  %30 = tail call ptr @nn_chunkref_data(ptr noundef %1) #4
  %31 = tail call ptr @nn_chunkref_data(ptr noundef nonnull %18) #4
  %32 = load i32, ptr %31, align 1
  store i32 %32, ptr %30, align 1
  tail call void @nn_chunkref_trim(ptr noundef nonnull %18, i64 noundef 4) #4
  br label %33

33:                                               ; preds = %15, %29, %2, %21
  %.0 = phi i32 [ -11, %21 ], [ -11, %2 ], [ 0, %29 ], [ 0, %15 ]
  ret i32 %.0
}

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

declare i64 @nn_chunkref_size(ptr noundef) local_unnamed_addr #0

declare void @nn_msg_term(ptr noundef) local_unnamed_addr #0

declare void @nn_chunkref_term(ptr noundef) local_unnamed_addr #0

declare void @nn_chunkref_init(ptr noundef, i64 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

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, !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"branch_weights", !"expected", i32 2000, i32 1}


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