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

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

@.str = external hidden unnamed_addr constant [79 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [76 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

declare ptr @chromosome_create_clone(ptr noundef) #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 i32 @gasearch_set_population_size(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %10 = load i32, ptr %6, align 4, !tbaa !9
  %11 = icmp ult i32 %10, 2
  br i1 %11, label %12, label %14

12:                                               ; preds = %3
  %13 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 164, ptr noundef @.str.13)
  store i32 %13, ptr %4, align 4
  br label %105

14:                                               ; preds = %3
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = icmp ugt i32 %15, 1024
  br i1 %16, label %17, label %19

17:                                               ; preds = %14
  %18 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 166, ptr noundef @.str.14, i32 noundef 1024)
  store i32 %18, ptr %4, align 4
  br label %105

19:                                               ; preds = %14
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %19
  %23 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 168, ptr noundef @.str.15)
  store i32 %23, ptr %4, align 4
  br label %105

24:                                               ; preds = %19
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = icmp uge i32 %25, %26
  br i1 %27, label %28, label %30

28:                                               ; preds = %24
  %29 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 170, ptr noundef @.str.16)
  store i32 %29, ptr %4, align 4
  br label %105

30:                                               ; preds = %24
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.gasearch_s, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = zext i32 %34 to i64
  %36 = mul i64 %35, 8
  %37 = call ptr @realloc(ptr noundef %33, i64 noundef %36) #4
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.gasearch_s, ptr %38, i32 0, i32 0
  store ptr %37, ptr %39, align 8, !tbaa !11
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.gasearch_s, ptr %40, i32 0, i32 6
  %42 = load ptr, ptr %41, align 8, !tbaa !14
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = mul i64 %44, 4
  %46 = call ptr @realloc(ptr noundef %42, i64 noundef %45) #4
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.gasearch_s, ptr %47, i32 0, i32 6
  store ptr %46, ptr %48, align 8, !tbaa !14
  %49 = load i32, ptr %6, align 4, !tbaa !9
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.gasearch_s, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 8, !tbaa !15
  %53 = icmp ugt i32 %49, %52
  br i1 %53, label %54, label %98

54:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.gasearch_s, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 8, !tbaa !15
  %58 = sub i32 %57, 1
  store i32 %58, ptr %9, align 4, !tbaa !9
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.gasearch_s, ptr %59, i32 0, i32 1
  %61 = load i32, ptr %60, align 8, !tbaa !15
  store i32 %61, ptr %8, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %94, %54
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = icmp ult i32 %63, %64
  br i1 %65, label %66, label %97

66:                                               ; preds = %62
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.gasearch_s, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !11
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds ptr, ptr %69, i64 %71
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = call ptr @chromosome_create_clone(ptr noundef %73)
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.gasearch_s, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !11
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = zext i32 %78 to i64
  %80 = getelementptr inbounds ptr, ptr %77, i64 %79
  store ptr %74, ptr %80, align 8, !tbaa !5
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.gasearch_s, ptr %81, i32 0, i32 6
  %83 = load ptr, ptr %82, align 8, !tbaa !14
  %84 = load i32, ptr %9, align 4, !tbaa !9
  %85 = zext i32 %84 to i64
  %86 = getelementptr inbounds float, ptr %83, i64 %85
  %87 = load float, ptr %86, align 4, !tbaa !16
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.gasearch_s, ptr %88, i32 0, i32 6
  %90 = load ptr, ptr %89, align 8, !tbaa !14
  %91 = load i32, ptr %8, align 4, !tbaa !9
  %92 = zext i32 %91 to i64
  %93 = getelementptr inbounds float, ptr %90, i64 %92
  store float %87, ptr %93, align 4, !tbaa !16
  br label %94

94:                                               ; preds = %66
  %95 = load i32, ptr %8, align 4, !tbaa !9
  %96 = add i32 %95, 1
  store i32 %96, ptr %8, align 4, !tbaa !9
  br label %62, !llvm.loop !17

97:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %98

98:                                               ; preds = %97, %30
  %99 = load i32, ptr %6, align 4, !tbaa !9
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.gasearch_s, ptr %100, i32 0, i32 1
  store i32 %99, ptr %101, align 8, !tbaa !15
  %102 = load i32, ptr %7, align 4, !tbaa !9
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.gasearch_s, ptr %103, i32 0, i32 2
  store i32 %102, ptr %104, align 4, !tbaa !19
  store i32 0, ptr %4, align 4
  br label %105

105:                                              ; preds = %98, %28, %22, %17, %12
  %106 = load i32, ptr %4, align 4
  ret i32 %106
}

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

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #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 = { nounwind allocsize(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 #4 = { nounwind allocsize(1) }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"gasearch_s", !6, i64 0, !10, i64 8, !10, i64 12, !13, i64 16, !10, i64 20, !10, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !13, i64 56, !6, i64 64, !6, i64 72, !10, i64 80}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !6, i64 32}
!15 = !{!12, !10, i64 8}
!16 = !{!13, !13, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!12, !10, i64 12}


; 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 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [76 x i8], align 1

declare ptr @chromosome_create_clone(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @gasearch_set_population_size(ptr nocapture noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = icmp ult i32 %1, 2
  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, i32 noundef 164, ptr noundef nonnull @.str.13) #3
  br label %46

7:                                                ; preds = %3
  %8 = icmp ugt i32 %1, 1024
  br i1 %8, label %9, label %11

9:                                                ; preds = %7
  %10 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 166, ptr noundef nonnull @.str.14, i32 noundef 1024) #3
  br label %46

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

13:                                               ; preds = %11
  %14 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 168, ptr noundef nonnull @.str.15) #3
  br label %46

15:                                               ; preds = %11
  %.not = icmp ult i32 %2, %1
  br i1 %.not, label %18, label %16

16:                                               ; preds = %15
  %17 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 170, ptr noundef nonnull @.str.16) #3
  br label %46

18:                                               ; preds = %15
  %19 = load ptr, ptr %0, align 8, !tbaa !5
  %20 = zext nneg i32 %1 to i64
  %21 = shl nuw nsw i64 %20, 3
  %22 = tail call ptr @realloc(ptr noundef %19, i64 noundef %21) #4
  store ptr %22, ptr %0, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %0, i64 32
  %24 = load ptr, ptr %23, align 8, !tbaa !12
  %25 = shl nuw nsw i64 %20, 2
  %26 = tail call ptr @realloc(ptr noundef %24, i64 noundef %25) #4
  store ptr %26, ptr %23, align 8, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  %28 = load i32, ptr %27, align 8, !tbaa !13
  %29 = icmp ult i32 %28, %1
  br i1 %29, label %30, label %.loopexit

30:                                               ; preds = %18
  %31 = add nsw i32 %28, -1
  %32 = zext i32 %31 to i64
  %33 = zext nneg i32 %28 to i64
  br label %34

34:                                               ; preds = %30, %34
  %indvars.iv = phi i64 [ %33, %30 ], [ %indvars.iv.next, %34 ]
  %35 = load ptr, ptr %0, align 8, !tbaa !5
  %36 = getelementptr inbounds ptr, ptr %35, i64 %32
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  %38 = tail call ptr @chromosome_create_clone(ptr noundef %37) #3
  %39 = load ptr, ptr %0, align 8, !tbaa !5
  %40 = getelementptr inbounds ptr, ptr %39, i64 %indvars.iv
  store ptr %38, ptr %40, align 8, !tbaa !14
  %41 = load ptr, ptr %23, align 8, !tbaa !12
  %42 = getelementptr inbounds float, ptr %41, i64 %32
  %43 = load float, ptr %42, align 4, !tbaa !15
  %44 = getelementptr inbounds float, ptr %41, i64 %indvars.iv
  store float %43, ptr %44, align 4, !tbaa !15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %lftr.wideiv, %1
  br i1 %exitcond.not, label %.loopexit, label %34, !llvm.loop !16

.loopexit:                                        ; preds = %34, %18
  store i32 %1, ptr %27, align 8, !tbaa !13
  %45 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %2, ptr %45, align 4, !tbaa !18
  br label %46

46:                                               ; preds = %.loopexit, %16, %13, %9, %5
  %.0 = phi i32 [ %6, %5 ], [ %10, %9 ], [ %14, %13 ], [ %17, %16 ], [ 0, %.loopexit ]
  ret i32 %.0
}

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

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #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 nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 }
attributes #4 = { nounwind allocsize(1) }

!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 = !{!"gasearch_s", !7, i64 0, !10, i64 8, !10, i64 12, !11, i64 16, !10, i64 20, !10, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !11, i64 56, !7, i64 64, !7, i64 72, !10, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !7, i64 32}
!13 = !{!6, !10, i64 8}
!14 = !{!7, !7, i64 0}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !10, i64 12}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass