; 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

; Function Attrs: nounwind uwtable
define dso_local float @convert_string_to_float(ptr noundef %0) #2 {
  %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 %43

25:                                               ; preds = %17
  %26 = load i32, ptr %6, align 4, !tbaa !11
  %27 = sub nsw i32 7, %26
  %28 = call float @power(float noundef 1.000000e+01, i32 noundef %27)
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = load i32, ptr %6, align 4, !tbaa !11
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds i8, ptr %29, i64 %31
  %33 = load i8, ptr %32, align 1, !tbaa !15
  %34 = sext i8 %33 to i32
  %35 = sub nsw i32 %34, 48
  %36 = sitofp i32 %35 to float
  %37 = load i32, ptr %4, align 4, !tbaa !11
  %38 = sitofp i32 %37 to float
  %39 = call float @llvm.fmuladd.f32(float %28, float %36, float %38)
  %40 = fptosi float %39 to i32
  store i32 %40, ptr %4, align 4, !tbaa !11
  %41 = load i32, ptr %6, align 4, !tbaa !11
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %6, align 4, !tbaa !11
  br label %17, !llvm.loop !16

43:                                               ; preds = %17
  %44 = load i32, ptr %6, align 4, !tbaa !11
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %6, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %64, %43
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = load i32, ptr %6, align 4, !tbaa !11
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i8, ptr %47, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !15
  %52 = sext i8 %51 to i32
  %53 = icmp ne i32 %52, 32
  br i1 %53, label %54, label %62

54:                                               ; preds = %46
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = load i32, ptr %6, align 4, !tbaa !11
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i8, ptr %55, i64 %57
  %59 = load i8, ptr %58, align 1, !tbaa !15
  %60 = sext i8 %59 to i32
  %61 = icmp ne i32 %60, 10
  br label %62

62:                                               ; preds = %54, %46
  %63 = phi i1 [ false, %46 ], [ %61, %54 ]
  br i1 %63, label %64, label %81

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

81:                                               ; preds = %62
  %82 = load i32, ptr %4, align 4, !tbaa !11
  %83 = sitofp i32 %82 to float
  %84 = load float, ptr %5, align 4, !tbaa !13
  %85 = fadd float %84, %83
  store float %85, ptr %5, align 4, !tbaa !13
  %86 = load i8, ptr %3, align 1, !tbaa !9, !range !19, !noundef !20
  %87 = trunc i8 %86 to i1
  br i1 %87, label %88, label %91

88:                                               ; preds = %81
  %89 = load float, ptr %5, align 4, !tbaa !13
  %90 = fmul float %89, -1.000000e+00
  store float %90, ptr %5, align 4, !tbaa !13
  br label %91

91:                                               ; preds = %88, %81
  %92 = 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 %92
}

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

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

; Function Attrs: nounwind uwtable
define dso_local float @convert_string_to_float(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %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 %19 to float
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %1
  %.027.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 %22

.lr.ph:                                           ; preds = %1, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %4, %1 ]
  %9 = phi ptr [ %20, %.lr.ph ], [ %5, %1 ]
  %.02733 = phi i32 [ %19, %.lr.ph ], [ 0, %1 ]
  %10 = trunc i64 %indvars.iv to i32
  %11 = sub i32 7, %10
  %12 = tail call float @power(float noundef 1.000000e+01, i32 noundef %11) #3
  %13 = load i8, ptr %9, align 1, !tbaa !5
  %14 = sext i8 %13 to i32
  %15 = add nsw i32 %14, -48
  %16 = sitofp i32 %15 to float
  %17 = sitofp i32 %.02733 to float
  %18 = tail call float @llvm.fmuladd.f32(float %12, float %16, float %17)
  %19 = fptosi float %18 to i32
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %20 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %.not = icmp eq i8 %21, 46
  br i1 %.not, label %.preheader.loopexit, label %.lr.ph, !llvm.loop !8

22:                                               ; preds = %.preheader, %25
  %indvars.iv38 = phi i64 [ %8, %.preheader ], [ %indvars.iv.next39, %25 ]
  %.025 = phi float [ 0.000000e+00, %.preheader ], [ %31, %25 ]
  %.0 = phi i32 [ -1, %.preheader ], [ %32, %25 ]
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %23 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next39
  %24 = load i8, ptr %23, align 1, !tbaa !5
  switch i8 %24, label %25 [
    i8 32, label %.critedge
    i8 10, label %.critedge
  ]

25:                                               ; preds = %22
  %26 = tail call float @power(float noundef 1.000000e+01, i32 noundef %.0) #3
  %27 = load i8, ptr %23, align 1, !tbaa !5
  %28 = sext i8 %27 to i32
  %29 = add nsw i32 %28, -48
  %30 = sitofp i32 %29 to float
  %31 = tail call float @llvm.fmuladd.f32(float %26, float %30, float %.025)
  %32 = add nsw i32 %.0, -1
  br label %22, !llvm.loop !10

.critedge:                                        ; preds = %22, %22
  %33 = fadd float %.025, %.027.lcssa
  %34 = fneg float %33
  %.126 = select i1 %3, float %34, float %33
  ret float %.126
}

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

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