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

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

%"class.uWS::ExtensionsParser" = type <{ ptr, i8, i8, i8, i8, i32, i32, [4 x i8] }>

; 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
declare dso_local noundef i32 @_ZN3uWS16ExtensionsParser8getTokenERPKcS2_(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3uWS16ExtensionsParserC2EPKcm(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef %1, i64 noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %10 = load ptr, ptr %4, align 8
  %11 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 0
  store ptr null, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 1
  store i8 0, ptr %12, align 8, !tbaa !15
  %13 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 2
  store i8 0, ptr %13, align 1, !tbaa !16
  %14 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 3
  store i8 0, ptr %14, align 2, !tbaa !17
  %15 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 5
  store i32 0, ptr %15, align 4, !tbaa !18
  %16 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 6
  store i32 0, ptr %16, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = getelementptr inbounds i8, ptr %17, i64 %18
  store ptr %19, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 1, ptr %8, align 4, !tbaa !20
  br label %20

20:                                               ; preds = %29, %3
  %21 = load i32, ptr %8, align 4, !tbaa !20
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %26

23:                                               ; preds = %20
  %24 = load i32, ptr %8, align 4, !tbaa !20
  %25 = icmp ne i32 %24, 1838
  br label %26

26:                                               ; preds = %23, %20
  %27 = phi i1 [ false, %20 ], [ %25, %23 ]
  br i1 %27, label %28, label %32

28:                                               ; preds = %26
  br label %29

29:                                               ; preds = %28
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = call noundef i32 @_ZN3uWS16ExtensionsParser8getTokenERPKcS2_(ptr noundef nonnull align 8 dereferenceable(20) %10, ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef %30)
  store i32 %31, ptr %8, align 4, !tbaa !20
  br label %20, !llvm.loop !21

32:                                               ; preds = %26
  %33 = load i32, ptr %8, align 4, !tbaa !20
  %34 = icmp eq i32 %33, 1838
  %35 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 1
  %36 = zext i1 %34 to i8
  store i8 %36, ptr %35, align 8, !tbaa !15
  br label %37

37:                                               ; preds = %69, %32
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = call noundef i32 @_ZN3uWS16ExtensionsParser8getTokenERPKcS2_(ptr noundef nonnull align 8 dereferenceable(20) %10, ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef %38)
  store i32 %39, ptr %8, align 4, !tbaa !20
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %70

41:                                               ; preds = %37
  %42 = load i32, ptr %8, align 4, !tbaa !20
  switch i32 %42, label %56 [
    i32 1838, label %43
    i32 2807, label %44
    i32 2783, label %46
    i32 2372, label %48
    i32 2348, label %52
  ]

43:                                               ; preds = %41
  store i32 1, ptr %9, align 4
  br label %71

44:                                               ; preds = %41
  %45 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 2
  store i8 1, ptr %45, align 1, !tbaa !16
  br label %69

46:                                               ; preds = %41
  %47 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 3
  store i8 1, ptr %47, align 2, !tbaa !17
  br label %69

48:                                               ; preds = %41
  %49 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 5
  store i32 1, ptr %49, align 4, !tbaa !18
  %50 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 5
  %51 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 0
  store ptr %50, ptr %51, align 8, !tbaa !11
  br label %69

52:                                               ; preds = %41
  %53 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 6
  store i32 1, ptr %53, align 8, !tbaa !19
  %54 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 6
  %55 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 0
  store ptr %54, ptr %55, align 8, !tbaa !11
  br label %69

56:                                               ; preds = %41
  %57 = load i32, ptr %8, align 4, !tbaa !20
  %58 = icmp slt i32 %57, 0
  br i1 %58, label %59, label %68

59:                                               ; preds = %56
  %60 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %68

63:                                               ; preds = %59
  %64 = load i32, ptr %8, align 4, !tbaa !20
  %65 = sub nsw i32 0, %64
  %66 = getelementptr inbounds %"class.uWS::ExtensionsParser", ptr %10, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !11
  store i32 %65, ptr %67, align 4, !tbaa !20
  br label %68

68:                                               ; preds = %63, %59, %56
  br label %69

69:                                               ; preds = %68, %52, %48, %46, %44
  br label %37, !llvm.loop !23

70:                                               ; preds = %37
  store i32 0, ptr %9, align 4
  br label %71

71:                                               ; preds = %70, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  %72 = load i32, ptr %9, align 4
  switch i32 %72, label %74 [
    i32 0, label %73
    i32 1, label %73
  ]

73:                                               ; preds = %71, %71
  ret void

74:                                               ; preds = %71
  unreachable
}

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 }

!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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN3uWS16ExtensionsParserE", !6, i64 0, !13, i64 8, !13, i64 9, !13, i64 10, !14, i64 12, !14, i64 16}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !13, i64 8}
!16 = !{!12, !13, i64 9}
!17 = !{!12, !13, i64 10}
!18 = !{!12, !14, i64 12}
!19 = !{!12, !14, i64 16}
!20 = !{!14, !14, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


; 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 nounwind uwtable
declare dso_local noundef i32 @_ZN3uWS16ExtensionsParser8getTokenERPKcS2_(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3uWS16ExtensionsParserC2EPKcm(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef %1, i64 noundef %2) unnamed_addr #0 align 2 {
  %4 = alloca ptr, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = getelementptr inbounds i8, ptr %0, i64 9
  %7 = getelementptr inbounds i8, ptr %0, i64 10
  %8 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 0, ptr %8, align 4, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 0, ptr %9, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %1, i64 %2
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(11) %0, i8 0, i64 11, i1 false)
  br label %11

11:                                               ; preds = %12, %3
  %.0 = phi i32 [ 1, %3 ], [ %13, %12 ]
  switch i32 %.0, label %12 [
    i32 1838, label %14
    i32 0, label %14
  ]

12:                                               ; preds = %11
  %13 = call noundef i32 @_ZN3uWS16ExtensionsParser8getTokenERPKcS2_(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef %10)
  br label %11, !llvm.loop !14

14:                                               ; preds = %11, %11
  %15 = icmp eq i32 %.0, 1838
  %16 = zext i1 %15 to i8
  store i8 %16, ptr %5, align 8, !tbaa !16
  br label %17

17:                                               ; preds = %.backedge, %14
  %18 = call noundef i32 @_ZN3uWS16ExtensionsParser8getTokenERPKcS2_(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef %10)
  switch i32 %18, label %23 [
    i32 0, label %29
    i32 1838, label %29
    i32 2807, label %19
    i32 2783, label %20
    i32 2372, label %21
    i32 2348, label %22
  ]

19:                                               ; preds = %17
  store i8 1, ptr %6, align 1, !tbaa !17
  br label %.backedge

20:                                               ; preds = %17
  store i8 1, ptr %7, align 2, !tbaa !18
  br label %.backedge

21:                                               ; preds = %17
  store i32 1, ptr %8, align 4, !tbaa !9
  store ptr %8, ptr %0, align 8, !tbaa !19
  br label %.backedge

22:                                               ; preds = %17
  store i32 1, ptr %9, align 8, !tbaa !13
  store ptr %9, ptr %0, align 8, !tbaa !19
  br label %.backedge

23:                                               ; preds = %17
  %24 = icmp slt i32 %18, 0
  br i1 %24, label %25, label %.backedge

.backedge:                                        ; preds = %23, %25, %27, %22, %21, %20, %19
  br label %17, !llvm.loop !20

25:                                               ; preds = %23
  %26 = load ptr, ptr %0, align 8, !tbaa !19
  %.not11 = icmp eq ptr %26, null
  br i1 %.not11, label %.backedge, label %27

27:                                               ; preds = %25
  %28 = sub nsw i32 0, %18
  store i32 %28, ptr %26, align 4, !tbaa !21
  br label %.backedge

29:                                               ; preds = %17, %17
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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 = !{!10, !12, i64 12}
!10 = !{!"_ZTSN3uWS16ExtensionsParserE", !6, i64 0, !11, i64 8, !11, i64 9, !11, i64 10, !12, i64 12, !12, i64 16}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!10, !11, i64 8}
!17 = !{!10, !11, i64 9}
!18 = !{!10, !11, i64 10}
!19 = !{!10, !6, i64 0}
!20 = distinct !{!20, !15}
!21 = !{!12, !12, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass