; LLVM IR from fritzsedlazeck/SURVIVOR :: src/vcfs/Merge_VCF.ll (Z14parse_snifflesPc)

; 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.std::pair.9" = type { i32, i32 }

; 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: inlinehint mustprogress nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local i64 @_Z14parse_snifflesPc(ptr noundef %0) #3 {
  %2 = alloca %"struct.std::pair.9", align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %6 = getelementptr inbounds %"struct.std::pair.9", ptr %2, i32 0, i32 0
  store i32 0, ptr %6, align 4, !tbaa !9
  %7 = getelementptr inbounds %"struct.std::pair.9", ptr %2, i32 0, i32 1
  store i32 0, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !13
  br label %8

8:                                                ; preds = %15, %1
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = load i64, ptr %4, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %9, i64 %10
  %12 = load i8, ptr %11, align 1, !tbaa !15
  %13 = sext i8 %12 to i32
  %14 = icmp ne i32 %13, 9
  br i1 %14, label %15, label %18

15:                                               ; preds = %8
  %16 = load i64, ptr %4, align 8, !tbaa !13
  %17 = add i64 %16, 1
  store i64 %17, ptr %4, align 8, !tbaa !13
  br label %8, !llvm.loop !16

18:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !18
  br label %19

19:                                               ; preds = %83, %18
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load i64, ptr %4, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %20, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !15
  %24 = sext i8 %23 to i32
  %25 = icmp ne i32 %24, 10
  br i1 %25, label %26, label %33

26:                                               ; preds = %19
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = load i64, ptr %4, align 8, !tbaa !13
  %29 = getelementptr inbounds i8, ptr %27, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !15
  %31 = sext i8 %30 to i32
  %32 = icmp ne i32 %31, 0
  br label %33

33:                                               ; preds = %26, %19
  %34 = phi i1 [ false, %19 ], [ %32, %26 ]
  br i1 %34, label %35, label %86

35:                                               ; preds = %33
  %36 = load i32, ptr %5, align 4, !tbaa !18
  %37 = icmp eq i32 %36, 1
  br i1 %37, label %38, label %54

38:                                               ; preds = %35
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load i64, ptr %4, align 8, !tbaa !13
  %41 = sub i64 %40, 1
  %42 = getelementptr inbounds i8, ptr %39, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !15
  %44 = sext i8 %43 to i32
  %45 = icmp eq i32 %44, 58
  br i1 %45, label %46, label %54

46:                                               ; preds = %38
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = load i64, ptr %4, align 8, !tbaa !13
  %49 = getelementptr inbounds i8, ptr %47, i64 %48
  %50 = call i32 @atoi(ptr noundef %49) #5
  %51 = getelementptr inbounds %"struct.std::pair.9", ptr %2, i32 0, i32 0
  %52 = load i32, ptr %51, align 4, !tbaa !9
  %53 = add nsw i32 %52, %50
  store i32 %53, ptr %51, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %46, %38, %35
  %55 = load i32, ptr %5, align 4, !tbaa !18
  %56 = icmp eq i32 %55, 2
  br i1 %56, label %57, label %73

57:                                               ; preds = %54
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = load i64, ptr %4, align 8, !tbaa !13
  %60 = sub i64 %59, 1
  %61 = getelementptr inbounds i8, ptr %58, i64 %60
  %62 = load i8, ptr %61, align 1, !tbaa !15
  %63 = sext i8 %62 to i32
  %64 = icmp eq i32 %63, 58
  br i1 %64, label %65, label %73

65:                                               ; preds = %57
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = load i64, ptr %4, align 8, !tbaa !13
  %68 = getelementptr inbounds i8, ptr %66, i64 %67
  %69 = call i32 @atoi(ptr noundef %68) #5
  %70 = getelementptr inbounds %"struct.std::pair.9", ptr %2, i32 0, i32 1
  %71 = load i32, ptr %70, align 4, !tbaa !12
  %72 = add nsw i32 %71, %69
  store i32 %72, ptr %70, align 4, !tbaa !12
  br label %73

73:                                               ; preds = %65, %57, %54
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = load i64, ptr %4, align 8, !tbaa !13
  %76 = getelementptr inbounds i8, ptr %74, i64 %75
  %77 = load i8, ptr %76, align 1, !tbaa !15
  %78 = sext i8 %77 to i32
  %79 = icmp eq i32 %78, 58
  br i1 %79, label %80, label %83

80:                                               ; preds = %73
  %81 = load i32, ptr %5, align 4, !tbaa !18
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %5, align 4, !tbaa !18
  br label %83

83:                                               ; preds = %80, %73
  %84 = load i64, ptr %4, align 8, !tbaa !13
  %85 = add i64 %84, 1
  store i64 %85, ptr %4, align 8, !tbaa !13
  br label %19, !llvm.loop !19

86:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %87 = load i64, ptr %2, align 4
  ret i64 %87
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress nounwind willreturn memory(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" }
attributes #2 = { 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 #3 = { mustprogress 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 = { 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 = !{!10, !11, i64 0}
!10 = !{!"_ZTSSt4pairIiiE", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!11, !11, i64 0}
!19 = distinct !{!19, !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"

%"struct.std::pair.9" = type { i32, i32 }

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local i64 @_Z14parse_snifflesPc(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = alloca %"struct.std::pair.9", align 8
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  store i32 0, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 0, ptr %3, align 4, !tbaa !10
  br label %4

4:                                                ; preds = %4, %1
  %.020 = phi i64 [ 0, %1 ], [ %7, %4 ]
  %5 = getelementptr inbounds i8, ptr %0, i64 %.020
  %6 = load i8, ptr %5, align 1, !tbaa !11
  %.not = icmp eq i8 %6, 9
  %7 = add i64 %.020, 1
  br i1 %.not, label %.preheader, label %4, !llvm.loop !12

.preheader:                                       ; preds = %4, %27
  %8 = phi i8 [ %.pre, %27 ], [ 9, %4 ]
  %9 = phi i32 [ %28, %27 ], [ 0, %4 ]
  %10 = phi i32 [ %29, %27 ], [ 0, %4 ]
  %.121 = phi i64 [ %32, %27 ], [ %.020, %4 ]
  %.0 = phi i32 [ %spec.select, %27 ], [ 0, %4 ]
  %11 = getelementptr inbounds i8, ptr %0, i64 %.121
  switch i8 %8, label %12 [
    i8 10, label %.critedge
    i8 0, label %.critedge
  ]

12:                                               ; preds = %.preheader
  switch i32 %.0, label %27 [
    i32 1, label %13
    i32 2, label %20
  ]

13:                                               ; preds = %12
  %14 = getelementptr i8, ptr %11, i64 -1
  %15 = load i8, ptr %14, align 1, !tbaa !11
  %16 = icmp eq i8 %15, 58
  br i1 %16, label %17, label %27

17:                                               ; preds = %13
  %18 = call i32 @atoi(ptr nocapture noundef %11) #2
  %19 = add nsw i32 %9, %18
  store i32 %19, ptr %2, align 8, !tbaa !5
  br label %27

20:                                               ; preds = %12
  %21 = getelementptr i8, ptr %11, i64 -1
  %22 = load i8, ptr %21, align 1, !tbaa !11
  %23 = icmp eq i8 %22, 58
  br i1 %23, label %24, label %27

24:                                               ; preds = %20
  %25 = call i32 @atoi(ptr nocapture noundef %11) #2
  %26 = add nsw i32 %10, %25
  store i32 %26, ptr %3, align 4, !tbaa !10
  br label %27

27:                                               ; preds = %13, %17, %12, %24, %20
  %28 = phi i32 [ %9, %13 ], [ %19, %17 ], [ %9, %12 ], [ %9, %24 ], [ %9, %20 ]
  %29 = phi i32 [ %10, %13 ], [ %10, %17 ], [ %10, %12 ], [ %26, %24 ], [ %10, %20 ]
  %30 = icmp eq i8 %8, 58
  %31 = zext i1 %30 to i32
  %spec.select = add nuw nsw i32 %.0, %31
  %32 = add i64 %.121, 1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 %32
  %.pre = load i8, ptr %.phi.trans.insert, align 1, !tbaa !11
  br label %.preheader, !llvm.loop !14

.critedge:                                        ; preds = %.preheader, %.preheader
  %33 = load i64, ptr %2, align 8
  ret i64 %33
}

attributes #0 = { inlinehint mustprogress nofree nounwind willreturn memory(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" }
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) }

!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, !7, i64 0}
!6 = !{!"_ZTSSt4pairIiiE", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!8, !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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