; LLVM IR from kmilo17pet/qlibs :: qpid (qPID_BindAutoTuning)

; 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.qPID_controller_t = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, ptr, float, float, %struct._qNumA_state_s, %struct._qNumA_state_s, %struct._qNumA_state_s, ptr, ptr, i32, i32, i32, i8 }
%struct._qNumA_state_s = type { [3 x float] }
%struct.qPID_AutoTuning_t = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, 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 @qPID_BindAutoTuning(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = icmp ne ptr null, %8
  br i1 %9, label %10, label %87

10:                                               ; preds = %2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.qPID_controller_t, ptr %11, i32 0, i32 28
  %13 = load i8, ptr %12, align 4, !tbaa !11
  %14 = zext i8 %13 to i32
  %15 = icmp ne i32 0, %14
  br i1 %15, label %16, label %87

16:                                               ; preds = %10
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = icmp ne ptr null, %17
  br i1 %18, label %19, label %83

19:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.qPID_controller_t, ptr %21, i32 0, i32 23
  store ptr %20, ptr %22, align 8, !tbaa !15
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %23, i32 0, i32 8
  store float 0x3FEFAC7100000000, ptr %24, align 4, !tbaa !16
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %25, i32 0, i32 8
  %27 = load float, ptr %26, align 4, !tbaa !16
  %28 = fdiv float 1.000000e+00, %27
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %29, i32 0, i32 9
  store float %28, ptr %30, align 4, !tbaa !18
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %31, i32 0, i32 0
  store float 1.000000e+03, ptr %32, align 4, !tbaa !19
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %33, i32 0, i32 3
  store float 1.000000e+03, ptr %34, align 4, !tbaa !20
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %35, i32 0, i32 1
  store float 0.000000e+00, ptr %36, align 4, !tbaa !21
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %37, i32 0, i32 2
  store float 0.000000e+00, ptr %38, align 4, !tbaa !22
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %39, i32 0, i32 6
  store float 0.000000e+00, ptr %40, align 4, !tbaa !23
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %41, i32 0, i32 7
  store float 0.000000e+00, ptr %42, align 4, !tbaa !24
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %43, i32 0, i32 10
  store float 0.000000e+00, ptr %44, align 4, !tbaa !25
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %45, i32 0, i32 11
  store float 0.000000e+00, ptr %46, align 4, !tbaa !26
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %47, i32 0, i32 14
  store i32 100, ptr %48, align 4, !tbaa !27
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %49, i32 0, i32 12
  store float 0x3FEE666660000000, ptr %50, align 4, !tbaa !28
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.qPID_controller_t, ptr %51, i32 0, i32 0
  %53 = load float, ptr %52, align 8, !tbaa !29
  %54 = fdiv float %53, 0x3FECCCCCC0000000
  store float %54, ptr %6, align 4, !tbaa !30
  %55 = load float, ptr %6, align 4, !tbaa !30
  %56 = fmul float 0x3FD147AE20000000, %55
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.qPID_controller_t, ptr %57, i32 0, i32 1
  %59 = load float, ptr %58, align 4, !tbaa !31
  %60 = fdiv float %56, %59
  store float %60, ptr %7, align 4, !tbaa !30
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.qPID_controller_t, ptr %61, i32 0, i32 5
  %63 = load float, ptr %62, align 4, !tbaa !32
  %64 = fneg float %63
  %65 = load float, ptr %7, align 4, !tbaa !30
  %66 = fdiv float %64, %65
  %67 = call float @qFFMath_Exp(float noundef %66)
  %68 = fneg float %67
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %69, i32 0, i32 5
  store float %68, ptr %70, align 4, !tbaa !33
  %71 = load float, ptr %6, align 4, !tbaa !30
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %72, i32 0, i32 5
  %74 = load float, ptr %73, align 4, !tbaa !33
  %75 = fadd float 1.000000e+00, %74
  %76 = fmul float %71, %75
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %77, i32 0, i32 4
  store float %76, ptr %78, align 4, !tbaa !34
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %79, i32 0, i32 13
  store float 2.500000e-01, ptr %80, align 4, !tbaa !35
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.qPID_AutoTuning_t, ptr %81, i32 0, i32 14
  store i32 -2, ptr %82, align 4, !tbaa !27
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %86

83:                                               ; preds = %16
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.qPID_controller_t, ptr %84, i32 0, i32 23
  store ptr null, ptr %85, align 8, !tbaa !15
  br label %86

86:                                               ; preds = %83, %19
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %87

87:                                               ; preds = %86, %10, %2
  %88 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %88
}

declare float @qFFMath_Exp(float noundef) #2

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 = { "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 = !{!"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, !7, i64 156}
!12 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !13, i64 56, !13, i64 60, !13, i64 64, !6, i64 72, !13, i64 80, !13, i64 84, !14, i64 88, !14, i64 100, !14, i64 112, !6, i64 128, !6, i64 136, !10, i64 144, !10, i64 148, !10, i64 152, !7, i64 156}
!13 = !{!"float", !7, i64 0}
!14 = !{!"_qNumA_state_s", !7, i64 0}
!15 = !{!12, !6, i64 128}
!16 = !{!17, !13, i64 32}
!17 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !10, i64 56}
!18 = !{!17, !13, i64 36}
!19 = !{!17, !13, i64 0}
!20 = !{!17, !13, i64 12}
!21 = !{!17, !13, i64 4}
!22 = !{!17, !13, i64 8}
!23 = !{!17, !13, i64 24}
!24 = !{!17, !13, i64 28}
!25 = !{!17, !13, i64 40}
!26 = !{!17, !13, i64 44}
!27 = !{!17, !10, i64 56}
!28 = !{!17, !13, i64 48}
!29 = !{!12, !13, i64 0}
!30 = !{!13, !13, i64 0}
!31 = !{!12, !13, i64 4}
!32 = !{!12, !13, i64 20}
!33 = !{!17, !13, i64 20}
!34 = !{!17, !13, i64 16}
!35 = !{!17, !13, i64 52}


; 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, 2) i32 @qPID_BindAutoTuning(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %31, label %3

3:                                                ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 156
  %5 = load i8, ptr %4, align 4, !tbaa !5
  %.not32 = icmp eq i8 %5, 0
  br i1 %.not32, label %31, label %6

6:                                                ; preds = %3
  %.not33 = icmp eq ptr %1, null
  %7 = getelementptr inbounds i8, ptr %0, i64 128
  br i1 %.not33, label %30, label %8

8:                                                ; preds = %6
  store ptr %1, ptr %7, align 8, !tbaa !13
  store <4 x float> <float 1.000000e+03, float 0.000000e+00, float 0.000000e+00, float 1.000000e+03>, ptr %1, align 4, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %1, i64 24
  store <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0x3FEFAC7100000000, float 0x3FF02A35C0000000>, ptr %9, align 4, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %1, i64 40
  store <2 x float> zeroinitializer, ptr %10, align 4, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %1, i64 56
  store i32 100, ptr %11, align 4, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %1, i64 48
  store float 0x3FEE666660000000, ptr %12, align 4, !tbaa !17
  %13 = load float, ptr %0, align 8, !tbaa !18
  %14 = fdiv float %13, 0x3FECCCCCC0000000
  %15 = fmul float %14, 0x3FD147AE20000000
  %16 = getelementptr inbounds i8, ptr %0, i64 4
  %17 = load float, ptr %16, align 4, !tbaa !19
  %18 = fdiv float %15, %17
  %19 = getelementptr inbounds i8, ptr %0, i64 20
  %20 = load float, ptr %19, align 4, !tbaa !20
  %21 = fneg float %20
  %22 = fdiv float %21, %18
  %23 = tail call float @qFFMath_Exp(float noundef %22) #2
  %24 = fneg float %23
  %25 = getelementptr inbounds i8, ptr %1, i64 20
  store float %24, ptr %25, align 4, !tbaa !21
  %26 = fsub float 1.000000e+00, %23
  %27 = fmul float %14, %26
  %28 = getelementptr inbounds i8, ptr %1, i64 16
  store float %27, ptr %28, align 4, !tbaa !22
  %29 = getelementptr inbounds i8, ptr %1, i64 52
  store float 2.500000e-01, ptr %29, align 4, !tbaa !23
  store i32 -2, ptr %11, align 4, !tbaa !15
  br label %31

30:                                               ; preds = %6
  store ptr null, ptr %7, align 8, !tbaa !13
  br label %31

31:                                               ; preds = %8, %30, %3, %2
  %.0 = phi i32 [ 0, %3 ], [ 0, %2 ], [ 1, %30 ], [ 1, %8 ]
  ret i32 %.0
}

declare float @qFFMath_Exp(float noundef) local_unnamed_addr #1

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 = { "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, !8, i64 156}
!6 = !{!"", !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, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !10, i64 72, !7, i64 80, !7, i64 84, !11, i64 88, !11, i64 100, !11, i64 112, !10, i64 128, !10, i64 136, !12, i64 144, !12, i64 148, !12, i64 152, !8, i64 156}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_qNumA_state_s", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!6, !10, i64 128}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !12, i64 56}
!16 = !{!"", !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, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !12, i64 56}
!17 = !{!16, !7, i64 48}
!18 = !{!6, !7, i64 0}
!19 = !{!6, !7, i64 4}
!20 = !{!6, !7, i64 20}
!21 = !{!16, !7, i64 20}
!22 = !{!16, !7, i64 16}
!23 = !{!16, !7, i64 52}


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