; LLVM IR from networknt/microservices-framework-benchmark :: node-uws/src/Extensions.ll (ZN3uWS16ExtensionsParser8getTokenERPKcS2_)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN3uWS16ExtensionsParser8getTokenERPKcS2_(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  br label %9

9:                                                ; preds = %23, %3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = load i8, ptr %11, align 1, !tbaa !9
  %13 = sext i8 %12 to i32
  %14 = call i32 @isalnum(i32 noundef %13) #3
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %21, label %16

16:                                               ; preds = %9
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = icmp ne ptr %18, %19
  br label %21

21:                                               ; preds = %16, %9
  %22 = phi i1 [ false, %9 ], [ %20, %16 ]
  br i1 %22, label %23, label %27

23:                                               ; preds = %21
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i32 1
  store ptr %26, ptr %24, align 8, !tbaa !5
  br label %9, !llvm.loop !10

27:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !12
  br label %28

28:                                               ; preds = %72, %27
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = load i8, ptr %30, align 1, !tbaa !9
  %32 = sext i8 %31 to i32
  %33 = call i32 @isalnum(i32 noundef %32) #3
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %47, label %35

35:                                               ; preds = %28
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = load i8, ptr %37, align 1, !tbaa !9
  %39 = sext i8 %38 to i32
  %40 = icmp eq i32 %39, 45
  br i1 %40, label %47, label %41

41:                                               ; preds = %35
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %44 = load i8, ptr %43, align 1, !tbaa !9
  %45 = sext i8 %44 to i32
  %46 = icmp eq i32 %45, 95
  br label %47

47:                                               ; preds = %41, %35, %28
  %48 = phi i1 [ true, %35 ], [ true, %28 ], [ %46, %41 ]
  br i1 %48, label %49, label %76

49:                                               ; preds = %47
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  %52 = load i8, ptr %51, align 1, !tbaa !9
  %53 = sext i8 %52 to i32
  %54 = call i32 @isdigit(i32 noundef %53) #3
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %65

56:                                               ; preds = %49
  %57 = load i32, ptr %7, align 4, !tbaa !12
  %58 = mul nsw i32 %57, 10
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = load i8, ptr %60, align 1, !tbaa !9
  %62 = sext i8 %61 to i32
  %63 = sub nsw i32 %62, 48
  %64 = sub nsw i32 %58, %63
  store i32 %64, ptr %7, align 4, !tbaa !12
  br label %72

65:                                               ; preds = %49
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  %68 = load i8, ptr %67, align 1, !tbaa !9
  %69 = sext i8 %68 to i32
  %70 = load i32, ptr %7, align 4, !tbaa !12
  %71 = add nsw i32 %70, %69
  store i32 %71, ptr %7, align 4, !tbaa !12
  br label %72

72:                                               ; preds = %65, %56
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = load ptr, ptr %73, align 8, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %74, i32 1
  store ptr %75, ptr %73, align 8, !tbaa !5
  br label %28, !llvm.loop !14

76:                                               ; preds = %47
  %77 = load i32, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 %77
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @isalnum(i32 noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @isdigit(i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { nounwind willreturn memory(read) "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 willreturn memory(read) }
attributes #4 = { 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++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !11}


; 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: mustprogress nofree nounwind memory(read, argmem: readwrite) uwtable
define dso_local noundef i32 @_ZN3uWS16ExtensionsParser8getTokenERPKcS2_(ptr nocapture noundef nonnull readnone align 8 dereferenceable(20) %0, ptr nocapture noundef nonnull align 8 dereferenceable(8) %1, ptr noundef readnone %2) local_unnamed_addr #0 align 2 {
  %.promoted = load ptr, ptr %1, align 8, !tbaa !5
  %4 = load i8, ptr %.promoted, align 1, !tbaa !9
  %5 = sext i8 %4 to i32
  %6 = tail call i32 @isalnum(i32 noundef %5) #2
  %.not22 = icmp ne i32 %6, 0
  %.not1823 = icmp eq ptr %.promoted, %2
  %or.cond24 = or i1 %.not1823, %.not22
  br i1 %or.cond24, label %.critedge.preheader, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.lr.ph
  %7 = phi ptr [ %8, %.lr.ph ], [ %.promoted, %3 ]
  %8 = getelementptr inbounds i8, ptr %7, i64 1
  store ptr %8, ptr %1, align 8, !tbaa !5
  %9 = load i8, ptr %8, align 1, !tbaa !9
  %10 = sext i8 %9 to i32
  %11 = tail call i32 @isalnum(i32 noundef %10) #2
  %.not = icmp ne i32 %11, 0
  %.not18 = icmp eq ptr %8, %2
  %or.cond = or i1 %.not18, %.not
  br i1 %or.cond, label %.critedge.preheader, label %.lr.ph, !llvm.loop !10

.critedge.preheader:                              ; preds = %.lr.ph, %3
  %.ph = phi i8 [ %4, %3 ], [ %9, %.lr.ph ]
  %.ph29 = phi ptr [ %.promoted, %3 ], [ %8, %.lr.ph ]
  br label %.critedge

.critedge:                                        ; preds = %.critedge.preheader, %.critedge2
  %12 = phi i8 [ %.pre, %.critedge2 ], [ %.ph, %.critedge.preheader ]
  %13 = phi ptr [ %19, %.critedge2 ], [ %.ph29, %.critedge.preheader ]
  %.0 = phi i32 [ %.1, %.critedge2 ], [ 0, %.critedge.preheader ]
  %14 = sext i8 %12 to i32
  %15 = tail call i32 @isalnum(i32 noundef %14) #2
  %.fr = freeze i32 %15
  %.not19.not = icmp eq i32 %.fr, 0
  br i1 %.not19.not, label %switch.early.test, label %.critedge2

switch.early.test:                                ; preds = %.critedge
  switch i8 %12, label %20 [
    i8 95, label %.critedge2
    i8 45, label %.critedge2
  ]

.critedge2:                                       ; preds = %switch.early.test, %switch.early.test, %.critedge
  %isdigittmp = add nsw i32 %14, -48
  %isdigit = icmp ult i32 %isdigittmp, 10
  %16 = mul nsw i32 %.0, 10
  %17 = sub nsw i32 %16, %isdigittmp
  %18 = add nsw i32 %.0, %14
  %.1 = select i1 %isdigit, i32 %17, i32 %18
  %19 = getelementptr inbounds i8, ptr %13, i64 1
  store ptr %19, ptr %1, align 8, !tbaa !5
  %.pre = load i8, ptr %19, align 1, !tbaa !9
  br label %.critedge, !llvm.loop !12

20:                                               ; preds = %switch.early.test
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @isalnum(i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind memory(read, argmem: readwrite) 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 nofree nounwind willreturn memory(read) "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 = { nounwind willreturn memory(read) }

!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++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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