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

; 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_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 }

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

; Function Attrs: nounwind uwtable
define dso_local i32 @nn_fq_recv(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.nn_fq, ptr %11, i32 0, i32 0
  %13 = call ptr @nn_priolist_getpipe(ptr noundef %12)
  store ptr %13, ptr %9, align 8, !tbaa !5
  %14 = load ptr, ptr %9, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  %16 = xor i1 %15, true
  %17 = zext i1 %16 to i32
  %18 = sext i32 %17 to i64
  %19 = call i64 @llvm.expect.i64(i64 %18, i64 0)
  %20 = icmp ne i64 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %3
  store i32 -11, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %59

22:                                               ; preds = %3
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = call i32 @nn_pipe_recv(ptr noundef %23, ptr noundef %24)
  store i32 %25, ptr %8, align 4, !tbaa !9
  br label %26

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

34:                                               ; preds = %26
  call void @nn_backtrace_print()
  %35 = load ptr, ptr @stderr, align 8, !tbaa !5
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = sub nsw i32 0, %36
  %38 = call ptr @nn_err_strerror(i32 noundef %37)
  %39 = load i32, ptr %8, align 4, !tbaa !9
  %40 = sub nsw i32 0, %39
  %41 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef @.str, ptr noundef %38, i32 noundef %40, ptr noundef @.str.1, i32 noundef 73) #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 = %26
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %52

49:                                               ; preds = %46
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %50, ptr %51, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %49, %46
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.nn_fq, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = and i32 %55, 1
  call void @nn_priolist_advance(ptr noundef %54, i32 noundef %56)
  %57 = load i32, ptr %8, align 4, !tbaa !9
  %58 = and i32 %57, -2
  store i32 %58, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %59

59:                                               ; preds = %52, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  %60 = load i32, ptr %4, align 4
  ret i32 %60
}

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

declare ptr @nn_priolist_getpipe(ptr noundef) #2

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

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

declare void @nn_backtrace_print() #2

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

declare ptr @nn_err_strerror(i32 noundef) #2

declare i32 @fflush(ptr noundef) #2

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

declare void @nn_priolist_advance(ptr noundef, i32 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 = !{!"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 [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [121 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, -1) i32 @nn_fq_recv(ptr noundef %0, ptr noundef %1, ptr noundef writeonly %2) local_unnamed_addr #0 {
  %4 = tail call ptr @nn_priolist_getpipe(ptr noundef %0) #4
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %20, label %5, !prof !5

5:                                                ; preds = %3
  %6 = tail call i32 @nn_pipe_recv(ptr noundef nonnull %4, ptr noundef %1) #4
  %7 = icmp slt i32 %6, 0
  br i1 %7, label %8, label %15, !prof !5

8:                                                ; preds = %5
  tail call void @nn_backtrace_print() #4
  %9 = load ptr, ptr @stderr, align 8, !tbaa !6
  %10 = sub nsw i32 0, %6
  %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, ptr noundef %11, i32 noundef %10, ptr noundef nonnull @.str.1, i32 noundef 73) #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 = %5
  %.not14 = icmp eq ptr %2, null
  br i1 %.not14, label %17, label %16

16:                                               ; preds = %15
  store ptr %4, ptr %2, align 8, !tbaa !6
  br label %17

17:                                               ; preds = %16, %15
  %18 = and i32 %6, 1
  tail call void @nn_priolist_advance(ptr noundef %0, i32 noundef %18) #4
  %19 = and i32 %6, 2147483646
  br label %20

20:                                               ; preds = %3, %17
  %.0 = phi i32 [ %19, %17 ], [ -11, %3 ]
  ret i32 %.0
}

declare ptr @nn_priolist_getpipe(ptr noundef) local_unnamed_addr #1

declare i32 @nn_pipe_recv(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @nn_backtrace_print() local_unnamed_addr #1

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

declare ptr @nn_err_strerror(i32 noundef) local_unnamed_addr #1

; 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_priolist_advance(ptr noundef, i32 noundef) local_unnamed_addr #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 = { "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 = !{!"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"}


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