; 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.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: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #2

declare void @nn_backtrace_print() #0

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

declare i32 @fflush(ptr noundef) #0

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

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

declare ptr @nn_err_strerror(i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @nn_rep_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 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 = zext i32 %20 to i64
  %22 = call i64 @llvm.expect.i64(i64 %21, i64 0)
  %23 = icmp ne i64 %22, 0
  br i1 %23, label %24, label %31

24:                                               ; preds = %15
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.nn_rep, ptr %25, i32 0, i32 2
  call void @nn_chunkref_term(ptr noundef %26)
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.nn_rep, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !9
  %30 = and i32 %29, -2
  store i32 %30, ptr %28, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %24, %15
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.nn_rep, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds %struct.nn_xrep, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call i32 @nn_xrep_recv(ptr noundef %34, ptr noundef %35)
  store i32 %36, ptr %6, align 4, !tbaa !18
  %37 = load i32, ptr %6, align 4, !tbaa !18
  %38 = icmp eq i32 %37, -11
  %39 = zext i1 %38 to i32
  %40 = sext i32 %39 to i64
  %41 = call i64 @llvm.expect.i64(i64 %40, i64 0)
  %42 = icmp ne i64 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %31
  store i32 -11, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %76

44:                                               ; preds = %31
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %6, align 4, !tbaa !18
  %47 = icmp eq i32 %46, 0
  %48 = xor i1 %47, true
  %49 = zext i1 %48 to i32
  %50 = sext i32 %49 to i64
  %51 = call i64 @llvm.expect.i64(i64 %50, i64 0)
  %52 = icmp ne i64 %51, 0
  br i1 %52, label %53, label %63

53:                                               ; preds = %45
  call void @nn_backtrace_print()
  %54 = load ptr, ptr @stderr, align 8, !tbaa !5
  %55 = load i32, ptr %6, align 4, !tbaa !18
  %56 = sub nsw i32 0, %55
  %57 = call ptr @nn_err_strerror(i32 noundef %56)
  %58 = load i32, ptr %6, align 4, !tbaa !18
  %59 = sub nsw i32 0, %58
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %54, ptr noundef @.str.3, ptr noundef %57, i32 noundef %59, ptr noundef @.str.2, i32 noundef 132) #6
  %61 = load ptr, ptr @stderr, align 8, !tbaa !5
  %62 = call i32 @fflush(ptr noundef %61)
  call void @nn_err_abort() #7
  unreachable

63:                                               ; preds = %45
  br label %64

64:                                               ; preds = %63
  br label %65

65:                                               ; preds = %64
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.nn_rep, ptr %66, i32 0, i32 2
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.nn_msg, ptr %68, i32 0, i32 0
  call void @nn_chunkref_mv(ptr noundef %67, ptr noundef %69)
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.nn_msg, ptr %70, i32 0, i32 0
  call void @nn_chunkref_init(ptr noundef %71, i64 noundef 0)
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.nn_rep, ptr %72, i32 0, i32 1
  %74 = load i32, ptr %73, align 8, !tbaa !9
  %75 = or i32 %74, 1
  store i32 %75, ptr %73, align 8, !tbaa !9
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %76

76:                                               ; preds = %65, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %77 = load i32, ptr %3, align 4
  ret i32 %77
}

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

declare void @nn_chunkref_init(ptr noundef, i64 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 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = { 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.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

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 void @nn_chunkref_mv(ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @nn_err_strerror(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -11, 1) i32 @nn_rep_recv(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %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 %10, label %6, !prof !17

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 440
  tail call void @nn_chunkref_term(ptr noundef nonnull %7) #4
  %8 = load i32, ptr %3, align 8, !tbaa !5
  %9 = and i32 %8, -2
  store i32 %9, ptr %3, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %6, %2
  %11 = tail call i32 @nn_xrep_recv(ptr noundef nonnull %0, ptr noundef %1) #4
  switch i32 %11, label %12 [
    i32 -11, label %23
    i32 0, label %19
  ], !prof !18

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

19:                                               ; preds = %10
  %20 = getelementptr inbounds i8, ptr %0, i64 440
  tail call void @nn_chunkref_mv(ptr noundef nonnull %20, ptr noundef %1) #4
  tail call void @nn_chunkref_init(ptr noundef %1, i64 noundef 0) #4
  %21 = load i32, ptr %3, align 8, !tbaa !5
  %22 = or i32 %21, 1
  store i32 %22, ptr %3, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %10, %19
  ret i32 %11
}

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

declare void @nn_chunkref_init(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 = !{!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 2000, i32 1}
!18 = !{!"branch_weights", i32 2000, i32 2001, i32 4000000}
!19 = !{!9, !9, i64 0}


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