; LLVM IR from jgaeddert/liquid-dsp :: src/math/src (windows)

; 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"

@.str.23 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [58 x i8], align 1

; 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

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local float @liquid_triangular(i32 noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  %10 = load i32, ptr %5, align 4, !tbaa !5
  %11 = load i32, ptr %6, align 4, !tbaa !5
  %12 = icmp ugt i32 %10, %11
  br i1 %12, label %13, label %15

13:                                               ; preds = %3
  %14 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.23, i32 noundef 332, ptr noundef @.str.39)
  store float 0.000000e+00, ptr %4, align 4
  br label %56

15:                                               ; preds = %3
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = sub i32 %17, 1
  %19 = icmp ne i32 %16, %18
  br i1 %19, label %20, label %31

20:                                               ; preds = %15
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = icmp ne i32 %21, %22
  br i1 %23, label %24, label %31

24:                                               ; preds = %20
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = add i32 %26, 1
  %28 = icmp ne i32 %25, %27
  br i1 %28, label %29, label %31

29:                                               ; preds = %24
  %30 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.23, i32 noundef 335, ptr noundef @.str.40)
  store float 0.000000e+00, ptr %4, align 4
  br label %56

31:                                               ; preds = %24, %20, %15
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %36

34:                                               ; preds = %31
  %35 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.23, i32 noundef 338, ptr noundef @.str.41)
  store float 0.000000e+00, ptr %4, align 4
  br label %56

36:                                               ; preds = %31
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = uitofp i32 %39 to float
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = sub i32 %41, 1
  %43 = uitofp i32 %42 to float
  %44 = fdiv float %43, 2.000000e+00
  %45 = fsub float %40, %44
  store float %45, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %46 = load i32, ptr %7, align 4, !tbaa !5
  %47 = uitofp i32 %46 to float
  %48 = fdiv float %47, 2.000000e+00
  store float %48, ptr %9, align 4, !tbaa !9
  %49 = load float, ptr %8, align 4, !tbaa !9
  %50 = load float, ptr %9, align 4, !tbaa !9
  %51 = fdiv float %49, %50
  %52 = call float @llvm.fabs.f32(float %51)
  %53 = fpext float %52 to double
  %54 = fsub double 1.000000e+00, %53
  %55 = fptrunc double %54 to float
  store float %55, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %56

56:                                               ; preds = %38, %34, %29, %13
  %57 = load float, ptr %4, align 4
  ret float %57
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}


; 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"

@.str.23 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [58 x i8], align 1

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local float @liquid_triangular(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = icmp ugt i32 %0, %1
  br i1 %4, label %5, label %7

5:                                                ; preds = %3
  %6 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.23, i32 noundef 332, ptr noundef nonnull @.str.39) #3
  br label %26

7:                                                ; preds = %3
  %8 = add i32 %1, -1
  %.not = icmp eq i32 %8, %2
  %.not17 = icmp eq i32 %2, %1
  %or.cond = or i1 %.not, %.not17
  %9 = add i32 %1, 1
  %.not18 = icmp eq i32 %9, %2
  %or.cond19 = or i1 %.not18, %or.cond
  br i1 %or.cond19, label %12, label %10

10:                                               ; preds = %7
  %11 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.23, i32 noundef 335, ptr noundef nonnull @.str.40) #3
  br label %26

12:                                               ; preds = %7
  %13 = icmp eq i32 %2, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %12
  %15 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.23, i32 noundef 338, ptr noundef nonnull @.str.41) #3
  br label %26

16:                                               ; preds = %12
  %17 = uitofp i32 %0 to float
  %18 = uitofp i32 %8 to float
  %19 = fmul float %18, 5.000000e-01
  %20 = fsub float %17, %19
  %21 = uitofp i32 %2 to float
  %22 = fmul float %21, 5.000000e-01
  %23 = fdiv float %20, %22
  %24 = tail call float @llvm.fabs.f32(float %23)
  %25 = fsub float 1.000000e+00, %24
  br label %26

26:                                               ; preds = %16, %14, %10, %5
  %.0 = phi float [ 0.000000e+00, %5 ], [ 0.000000e+00, %10 ], [ 0.000000e+00, %14 ], [ %25, %16 ]
  ret float %.0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #2

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass