; LLVM IR from jgaeddert/liquid-dsp :: src/fft/src (spgramcf)

; 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.spgramcf_s = type { i32, i32, i32, i32, float, float, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, i64, i64, i64, i64, float, float }

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [81 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [50 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @spgramcf_set_alpha(ptr noundef %0, float noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  %6 = load float, ptr %5, align 4, !tbaa !9
  %7 = fcmp une float %6, -1.000000e+00
  br i1 %7, label %8, label %16

8:                                                ; preds = %2
  %9 = load float, ptr %5, align 4, !tbaa !9
  %10 = fcmp olt float %9, 0.000000e+00
  br i1 %10, label %14, label %11

11:                                               ; preds = %8
  %12 = load float, ptr %5, align 4, !tbaa !9
  %13 = fcmp ogt float %12, 1.000000e+00
  br i1 %13, label %14, label %16

14:                                               ; preds = %11, %8
  %15 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.8, i32 noundef 278, ptr noundef @.str.18, ptr noundef @.str.2)
  store i32 -1, ptr %3, align 4
  br label %43

16:                                               ; preds = %11, %2
  %17 = load float, ptr %5, align 4, !tbaa !9
  %18 = fcmp oeq float %17, -1.000000e+00
  %19 = zext i1 %18 to i64
  %20 = select i1 %18, i32 1, i32 0
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.spgramcf_s, ptr %21, i32 0, i32 6
  store i32 %20, ptr %22, align 8, !tbaa !11
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.spgramcf_s, ptr %23, i32 0, i32 6
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %32

27:                                               ; preds = %16
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.spgramcf_s, ptr %28, i32 0, i32 4
  store float 1.000000e+00, ptr %29, align 8, !tbaa !15
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.spgramcf_s, ptr %30, i32 0, i32 5
  store float 1.000000e+00, ptr %31, align 4, !tbaa !16
  br label %42

32:                                               ; preds = %16
  %33 = load float, ptr %5, align 4, !tbaa !9
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.spgramcf_s, ptr %34, i32 0, i32 4
  store float %33, ptr %35, align 8, !tbaa !15
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.spgramcf_s, ptr %36, i32 0, i32 4
  %38 = load float, ptr %37, align 8, !tbaa !15
  %39 = fsub float 1.000000e+00, %38
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.spgramcf_s, ptr %40, i32 0, i32 5
  store float %39, ptr %41, align 4, !tbaa !16
  br label %42

42:                                               ; preds = %32, %27
  store i32 0, ptr %3, align 4
  br label %43

43:                                               ; preds = %42, %14
  %44 = load i32, ptr %3, align 4
  ret i32 %44
}

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

!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 = !{!"float", !7, i64 0}
!11 = !{!12, !13, i64 24}
!12 = !{!"spgramcf_s", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !10, i64 16, !10, i64 20, !13, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !13, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !14, i64 112, !10, i64 120, !10, i64 124}
!13 = !{!"int", !7, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!12, !10, i64 16}
!16 = !{!12, !10, i64 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"

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [81 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [50 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 range(i32 -1, 1) i32 @spgramcf_set_alpha(ptr nocapture noundef writeonly %0, float noundef %1) local_unnamed_addr #1 {
  %3 = fcmp une float %1, -1.000000e+00
  br i1 %3, label %4, label %9

4:                                                ; preds = %2
  %5 = fcmp olt float %1, 0.000000e+00
  %6 = fcmp ogt float %1, 1.000000e+00
  %or.cond = or i1 %5, %6
  br i1 %or.cond, label %7, label %9

7:                                                ; preds = %4
  %8 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.8, i32 noundef 278, ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.2) #2
  br label %18

9:                                                ; preds = %4, %2
  %10 = fcmp oeq float %1, -1.000000e+00
  %11 = zext i1 %10 to i32
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %11, ptr %12, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  br i1 %10, label %14, label %15

14:                                               ; preds = %9
  store <2 x float> <float 1.000000e+00, float 1.000000e+00>, ptr %13, align 8, !tbaa !13
  br label %18

15:                                               ; preds = %9
  store float %1, ptr %13, align 8, !tbaa !14
  %16 = fsub float 1.000000e+00, %1
  %17 = getelementptr inbounds i8, ptr %0, i64 20
  store float %16, ptr %17, align 4, !tbaa !15
  br label %18

18:                                               ; preds = %14, %15, %7
  %.0 = phi i32 [ -1, %7 ], [ 0, %15 ], [ 0, %14 ]
  ret i32 %.0
}

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 = { 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 24}
!6 = !{!"spgramcf_s", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 20, !7, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !7, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !10, i64 120, !10, i64 124}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!10, !10, i64 0}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !10, i64 20}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass