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

; 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_xsurveyor_data = type { ptr, %struct.nn_dist_data, %struct.nn_fq_data }
%struct.nn_dist_data = type { %struct.nn_list_item, ptr }
%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 }
%struct.nn_xsurveyor = type { %struct.nn_sockbase, %struct.nn_dist, %struct.nn_fq }
%struct.nn_sockbase = type { ptr, ptr }
%struct.nn_dist = type { i32, %struct.nn_list }
%struct.nn_list = type { ptr, 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 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [129 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @nn_xsurveyor_add(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, 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
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %14

11:                                               ; preds = %2
  %12 = load ptr, ptr %3, 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 %5, align 8, !tbaa !5
  store i64 4, ptr %8, align 8, !tbaa !9
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  call void @nn_pipe_getopt(ptr noundef %17, i32 noundef 0, i32 noundef 9, ptr noundef %7, ptr noundef %8)
  br label %18

18:                                               ; preds = %15
  %19 = load i64, ptr %8, align 8, !tbaa !9
  %20 = icmp eq i64 %19, 4
  %21 = xor i1 %20, true
  %22 = zext i1 %21 to i32
  %23 = sext i32 %22 to i64
  %24 = call i64 @llvm.expect.i64(i64 %23, i64 0)
  %25 = icmp ne i64 %24, 0
  br i1 %25, label %26, label %31

26:                                               ; preds = %18
  call void @nn_backtrace_print()
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 91) #6
  %29 = load ptr, ptr @stderr, align 8, !tbaa !5
  %30 = call i32 @fflush(ptr noundef %29)
  call void @nn_err_abort() #7
  unreachable

31:                                               ; preds = %18
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr %7, align 4, !tbaa !11
  %36 = icmp sge i32 %35, 1
  br i1 %36, label %37, label %40

37:                                               ; preds = %34
  %38 = load i32, ptr %7, align 4, !tbaa !11
  %39 = icmp sle i32 %38, 16
  br label %40

40:                                               ; preds = %37, %34
  %41 = phi i1 [ false, %34 ], [ %39, %37 ]
  %42 = xor i1 %41, true
  %43 = zext i1 %42 to i32
  %44 = sext i32 %43 to i64
  %45 = call i64 @llvm.expect.i64(i64 %44, i64 0)
  %46 = icmp ne i64 %45, 0
  br i1 %46, label %47, label %52

47:                                               ; preds = %40
  call void @nn_backtrace_print()
  %48 = load ptr, ptr @stderr, align 8, !tbaa !5
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef @.str, ptr noundef @.str.3, ptr noundef @.str.2, i32 noundef 92) #6
  %50 = load ptr, ptr @stderr, align 8, !tbaa !5
  %51 = call i32 @fflush(ptr noundef %50)
  call void @nn_err_abort() #7
  unreachable

52:                                               ; preds = %40
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  %55 = call ptr @nn_alloc_(i64 noundef 64)
  store ptr %55, ptr %6, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %54
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = icmp ne ptr %57, null
  %59 = xor i1 %58, true
  %60 = zext i1 %59 to i32
  %61 = sext i32 %60 to i64
  %62 = call i64 @llvm.expect.i64(i64 %61, i64 0)
  %63 = icmp ne i64 %62, 0
  br i1 %63, label %64, label %69

64:                                               ; preds = %56
  call void @nn_backtrace_print()
  %65 = load ptr, ptr @stderr, align 8, !tbaa !5
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str.4, ptr noundef @.str.2, i32 noundef 96) #6
  %67 = load ptr, ptr @stderr, align 8, !tbaa !5
  %68 = call i32 @fflush(ptr noundef %67)
  call void @nn_err_abort() #7
  unreachable

69:                                               ; preds = %56
  br label %70

70:                                               ; preds = %69
  br label %71

71:                                               ; preds = %70
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.nn_xsurveyor_data, ptr %73, i32 0, i32 0
  store ptr %72, ptr %74, align 8, !tbaa !13
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.nn_xsurveyor, ptr %75, i32 0, i32 2
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.nn_xsurveyor_data, ptr %77, i32 0, i32 2
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = load i32, ptr %7, align 4, !tbaa !11
  call void @nn_fq_add(ptr noundef %76, ptr noundef %78, ptr noundef %79, i32 noundef %80)
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.nn_xsurveyor, ptr %81, i32 0, i32 1
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.nn_xsurveyor_data, ptr %83, i32 0, i32 1
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  call void @nn_dist_add(ptr noundef %82, ptr noundef %84, ptr noundef %85)
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  call void @nn_pipe_setdata(ptr noundef %86, ptr noundef %87)
  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 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret i32 0
}

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

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

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

declare void @nn_backtrace_print() #2

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

declare i32 @fflush(ptr noundef) #2

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

declare ptr @nn_alloc_(i64 noundef) #2

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

declare void @nn_dist_add(ptr noundef, ptr noundef, ptr noundef) #2

declare void @nn_pipe_setdata(ptr noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"nn_xsurveyor_data", !6, i64 0, !15, i64 8, !17, i64 32}
!15 = !{!"nn_dist_data", !16, i64 0, !6, i64 16}
!16 = !{!"nn_list_item", !6, i64 0, !6, i64 8}
!17 = !{!"nn_fq_data", !18, i64 0}
!18 = !{!"nn_priolist_data", !6, i64 0, !12, i64 8, !16, i64 16}


; 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 [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [129 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @nn_xsurveyor_add(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  store i64 4, ptr %4, align 8, !tbaa !5
  call void @nn_pipe_getopt(ptr noundef %1, i32 noundef 0, i32 noundef 9, ptr noundef nonnull %3, ptr noundef nonnull %4) #5
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i64 %5, 4
  br i1 %.not, label %11, label %6, !prof !9

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

11:                                               ; preds = %2
  %12 = load i32, ptr %3, align 4
  %13 = add i32 %12, -17
  %14 = icmp ult i32 %13, -16
  br i1 %14, label %15, label %20, !prof !12

15:                                               ; preds = %11
  call void @nn_backtrace_print() #5
  %16 = load ptr, ptr @stderr, align 8, !tbaa !10
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.2, i32 noundef 92) #6
  %18 = load ptr, ptr @stderr, align 8, !tbaa !10
  %19 = call i32 @fflush(ptr noundef %18)
  call void @nn_err_abort() #7
  unreachable

20:                                               ; preds = %11
  %21 = call ptr @nn_alloc_(i64 noundef 64) #5
  %.not14 = icmp eq ptr %21, null
  br i1 %.not14, label %22, label %27, !prof !12

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

27:                                               ; preds = %20
  store ptr %1, ptr %21, align 8, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %0, i64 40
  %29 = getelementptr inbounds i8, ptr %21, i64 32
  %30 = load i32, ptr %3, align 4, !tbaa !20
  call void @nn_fq_add(ptr noundef nonnull %28, ptr noundef nonnull %29, ptr noundef %1, i32 noundef %30) #5
  %31 = getelementptr inbounds i8, ptr %0, i64 16
  %32 = getelementptr inbounds i8, ptr %21, i64 8
  call void @nn_dist_add(ptr noundef nonnull %31, ptr noundef nonnull %32, ptr noundef %1) #5
  call void @nn_pipe_setdata(ptr noundef %1, ptr noundef nonnull %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  ret i32 0
}

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

declare void @nn_pipe_getopt(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @nn_backtrace_print() local_unnamed_addr #2

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

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

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

declare ptr @nn_alloc_(i64 noundef) local_unnamed_addr #2

declare void @nn_fq_add(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @nn_dist_add(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @nn_pipe_setdata(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress 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 = { 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 #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 }
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, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!13 = !{!14, !11, i64 0}
!14 = !{!"nn_xsurveyor_data", !11, i64 0, !15, i64 8, !17, i64 32}
!15 = !{!"nn_dist_data", !16, i64 0, !11, i64 16}
!16 = !{!"nn_list_item", !11, i64 0, !11, i64 8}
!17 = !{!"nn_fq_data", !18, i64 0}
!18 = !{!"nn_priolist_data", !11, i64 0, !19, i64 8, !16, i64 16}
!19 = !{!"int", !7, i64 0}
!20 = !{!19, !19, i64 0}


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