; LLVM IR from bkaradzic/bgfx :: 3rdparty/fcpp (cpp6)

; 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.Global = type { i32, i32, ptr, ptr, i32, i32, i32, ptr, i32, i32, i32, i32, [513 x i8], ptr, i8, i8, i8, i8, i8, [32 x i8], ptr, [20 x ptr], ptr, [20 x ptr], [20 x i8], i32, [5 x ptr], [5 x ptr], i8, ptr, [1025 x i8], ptr, [31 x ptr], i32, ptr, [64 x ptr], i32, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, i8, i8, i8, i8, ptr, i64, i8, i8, i8, i8, i8, i8, ptr, [20 x ptr], i32, i8, i8, i8, ptr }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @fpp_get(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local void @fpp_unget(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @fpp_cerror(ptr noundef, i32 noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @fpp_scanstring(ptr noundef %0, i32 noundef %1, ptr noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.Global, ptr %11, i32 0, i32 10
  store i32 1, ptr %12, align 8, !tbaa !11
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = call i32 %13(ptr noundef %14, i32 noundef %15)
  store i32 %16, ptr %9, align 4, !tbaa !9
  %17 = load i32, ptr %9, align 4, !tbaa !9
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %21

19:                                               ; preds = %3
  %20 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %20, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %74

21:                                               ; preds = %3
  br label %22

22:                                               ; preds = %58, %21
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call i32 @fpp_get(ptr noundef %23)
  store i32 %24, ptr %8, align 4, !tbaa !9
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = icmp ne i32 %24, %25
  br i1 %26, label %27, label %33

27:                                               ; preds = %22
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = icmp ne i32 %28, 10
  br i1 %29, label %30, label %33

30:                                               ; preds = %27
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  br label %33

33:                                               ; preds = %30, %27, %22
  %34 = phi i1 [ false, %27 ], [ false, %22 ], [ %32, %30 ]
  br i1 %34, label %35, label %59

35:                                               ; preds = %33
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = call i32 %36(ptr noundef %37, i32 noundef %38)
  store i32 %39, ptr %9, align 4, !tbaa !9
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %35
  %43 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %43, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %74

44:                                               ; preds = %35
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = icmp eq i32 %45, 92
  br i1 %46, label %47, label %58

47:                                               ; preds = %44
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = call i32 @fpp_get(ptr noundef %50)
  %52 = call i32 %48(ptr noundef %49, i32 noundef %51)
  store i32 %52, ptr %9, align 4, !tbaa !9
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %57

55:                                               ; preds = %47
  %56 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %56, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %74

57:                                               ; preds = %47
  br label %58

58:                                               ; preds = %57, %44
  br label %22, !llvm.loop !14

59:                                               ; preds = %33
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.Global, ptr %60, i32 0, i32 10
  store i32 0, ptr %61, align 8, !tbaa !11
  %62 = load i32, ptr %8, align 4, !tbaa !9
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = icmp eq i32 %62, %63
  br i1 %64, label %65, label %71

65:                                               ; preds = %59
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = load i32, ptr %8, align 4, !tbaa !9
  %69 = call i32 %66(ptr noundef %67, i32 noundef %68)
  store i32 %69, ptr %9, align 4, !tbaa !9
  %70 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %70, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %74

71:                                               ; preds = %59
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  call void (ptr, i32, ...) @fpp_cerror(ptr noundef %72, i32 noundef 26)
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  call void @fpp_unget(ptr noundef %73)
  store i32 16, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %74

74:                                               ; preds = %71, %65, %55, %42, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %75 = load i32, ptr %4, align 4
  ret i32 %75
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 56}
!12 = !{!"Global", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !7, i64 64, !6, i64 584, !7, i64 592, !7, i64 593, !7, i64 594, !7, i64 595, !7, i64 596, !7, i64 597, !6, i64 632, !7, i64 640, !6, i64 800, !7, i64 808, !7, i64 968, !10, i64 988, !7, i64 992, !7, i64 1032, !7, i64 1072, !6, i64 1080, !7, i64 1088, !6, i64 2120, !7, i64 2128, !10, i64 2376, !6, i64 2384, !7, i64 2392, !10, i64 2904, !6, i64 2912, !6, i64 2920, !6, i64 2928, !6, i64 2936, !6, i64 2944, !6, i64 2952, !7, i64 2960, !7, i64 2961, !7, i64 2962, !7, i64 2963, !7, i64 2964, !7, i64 2965, !7, i64 2966, !7, i64 2967, !6, i64 2968, !13, i64 2976, !7, i64 2984, !7, i64 2985, !7, i64 2986, !7, i64 2987, !7, i64 2988, !7, i64 2989, !6, i64 2992, !7, i64 3000, !10, i64 3160, !7, i64 3164, !7, i64 3165, !7, i64 3166, !6, i64 3168}
!13 = !{!"long", !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: nounwind uwtable
declare dso_local i32 @fpp_get(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @fpp_unget(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @fpp_cerror(ptr noundef, i32 noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @fpp_scanstring(ptr noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 1, ptr %4, align 8, !tbaa !5
  %5 = tail call i32 %2(ptr noundef %0, i32 noundef %1) #1
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %3
  %6 = tail call i32 @fpp_get(ptr noundef nonnull %0)
  %.fr41 = freeze i32 %6
  %.not3942 = icmp eq i32 %.fr41, %1
  br i1 %.not3942, label %.critedge.thread, label %switch.early.test

switch.early.test:                                ; preds = %.preheader, %14
  %.fr43 = phi i32 [ %.fr, %14 ], [ %.fr41, %.preheader ]
  switch i32 %.fr43, label %7 [
    i32 10, label %.critedge
    i32 0, label %.critedge
  ]

7:                                                ; preds = %switch.early.test
  %8 = tail call i32 %2(ptr noundef %0, i32 noundef %.fr43) #1
  %.not37 = icmp eq i32 %8, 0
  br i1 %.not37, label %9, label %.loopexit

9:                                                ; preds = %7
  %10 = icmp eq i32 %.fr43, 92
  br i1 %10, label %11, label %14

11:                                               ; preds = %9
  %12 = tail call i32 @fpp_get(ptr noundef %0)
  %13 = tail call i32 %2(ptr noundef %0, i32 noundef %12) #1
  %.not38 = icmp eq i32 %13, 0
  br i1 %.not38, label %14, label %.loopexit

14:                                               ; preds = %11, %9
  %15 = tail call i32 @fpp_get(ptr noundef %0)
  %.fr = freeze i32 %15
  %.not39 = icmp eq i32 %.fr, %1
  br i1 %.not39, label %.critedge.thread, label %switch.early.test, !llvm.loop !12

.critedge.thread:                                 ; preds = %14, %.preheader
  store i32 0, ptr %4, align 8, !tbaa !5
  br label %17

.critedge:                                        ; preds = %switch.early.test, %switch.early.test
  store i32 0, ptr %4, align 8, !tbaa !5
  %16 = icmp eq i32 %.fr43, %1
  br i1 %16, label %17, label %19

17:                                               ; preds = %.critedge.thread, %.critedge
  %18 = tail call i32 %2(ptr noundef nonnull %0, i32 noundef %1) #1
  br label %.loopexit

19:                                               ; preds = %.critedge
  tail call void (ptr, i32, ...) @fpp_cerror(ptr noundef nonnull %0, i32 noundef 26)
  tail call void @fpp_unget(ptr noundef nonnull %0)
  br label %.loopexit

.loopexit:                                        ; preds = %11, %7, %3, %19, %17
  %.0 = phi i32 [ %18, %17 ], [ 16, %19 ], [ %5, %3 ], [ %13, %11 ], [ %8, %7 ]
  ret i32 %.0
}

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 = { 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, !7, i64 56}
!6 = !{!"Global", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !10, i64 40, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !8, i64 64, !10, i64 584, !8, i64 592, !8, i64 593, !8, i64 594, !8, i64 595, !8, i64 596, !8, i64 597, !10, i64 632, !8, i64 640, !10, i64 800, !8, i64 808, !8, i64 968, !7, i64 988, !8, i64 992, !8, i64 1032, !8, i64 1072, !10, i64 1080, !8, i64 1088, !10, i64 2120, !8, i64 2128, !7, i64 2376, !10, i64 2384, !8, i64 2392, !7, i64 2904, !10, i64 2912, !10, i64 2920, !10, i64 2928, !10, i64 2936, !10, i64 2944, !10, i64 2952, !8, i64 2960, !8, i64 2961, !8, i64 2962, !8, i64 2963, !8, i64 2964, !8, i64 2965, !8, i64 2966, !8, i64 2967, !10, i64 2968, !11, i64 2976, !8, i64 2984, !8, i64 2985, !8, i64 2986, !8, i64 2987, !8, i64 2988, !8, i64 2989, !10, i64 2992, !8, i64 3000, !7, i64 3160, !8, i64 3164, !8, i64 3165, !8, i64 3166, !10, i64 3168}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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