; LLVM IR from jgaeddert/liquid-dsp :: src/optim/src (qs1dsearch)

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

; 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

; Function Attrs: nounwind uwtable
define dso_local i32 @qs1dsearch_init(ptr noundef %0, float noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store float 0x3C9CD2B2A0000000, ptr %6, align 4, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = load float, ptr %5, align 4, !tbaa !9
  %10 = load float, ptr %6, align 4, !tbaa !9
  %11 = call i32 @qs1dsearch_init_direction(ptr noundef %8, float noundef %9, float noundef %10)
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %14

13:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %117

14:                                               ; preds = %2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load float, ptr %5, align 4, !tbaa !9
  %17 = load float, ptr %6, align 4, !tbaa !9
  %18 = fneg float %17
  %19 = call i32 @qs1dsearch_init_direction(ptr noundef %15, float noundef %16, float noundef %18)
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %14
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %117

22:                                               ; preds = %14
  %23 = load float, ptr %5, align 4, !tbaa !9
  %24 = load float, ptr %6, align 4, !tbaa !9
  %25 = fsub float %23, %24
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.qs1dsearch_s, ptr %26, i32 0, i32 0
  store float %25, ptr %27, align 8, !tbaa !11
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.qs1dsearch_s, ptr %28, i32 0, i32 11
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.qs1dsearch_s, ptr %31, i32 0, i32 0
  %33 = load float, ptr %32, align 8, !tbaa !11
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.qs1dsearch_s, ptr %34, i32 0, i32 12
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = call float %30(float noundef %33, ptr noundef %36)
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.qs1dsearch_s, ptr %38, i32 0, i32 5
  store float %37, ptr %39, align 4, !tbaa !16
  %40 = load float, ptr %5, align 4, !tbaa !9
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.qs1dsearch_s, ptr %41, i32 0, i32 2
  store float %40, ptr %42, align 8, !tbaa !17
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.qs1dsearch_s, ptr %43, i32 0, i32 11
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.qs1dsearch_s, ptr %46, i32 0, i32 2
  %48 = load float, ptr %47, align 8, !tbaa !17
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.qs1dsearch_s, ptr %49, i32 0, i32 12
  %51 = load ptr, ptr %50, align 8, !tbaa !15
  %52 = call float %45(float noundef %48, ptr noundef %51)
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.qs1dsearch_s, ptr %53, i32 0, i32 7
  store float %52, ptr %54, align 4, !tbaa !18
  %55 = load float, ptr %5, align 4, !tbaa !9
  %56 = load float, ptr %6, align 4, !tbaa !9
  %57 = fadd float %55, %56
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.qs1dsearch_s, ptr %58, i32 0, i32 4
  store float %57, ptr %59, align 8, !tbaa !19
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.qs1dsearch_s, ptr %60, i32 0, i32 11
  %62 = load ptr, ptr %61, align 8, !tbaa !14
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.qs1dsearch_s, ptr %63, i32 0, i32 4
  %65 = load float, ptr %64, align 8, !tbaa !19
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.qs1dsearch_s, ptr %66, i32 0, i32 12
  %68 = load ptr, ptr %67, align 8, !tbaa !15
  %69 = call float %62(float noundef %65, ptr noundef %68)
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.qs1dsearch_s, ptr %70, i32 0, i32 9
  store float %69, ptr %71, align 4, !tbaa !20
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.qs1dsearch_s, ptr %72, i32 0, i32 13
  %74 = load i32, ptr %73, align 8, !tbaa !21
  %75 = icmp eq i32 %74, 0
  br i1 %75, label %76, label %92

76:                                               ; preds = %22
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.qs1dsearch_s, ptr %77, i32 0, i32 7
  %79 = load float, ptr %78, align 4, !tbaa !18
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.qs1dsearch_s, ptr %80, i32 0, i32 5
  %82 = load float, ptr %81, align 4, !tbaa !16
  %83 = fcmp olt float %79, %82
  br i1 %83, label %84, label %92

84:                                               ; preds = %76
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.qs1dsearch_s, ptr %85, i32 0, i32 7
  %87 = load float, ptr %86, align 4, !tbaa !18
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.qs1dsearch_s, ptr %88, i32 0, i32 9
  %90 = load float, ptr %89, align 4, !tbaa !20
  %91 = fcmp olt float %87, %90
  br i1 %91, label %113, label %92

92:                                               ; preds = %84, %76, %22
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.qs1dsearch_s, ptr %93, i32 0, i32 13
  %95 = load i32, ptr %94, align 8, !tbaa !21
  %96 = icmp eq i32 %95, 1
  br i1 %96, label %97, label %116

97:                                               ; preds = %92
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.qs1dsearch_s, ptr %98, i32 0, i32 7
  %100 = load float, ptr %99, align 4, !tbaa !18
  %101 = load ptr, ptr %4, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.qs1dsearch_s, ptr %101, i32 0, i32 5
  %103 = load float, ptr %102, align 4, !tbaa !16
  %104 = fcmp ogt float %100, %103
  br i1 %104, label %105, label %116

105:                                              ; preds = %97
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.qs1dsearch_s, ptr %106, i32 0, i32 7
  %108 = load float, ptr %107, align 4, !tbaa !18
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.qs1dsearch_s, ptr %109, i32 0, i32 9
  %111 = load float, ptr %110, align 4, !tbaa !20
  %112 = fcmp ogt float %108, %111
  br i1 %112, label %113, label %116

113:                                              ; preds = %105, %84
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.qs1dsearch_s, ptr %114, i32 0, i32 10
  store i32 1, ptr %115, align 8, !tbaa !22
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %117

116:                                              ; preds = %105, %97, %92
  store i32 4, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %117

117:                                              ; preds = %116, %113, %21, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %118 = load i32, ptr %3, align 4
  ret i32 %118
}

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

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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"qs1dsearch_s", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !13, i64 40, !6, i64 48, !6, i64 56, !13, i64 64, !13, i64 68}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 48}
!15 = !{!12, !6, i64 56}
!16 = !{!12, !10, i64 20}
!17 = !{!12, !10, i64 8}
!18 = !{!12, !10, i64 28}
!19 = !{!12, !10, i64 16}
!20 = !{!12, !10, i64 36}
!21 = !{!12, !13, i64 64}
!22 = !{!12, !13, i64 40}


; 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
define dso_local range(i32 0, 5) i32 @qs1dsearch_init(ptr noundef %0, float noundef %1) local_unnamed_addr #0 {
  %3 = tail call i32 @qs1dsearch_init_direction(ptr noundef %0, float noundef %1, float noundef 0x3C9CD2B2A0000000)
  %4 = icmp eq i32 %3, 0
  br i1 %4, label %.thread, label %5

5:                                                ; preds = %2
  %6 = tail call i32 @qs1dsearch_init_direction(ptr noundef %0, float noundef %1, float noundef 0xBC9CD2B2A0000000)
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %.thread, label %8

8:                                                ; preds = %5
  %9 = fadd float %1, 0xBC9CD2B2A0000000
  store float %9, ptr %0, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 48
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %0, i64 56
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = tail call float %11(float noundef %9, ptr noundef %13) #1
  %15 = getelementptr inbounds i8, ptr %0, i64 20
  store float %14, ptr %15, align 4, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  store float %1, ptr %16, align 8, !tbaa !15
  %17 = load ptr, ptr %10, align 8, !tbaa !12
  %18 = load ptr, ptr %12, align 8, !tbaa !13
  %19 = tail call float %17(float noundef %1, ptr noundef %18) #1
  %20 = getelementptr inbounds i8, ptr %0, i64 28
  store float %19, ptr %20, align 4, !tbaa !16
  %21 = fadd float %1, 0x3C9CD2B2A0000000
  %22 = getelementptr inbounds i8, ptr %0, i64 16
  store float %21, ptr %22, align 8, !tbaa !17
  %23 = load ptr, ptr %10, align 8, !tbaa !12
  %24 = load ptr, ptr %12, align 8, !tbaa !13
  %25 = tail call float %23(float noundef %21, ptr noundef %24) #1
  %26 = getelementptr inbounds i8, ptr %0, i64 36
  store float %25, ptr %26, align 4, !tbaa !18
  %27 = getelementptr inbounds i8, ptr %0, i64 64
  %28 = load i32, ptr %27, align 8, !tbaa !19
  switch i32 %28, label %.thread [
    i32 0, label %29
    i32 1, label %34
  ]

29:                                               ; preds = %8
  %30 = load float, ptr %20, align 4, !tbaa !16
  %31 = load float, ptr %15, align 4, !tbaa !14
  %32 = fcmp olt float %30, %31
  %33 = fcmp olt float %30, %25
  %or.cond = select i1 %32, i1 %33, i1 false
  br i1 %or.cond, label %39, label %.thread

34:                                               ; preds = %8
  %35 = load float, ptr %20, align 4, !tbaa !16
  %36 = load float, ptr %15, align 4, !tbaa !14
  %37 = fcmp ogt float %35, %36
  %38 = fcmp ogt float %35, %25
  %or.cond39 = select i1 %37, i1 %38, i1 false
  br i1 %or.cond39, label %39, label %.thread

39:                                               ; preds = %34, %29
  %40 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 1, ptr %40, align 8, !tbaa !20
  br label %.thread

.thread:                                          ; preds = %8, %29, %34, %5, %2, %39
  %.0 = phi i32 [ 0, %39 ], [ 0, %2 ], [ 0, %5 ], [ 4, %34 ], [ 4, %29 ], [ 4, %8 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @qs1dsearch_init_direction(ptr noundef, float noundef, float noundef) local_unnamed_addr #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 0}
!6 = !{!"qs1dsearch_s", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !10, i64 40, !11, i64 48, !11, i64 56, !10, i64 64, !10, i64 68}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !11, i64 48}
!13 = !{!6, !11, i64 56}
!14 = !{!6, !7, i64 20}
!15 = !{!6, !7, i64 8}
!16 = !{!6, !7, i64 28}
!17 = !{!6, !7, i64 16}
!18 = !{!6, !7, i64 36}
!19 = !{!6, !10, i64 64}
!20 = !{!6, !10, i64 40}


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