; LLVM IR from bohanwang/libpgo :: src/core/volumetricMesh (volumetricMeshParser)

; 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 void @_ZN3pgo16VolumetricMeshes20VolumetricMeshParser16removeWhitespaceEPci(ptr noundef %0, i32 noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %10, ptr %5, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %84, %2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load i8, ptr %12, align 1, !tbaa !11
  %14 = sext i8 %13 to i32
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %87

16:                                               ; preds = %11
  br label %17

17:                                               ; preds = %83, %16
  br label %18

18:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #2
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = load i8, ptr %19, align 1, !tbaa !11
  %21 = sext i8 %20 to i32
  %22 = icmp eq i32 %21, 32
  %23 = zext i1 %22 to i8
  store i8 %23, ptr %6, align 1, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %58, %18
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = icmp sle i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 6, ptr %8, align 4
  br label %61

29:                                               ; preds = %24
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr %30, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !11
  %35 = sext i8 %34 to i32
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %38

37:                                               ; preds = %29
  store i8 0, ptr %6, align 1, !tbaa !12
  store i32 6, ptr %8, align 4
  br label %61

38:                                               ; preds = %29
  %39 = load i8, ptr %6, align 1, !tbaa !12, !range !14, !noundef !15
  %40 = trunc i8 %39 to i1
  br i1 %40, label %41, label %55

41:                                               ; preds = %38
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = icmp eq ptr %42, %43
  br i1 %44, label %53, label %45

45:                                               ; preds = %41
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i8, ptr %46, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !11
  %51 = sext i8 %50 to i32
  %52 = icmp eq i32 %51, 32
  br label %53

53:                                               ; preds = %45, %41
  %54 = phi i1 [ true, %41 ], [ %52, %45 ]
  br label %55

55:                                               ; preds = %53, %38
  %56 = phi i1 [ false, %38 ], [ %54, %53 ]
  %57 = zext i1 %56 to i8
  store i8 %57, ptr %6, align 1, !tbaa !12
  br label %58

58:                                               ; preds = %55
  %59 = load i32, ptr %7, align 4, !tbaa !9
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %7, align 4, !tbaa !9
  br label %24, !llvm.loop !16

61:                                               ; preds = %37, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %62

62:                                               ; preds = %61
  %63 = load i8, ptr %6, align 1, !tbaa !12, !range !14, !noundef !15
  %64 = trunc i8 %63 to i1
  br i1 %64, label %66, label %65

65:                                               ; preds = %62
  store i32 5, ptr %8, align 4
  br label %81

66:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %67, ptr %9, align 8, !tbaa !5
  br label %68

68:                                               ; preds = %73, %66
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = load i8, ptr %69, align 1, !tbaa !11
  %71 = sext i8 %70 to i32
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %80

73:                                               ; preds = %68
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %74, i64 1
  %76 = load i8, ptr %75, align 1, !tbaa !11
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  store i8 %76, ptr %77, align 1, !tbaa !11
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %78, i32 1
  store ptr %79, ptr %9, align 8, !tbaa !5
  br label %68, !llvm.loop !18

80:                                               ; preds = %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  store i32 0, ptr %8, align 4
  br label %81

81:                                               ; preds = %80, %65
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #2
  %82 = load i32, ptr %8, align 4
  switch i32 %82, label %88 [
    i32 0, label %83
    i32 5, label %84
  ]

83:                                               ; preds = %81
  br label %17, !llvm.loop !19

84:                                               ; preds = %81
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds i8, ptr %85, i32 1
  store ptr %86, ptr %5, align 8, !tbaa !5
  br label %11, !llvm.loop !20

87:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void

88:                                               ; preds = %81
  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 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}
!20 = distinct !{!20, !17}


; 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 norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN3pgo16VolumetricMeshes20VolumetricMeshParser16removeWhitespaceEPci(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = load i8, ptr %0, align 1, !tbaa !5
  %.not37 = icmp eq i8 %3, 0
  br i1 %.not37, label %._crit_edge42, label %.critedge.preheader.lr.ph

.critedge.preheader.lr.ph:                        ; preds = %2
  %.not2531 = icmp slt i32 %1, 1
  br i1 %.not2531, label %.critedge.preheader.us, label %.critedge.preheader.preheader

.critedge.preheader.preheader:                    ; preds = %.critedge.preheader.lr.ph
  %4 = add nuw i32 %1, 1
  %wide.trip.count = zext i32 %4 to i64
  br label %.critedge.preheader

.critedge.preheader.us:                           ; preds = %.critedge.preheader.lr.ph, %.loopexit29.split.us.us
  %5 = phi i8 [ %11, %.loopexit29.split.us.us ], [ %3, %.critedge.preheader.lr.ph ]
  %.02338.us = phi ptr [ %10, %.loopexit29.split.us.us ], [ %0, %.critedge.preheader.lr.ph ]
  %6 = icmp eq i8 %5, 32
  br i1 %6, label %.lr.ph36.us.us, label %.loopexit29.split.us.us

.lr.ph36.us.us:                                   ; preds = %.critedge.preheader.us, %.lr.ph36.us.us.backedge
  %.035.us.us = phi ptr [ %.035.us.us.be, %.lr.ph36.us.us.backedge ], [ %.02338.us, %.critedge.preheader.us ]
  %7 = getelementptr inbounds i8, ptr %.035.us.us, i64 1
  %8 = load i8, ptr %7, align 1, !tbaa !5
  store i8 %8, ptr %.035.us.us, align 1, !tbaa !5
  %.not26.us.us = icmp eq i8 %8, 0
  br i1 %.not26.us.us, label %.critedge.loopexit.us.us, label %.lr.ph36.us.us.backedge

.lr.ph36.us.us.backedge:                          ; preds = %.lr.ph36.us.us, %.critedge.loopexit.us.us
  %.035.us.us.be = phi ptr [ %7, %.lr.ph36.us.us ], [ %.02338.us, %.critedge.loopexit.us.us ]
  br label %.lr.ph36.us.us, !llvm.loop !8

.critedge.loopexit.us.us:                         ; preds = %.lr.ph36.us.us
  %.pre51 = load i8, ptr %.02338.us, align 1, !tbaa !5
  %9 = icmp eq i8 %.pre51, 32
  br i1 %9, label %.lr.ph36.us.us.backedge, label %.loopexit29.split.us.us

.loopexit29.split.us.us:                          ; preds = %.critedge.loopexit.us.us, %.critedge.preheader.us
  %10 = getelementptr inbounds i8, ptr %.02338.us, i64 1
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %.not.us = icmp eq i8 %11, 0
  br i1 %.not.us, label %._crit_edge42, label %.critedge.preheader.us, !llvm.loop !10

.critedge.preheader:                              ; preds = %.critedge.preheader.preheader, %.loopexit
  %12 = phi i8 [ %31, %.loopexit ], [ %3, %.critedge.preheader.preheader ]
  %.02338 = phi ptr [ %30, %.loopexit ], [ %0, %.critedge.preheader.preheader ]
  %13 = icmp eq ptr %.02338, %0
  %14 = getelementptr inbounds i8, ptr %.02338, i64 1
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = icmp eq i8 %15, 0
  br i1 %16, label %.loopexit, label %.lr.ph

.critedge.loopexit.loopexit:                      ; preds = %.lr.ph36
  %.pre.pre = load i8, ptr %.02338, align 1, !tbaa !5
  br label %.critedge.loopexit

.critedge.loopexit:                               ; preds = %.critedge.loopexit.loopexit, %thread-pre-split
  %.pre = phi i8 [ %.pre.pre, %.critedge.loopexit.loopexit ], [ 0, %thread-pre-split ]
  %17 = load i8, ptr %14, align 1, !tbaa !5
  %18 = icmp eq i8 %17, 0
  br i1 %18, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.critedge.preheader, %.critedge.loopexit
  %19 = phi i8 [ %17, %.critedge.loopexit ], [ %15, %.critedge.preheader ]
  %.pre4860 = phi i8 [ %.pre, %.critedge.loopexit ], [ %12, %.critedge.preheader ]
  %20 = icmp eq i8 %.pre4860, 32
  br label %21

21:                                               ; preds = %.lr.ph, %.backedge
  %22 = phi i8 [ %19, %.lr.ph ], [ %26, %.backedge ]
  %.022.in3259 = phi i1 [ %20, %.lr.ph ], [ %.022.in32.be, %.backedge ]
  %indvars.iv58 = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.be, %.backedge ]
  br i1 %.022.in3259, label %23, label %.thread

23:                                               ; preds = %21
  %24 = icmp eq i8 %22, 32
  %spec.select = or i1 %13, %24
  %indvars.iv.next = add nuw nsw i64 %indvars.iv58, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.backedge

.backedge:                                        ; preds = %23, %.thread
  %indvars.iv.be = phi i64 [ %indvars.iv.next, %23 ], [ %indvars.iv.next52, %.thread ]
  %.022.in32.be = phi i1 [ %spec.select, %23 ], [ false, %.thread ]
  %25 = getelementptr inbounds i8, ptr %.02338, i64 %indvars.iv.be
  %26 = load i8, ptr %25, align 1, !tbaa !5
  %27 = icmp eq i8 %26, 0
  br i1 %27, label %.loopexit, label %21, !llvm.loop !12

.thread:                                          ; preds = %21
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv58, 1
  %exitcond.not53 = icmp eq i64 %indvars.iv.next52, %wide.trip.count
  br i1 %exitcond.not53, label %.loopexit, label %.backedge

._crit_edge:                                      ; preds = %23
  br i1 %spec.select, label %thread-pre-split, label %.loopexit

thread-pre-split:                                 ; preds = %._crit_edge
  %.not2634 = icmp eq i8 %.pre4860, 0
  br i1 %.not2634, label %.critedge.loopexit, label %.lr.ph36

.lr.ph36:                                         ; preds = %thread-pre-split, %.lr.ph36
  %.035 = phi ptr [ %28, %.lr.ph36 ], [ %.02338, %thread-pre-split ]
  %28 = getelementptr inbounds i8, ptr %.035, i64 1
  %29 = load i8, ptr %28, align 1, !tbaa !5
  store i8 %29, ptr %.035, align 1, !tbaa !5
  %.not26 = icmp eq i8 %29, 0
  br i1 %.not26, label %.critedge.loopexit.loopexit, label %.lr.ph36, !llvm.loop !13

.loopexit:                                        ; preds = %._crit_edge, %.critedge.loopexit, %.backedge, %.thread, %.critedge.preheader
  %30 = getelementptr inbounds i8, ptr %.02338, i64 1
  %31 = load i8, ptr %30, align 1, !tbaa !5
  %.not = icmp eq i8 %31, 0
  br i1 %.not, label %._crit_edge42, label %.critedge.preheader, !llvm.loop !10

._crit_edge42:                                    ; preds = %.loopexit, %.loopexit29.split.us.us, %2
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.unswitch.partial.disable"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass