; LLVM IR from sbu-fsl/kernel-ml :: src/utility (utility)

; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

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

declare float @power(float noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local float @convert_string_to_float_single_dec(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #4
  store i8 0, ptr %3, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store float 0.000000e+00, ptr %5, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 -1, ptr %7, align 4, !tbaa !11
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 0
  %10 = load i8, ptr %9, align 1, !tbaa !15
  %11 = sext i8 %10 to i32
  %12 = icmp eq i32 %11, 45
  br i1 %12, label %13, label %16

13:                                               ; preds = %1
  store i8 1, ptr %3, align 1, !tbaa !9
  %14 = load i32, ptr %6, align 4, !tbaa !11
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %6, align 4, !tbaa !11
  br label %16

16:                                               ; preds = %13, %1
  br label %17

17:                                               ; preds = %25, %16
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = load i32, ptr %6, align 4, !tbaa !11
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i8, ptr %18, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !15
  %23 = sext i8 %22 to i32
  %24 = icmp ne i32 %23, 46
  br i1 %24, label %25, label %37

25:                                               ; preds = %17
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = load i32, ptr %6, align 4, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %26, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !15
  %31 = sext i8 %30 to i32
  %32 = sub nsw i32 %31, 48
  %33 = load i32, ptr %4, align 4, !tbaa !11
  %34 = add nsw i32 %33, %32
  store i32 %34, ptr %4, align 4, !tbaa !11
  %35 = load i32, ptr %6, align 4, !tbaa !11
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %6, align 4, !tbaa !11
  br label %17, !llvm.loop !16

37:                                               ; preds = %17
  %38 = load i32, ptr %6, align 4, !tbaa !11
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %6, align 4, !tbaa !11
  br label %40

40:                                               ; preds = %58, %37
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = load i32, ptr %6, align 4, !tbaa !11
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i8, ptr %41, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !15
  %46 = sext i8 %45 to i32
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %56

48:                                               ; preds = %40
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = load i32, ptr %6, align 4, !tbaa !11
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i8, ptr %49, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !15
  %54 = sext i8 %53 to i32
  %55 = icmp ne i32 %54, 10
  br label %56

56:                                               ; preds = %48, %40
  %57 = phi i1 [ false, %40 ], [ %55, %48 ]
  br i1 %57, label %58, label %75

58:                                               ; preds = %56
  %59 = load i32, ptr %7, align 4, !tbaa !11
  %60 = call float @power(float noundef 1.000000e+01, i32 noundef %59)
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = load i32, ptr %6, align 4, !tbaa !11
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds i8, ptr %61, i64 %63
  %65 = load i8, ptr %64, align 1, !tbaa !15
  %66 = sext i8 %65 to i32
  %67 = sub nsw i32 %66, 48
  %68 = sitofp i32 %67 to float
  %69 = load float, ptr %5, align 4, !tbaa !13
  %70 = call float @llvm.fmuladd.f32(float %60, float %68, float %69)
  store float %70, ptr %5, align 4, !tbaa !13
  %71 = load i32, ptr %6, align 4, !tbaa !11
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %6, align 4, !tbaa !11
  %73 = load i32, ptr %7, align 4, !tbaa !11
  %74 = sub nsw i32 %73, 1
  store i32 %74, ptr %7, align 4, !tbaa !11
  br label %40, !llvm.loop !18

75:                                               ; preds = %56
  %76 = load i32, ptr %4, align 4, !tbaa !11
  %77 = sitofp i32 %76 to float
  %78 = load float, ptr %5, align 4, !tbaa !13
  %79 = fadd float %78, %77
  store float %79, ptr %5, align 4, !tbaa !13
  %80 = load i8, ptr %3, align 1, !tbaa !9, !range !19, !noundef !20
  %81 = trunc i8 %80 to i1
  br i1 %81, label %82, label %85

82:                                               ; preds = %75
  %83 = load float, ptr %5, align 4, !tbaa !13
  %84 = fmul float %83, -1.000000e+00
  store float %84, ptr %5, align 4, !tbaa !13
  br label %85

85:                                               ; preds = %82, %75
  %86 = load float, ptr %5, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  ret float %86
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { "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 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 }

!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 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{i8 0, i8 2}
!20 = !{}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

declare float @power(float noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local float @convert_string_to_float_single_dec(ptr nocapture noundef readonly %0) local_unnamed_addr #2 {
  %2 = load i8, ptr %0, align 1, !tbaa !5
  %3 = icmp eq i8 %2, 45
  %spec.select = zext i1 %3 to i64
  %4 = zext i1 %3 to i64
  %5 = getelementptr inbounds i8, ptr %0, i64 %4
  %6 = load i8, ptr %5, align 1, !tbaa !5
  %.not32 = icmp eq i8 %6, 46
  br i1 %.not32, label %.preheader, label %.lr.ph

.preheader.loopexit:                              ; preds = %.lr.ph
  %7 = sitofp i32 %12 to float
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %1
  %.026.lcssa = phi float [ 0.000000e+00, %1 ], [ %7, %.preheader.loopexit ]
  %.1.lcssa = phi i64 [ %spec.select, %1 ], [ %indvars.iv.next, %.preheader.loopexit ]
  %8 = and i64 %.1.lcssa, 4294967295
  br label %15

.lr.ph:                                           ; preds = %1, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %4, %1 ]
  %9 = phi i8 [ %14, %.lr.ph ], [ %6, %1 ]
  %.02633 = phi i32 [ %12, %.lr.ph ], [ 0, %1 ]
  %10 = sext i8 %9 to i32
  %11 = add i32 %.02633, -48
  %12 = add i32 %11, %10
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %.not = icmp eq i8 %14, 46
  br i1 %.not, label %.preheader.loopexit, label %.lr.ph, !llvm.loop !8

15:                                               ; preds = %.preheader, %18
  %indvars.iv37 = phi i64 [ %8, %.preheader ], [ %indvars.iv.next38, %18 ]
  %.024 = phi float [ 0.000000e+00, %.preheader ], [ %24, %18 ]
  %.0 = phi i32 [ -1, %.preheader ], [ %25, %18 ]
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %16 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next38
  %17 = load i8, ptr %16, align 1, !tbaa !5
  switch i8 %17, label %18 [
    i8 0, label %.critedge
    i8 10, label %.critedge
  ]

18:                                               ; preds = %15
  %19 = tail call float @power(float noundef 1.000000e+01, i32 noundef %.0) #3
  %20 = load i8, ptr %16, align 1, !tbaa !5
  %21 = sext i8 %20 to i32
  %22 = add nsw i32 %21, -48
  %23 = sitofp i32 %22 to float
  %24 = tail call float @llvm.fmuladd.f32(float %19, float %23, float %.024)
  %25 = add nsw i32 %.0, -1
  br label %15, !llvm.loop !10

.critedge:                                        ; preds = %15, %15
  %26 = fadd float %.024, %.026.lcssa
  %27 = fneg float %26
  %.125 = select i1 %3, float %27, float %26
  ret float %.125
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { "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 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


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