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

; 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_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_priolist_data = type { ptr, i32, %struct.nn_list_item }
%struct.nn_list_item = type { ptr, 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 [18 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [127 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(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare ptr @nn_list_erase(ptr noundef, ptr noundef) #1

declare ptr @nn_list_begin(ptr noundef) #1

declare i32 @nn_list_empty(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @nn_priolist_advance(ptr noundef %0, i32 noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  br label %8

8:                                                ; preds = %2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.nn_priolist, ptr %9, i32 0, i32 1
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = icmp sgt i32 %11, 0
  %13 = xor i1 %12, true
  %14 = zext i1 %13 to i32
  %15 = sext i32 %14 to i64
  %16 = call i64 @llvm.expect.i64(i64 %15, i64 0)
  %17 = icmp ne i64 %16, 0
  br i1 %17, label %18, label %23

18:                                               ; preds = %8
  call void @nn_backtrace_print()
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 154) #6
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = call i32 @fflush(ptr noundef %21)
  call void @nn_err_abort() #7
  unreachable

23:                                               ; preds = %8
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.nn_priolist, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.nn_priolist, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %31 = sub nsw i32 %30, 1
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [16 x %struct.nn_priolist_slot], ptr %27, i64 0, i64 %32
  store ptr %33, ptr %5, align 8, !tbaa !5
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %44

36:                                               ; preds = %25
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.nn_priolist_slot, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.nn_priolist_slot, ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  %42 = getelementptr inbounds %struct.nn_priolist_data, ptr %41, i32 0, i32 2
  %43 = call ptr @nn_list_erase(ptr noundef %38, ptr noundef %42)
  store ptr %43, ptr %6, align 8, !tbaa !5
  br label %52

44:                                               ; preds = %25
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.nn_priolist_slot, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.nn_priolist_slot, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = getelementptr inbounds %struct.nn_priolist_data, ptr %49, i32 0, i32 2
  %51 = call ptr @nn_list_next(ptr noundef %46, ptr noundef %50)
  store ptr %51, ptr %6, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %44, %36
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %59, label %55

55:                                               ; preds = %52
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.nn_priolist_slot, ptr %56, i32 0, i32 0
  %58 = call ptr @nn_list_begin(ptr noundef %57)
  store ptr %58, ptr %6, align 8, !tbaa !5
  br label %59

59:                                               ; preds = %55, %52
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %65

62:                                               ; preds = %59
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i64 -16
  br label %66

65:                                               ; preds = %59
  br label %66

66:                                               ; preds = %65, %62
  %67 = phi ptr [ %64, %62 ], [ null, %65 ]
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.nn_priolist_slot, ptr %68, i32 0, i32 1
  store ptr %67, ptr %69, align 8, !tbaa !13
  br label %70

70:                                               ; preds = %87, %66
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.nn_priolist_slot, ptr %71, i32 0, i32 0
  %73 = call i32 @nn_list_empty(ptr noundef %72)
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %96

75:                                               ; preds = %70
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.nn_priolist, ptr %76, i32 0, i32 1
  %78 = load i32, ptr %77, align 8, !tbaa !11
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %77, align 8, !tbaa !11
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.nn_priolist, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 8, !tbaa !11
  %83 = icmp sgt i32 %82, 16
  br i1 %83, label %84, label %87

84:                                               ; preds = %75
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.nn_priolist, ptr %85, i32 0, i32 1
  store i32 -1, ptr %86, align 8, !tbaa !11
  store i32 1, ptr %7, align 4
  br label %97

87:                                               ; preds = %75
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.nn_priolist, ptr %88, i32 0, i32 0
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.nn_priolist, ptr %90, i32 0, i32 1
  %92 = load i32, ptr %91, align 8, !tbaa !11
  %93 = sub nsw i32 %92, 1
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [16 x %struct.nn_priolist_slot], ptr %89, i64 0, i64 %94
  store ptr %95, ptr %5, align 8, !tbaa !5
  br label %70, !llvm.loop !16

96:                                               ; preds = %70
  store i32 0, ptr %7, align 4
  br label %97

97:                                               ; preds = %96, %84
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  %98 = load i32, ptr %7, align 4
  switch i32 %98, label %100 [
    i32 0, label %99
    i32 1, label %99
  ]

99:                                               ; preds = %97, %97
  ret void

100:                                              ; preds = %97
  unreachable
}

declare void @nn_backtrace_print() #1

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

declare i32 @fflush(ptr noundef) #1

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

declare ptr @nn_list_next(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 "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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 384}
!12 = !{!"nn_priolist", !7, i64 0, !10, i64 384}
!13 = !{!14, !6, i64 16}
!14 = !{!"nn_priolist_slot", !15, i64 0, !6, i64 16}
!15 = !{!"nn_list", !6, i64 0, !6, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; 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.nn_priolist_slot = type { %struct.nn_list, ptr }
%struct.nn_list = type { ptr, ptr }

@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 [18 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [127 x i8], align 1

declare ptr @nn_list_erase(ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @nn_list_begin(ptr noundef) local_unnamed_addr #0

declare i32 @nn_list_empty(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @nn_priolist_advance(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 384
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp slt i32 %4, 1
  br i1 %5, label %6, label %11, !prof !10

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

11:                                               ; preds = %2
  %12 = add nsw i32 %4, -1
  %13 = zext nneg i32 %12 to i64
  %14 = getelementptr inbounds [16 x %struct.nn_priolist_slot], ptr %0, i64 0, i64 %13
  %.not = icmp eq i32 %1, 0
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  br i1 %.not, label %20, label %18

18:                                               ; preds = %11
  %19 = tail call ptr @nn_list_erase(ptr noundef %14, ptr noundef nonnull %17) #4
  br label %22

20:                                               ; preds = %11
  %21 = tail call ptr @nn_list_next(ptr noundef %14, ptr noundef nonnull %17) #4
  br label %22

22:                                               ; preds = %20, %18
  %.0 = phi ptr [ %19, %18 ], [ %21, %20 ]
  %.not19 = icmp eq ptr %.0, null
  br i1 %.not19, label %23, label %25

23:                                               ; preds = %22
  %24 = tail call ptr @nn_list_begin(ptr noundef nonnull %14) #4
  br label %25

25:                                               ; preds = %23, %22
  %.1 = phi ptr [ %.0, %22 ], [ %24, %23 ]
  %.not20 = icmp eq ptr %.1, null
  %26 = getelementptr inbounds i8, ptr %.1, i64 -16
  %27 = select i1 %.not20, ptr null, ptr %26
  %28 = getelementptr inbounds i8, ptr %14, i64 16
  store ptr %27, ptr %28, align 8, !tbaa !13
  %29 = tail call i32 @nn_list_empty(ptr noundef nonnull %14) #4
  %.not2122 = icmp eq i32 %29, 0
  br i1 %.not2122, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %25, %34
  %30 = load i32, ptr %3, align 8, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %3, align 8, !tbaa !5
  %32 = icmp sgt i32 %30, 15
  br i1 %32, label %33, label %34

33:                                               ; preds = %.lr.ph
  store i32 -1, ptr %3, align 8, !tbaa !5
  br label %.loopexit

34:                                               ; preds = %.lr.ph
  %35 = sext i32 %30 to i64
  %36 = getelementptr inbounds [16 x %struct.nn_priolist_slot], ptr %0, i64 0, i64 %35
  %37 = tail call i32 @nn_list_empty(ptr noundef %36) #4
  %.not21 = icmp eq i32 %37, 0
  br i1 %.not21, label %.loopexit, label %.lr.ph, !llvm.loop !16

.loopexit:                                        ; preds = %34, %25, %33
  ret void
}

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 ptr @nn_list_next(ptr noundef, ptr 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, !9, i64 384}
!6 = !{!"nn_priolist", !7, i64 0, !9, i64 384}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !12, i64 16}
!14 = !{!"nn_priolist_slot", !15, i64 0, !12, i64 16}
!15 = !{!"nn_list", !12, i64 0, !12, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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