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

; 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"

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

9:                                                ; preds = %43, %2
  %10 = load i64, ptr %7, align 8, !tbaa !9
  %11 = load i64, ptr %5, align 8, !tbaa !9
  %12 = icmp ne i64 %10, %11
  br i1 %12, label %13, label %46

13:                                               ; preds = %9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load i64, ptr %7, align 8, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %14, i64 %15
  %17 = load i8, ptr %16, align 1, !tbaa !13
  %18 = sext i8 %17 to i32
  %19 = icmp slt i32 %18, 48
  br i1 %19, label %27, label %20

20:                                               ; preds = %13
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = load i64, ptr %7, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %21, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !13
  %25 = sext i8 %24 to i32
  %26 = icmp sgt i32 %25, 57
  br i1 %26, label %27, label %28

27:                                               ; preds = %20, %13
  store i32 -22, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %52

28:                                               ; preds = %20
  %29 = load i32, ptr %6, align 4, !tbaa !11
  %30 = mul nsw i32 %29, 10
  store i32 %30, ptr %6, align 4, !tbaa !11
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = load i64, ptr %7, align 8, !tbaa !9
  %33 = getelementptr inbounds i8, ptr %31, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !13
  %35 = sext i8 %34 to i32
  %36 = sub nsw i32 %35, 48
  %37 = load i32, ptr %6, align 4, !tbaa !11
  %38 = add nsw i32 %37, %36
  store i32 %38, ptr %6, align 4, !tbaa !11
  %39 = load i32, ptr %6, align 4, !tbaa !11
  %40 = icmp sgt i32 %39, 65535
  br i1 %40, label %41, label %42

41:                                               ; preds = %28
  store i32 -22, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %52

42:                                               ; preds = %28
  br label %43

43:                                               ; preds = %42
  %44 = load i64, ptr %7, align 8, !tbaa !9
  %45 = add i64 %44, 1
  store i64 %45, ptr %7, align 8, !tbaa !9
  br label %9, !llvm.loop !14

46:                                               ; preds = %9
  %47 = load i32, ptr %6, align 4, !tbaa !11
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %50

49:                                               ; preds = %46
  store i32 -22, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %52

50:                                               ; preds = %46
  %51 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %51, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %52

52:                                               ; preds = %50, %49, %41, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %53 = load i32, ptr %3, align 4
  ret i32 %53
}

; 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

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 = { 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 = !{!"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 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: read) uwtable
define dso_local range(i32 1, 0) i32 @nn_port_resolve(ptr nocapture noundef readonly %0, i64 noundef %1) local_unnamed_addr #0 {
  %.not19 = icmp eq i64 %1, 0
  br i1 %.not19, label %._crit_edge.thread, label %.lr.ph

3:                                                ; preds = %8
  %4 = add nuw i64 %.021, 1
  %.not = icmp eq i64 %4, %1
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

.lr.ph:                                           ; preds = %2, %3
  %.021 = phi i64 [ %4, %3 ], [ 0, %2 ]
  %.01420 = phi i32 [ %.fr, %3 ], [ 0, %2 ]
  %5 = getelementptr inbounds i8, ptr %0, i64 %.021
  %6 = load i8, ptr %5, align 1, !tbaa !7
  %7 = add i8 %6, -58
  %or.cond = icmp ult i8 %7, -10
  br i1 %or.cond, label %.loopexit, label %8

8:                                                ; preds = %.lr.ph
  %9 = mul nsw i32 %.01420, 10
  %narrow = add nsw i8 %6, -48
  %10 = zext nneg i8 %narrow to i32
  %11 = add nsw i32 %9, %10
  %.fr = freeze i32 %11
  %12 = icmp sgt i32 %.fr, 65535
  br i1 %12, label %.loopexit, label %3

._crit_edge:                                      ; preds = %3
  %13 = icmp eq i32 %.fr, 0
  br i1 %13, label %._crit_edge.thread, label %.loopexit

._crit_edge.thread:                               ; preds = %2, %._crit_edge
  br label %.loopexit

.loopexit:                                        ; preds = %8, %.lr.ph, %._crit_edge.thread, %._crit_edge
  %.015 = phi i32 [ -22, %._crit_edge.thread ], [ %.fr, %._crit_edge ], [ -22, %.lr.ph ], [ -22, %8 ]
  ret i32 %.015
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: read) 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" }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass