; LLVM IR from kmilo17pet/qlibs :: qltisys (qLTISys_SetInitStates)

; 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._qLTISys_s = type { ptr, ptr, ptr, ptr, ptr, %struct.qTDL_t, float, float, float, float, i64, i64, i64, ptr }
%struct.qTDL_t = type { ptr, ptr, ptr, ptr, i64 }
%struct._qNumA_state_s = type { [3 x float] }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @qLTISys_IsInitialized(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 @qLTISys_SetInitStates(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca float, align 4
  %8 = alloca ptr, align 8
  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
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call i32 @qLTISys_IsInitialized(ptr noundef %9)
  %11 = icmp eq i32 1, %10
  br i1 %11, label %12, label %62

12:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %13

13:                                               ; preds = %58, %12
  %14 = load i64, ptr %6, align 8, !tbaa !11
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._qLTISys_s, ptr %15, i32 0, i32 10
  %17 = load i64, ptr %16, align 8, !tbaa !13
  %18 = icmp ult i64 %14, %17
  br i1 %18, label %19, label %61

19:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store float 0.000000e+00, ptr %7, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = icmp ne ptr null, %20
  br i1 %21, label %22, label %26

22:                                               ; preds = %19
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load i64, ptr %6, align 8, !tbaa !11
  %25 = getelementptr inbounds float, ptr %23, i64 %24
  br label %27

26:                                               ; preds = %19
  br label %27

27:                                               ; preds = %26, %22
  %28 = phi ptr [ %25, %22 ], [ %7, %26 ]
  store ptr %28, ptr %8, align 8, !tbaa !5
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._qLTISys_s, ptr %29, i32 0, i32 6
  %31 = load float, ptr %30, align 8, !tbaa !18
  %32 = fcmp ole float %31, 0.000000e+00
  br i1 %32, label %33, label %42

33:                                               ; preds = %27
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds float, ptr %34, i64 0
  %36 = load float, ptr %35, align 4, !tbaa !17
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._qLTISys_s, ptr %37, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !19
  %40 = load i64, ptr %6, align 8, !tbaa !11
  %41 = getelementptr inbounds float, ptr %39, i64 %40
  store float %36, ptr %41, align 4, !tbaa !17
  br label %57

42:                                               ; preds = %27
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._qLTISys_s, ptr %43, i32 0, i32 4
  %45 = load ptr, ptr %44, align 8, !tbaa !20
  %46 = load i64, ptr %6, align 8, !tbaa !11
  %47 = getelementptr inbounds %struct._qNumA_state_s, ptr %45, i64 %46
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds float, ptr %48, i64 0
  %50 = load float, ptr %49, align 4, !tbaa !17
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds float, ptr %51, i64 0
  %53 = load float, ptr %52, align 4, !tbaa !17
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds float, ptr %54, i64 0
  %56 = load float, ptr %55, align 4, !tbaa !17
  call void @qNumA_StateInit(ptr noundef %47, float noundef %50, float noundef %53, float noundef %56)
  br label %57

57:                                               ; preds = %42, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %58

58:                                               ; preds = %57
  %59 = load i64, ptr %6, align 8, !tbaa !11
  %60 = add i64 %59, 1
  store i64 %60, ptr %6, align 8, !tbaa !11
  br label %13, !llvm.loop !21

61:                                               ; preds = %13
  store i32 1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %62

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

declare void @qNumA_StateInit(ptr noundef, float noundef, float noundef, 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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 96}
!14 = !{!"_qLTISys_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !15, i64 40, !16, i64 80, !16, i64 84, !16, i64 88, !16, i64 92, !12, i64 96, !12, i64 104, !12, i64 112, !6, i64 120}
!15 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32}
!16 = !{!"float", !7, i64 0}
!17 = !{!16, !16, i64 0}
!18 = !{!14, !16, i64 80}
!19 = !{!14, !6, i64 24}
!20 = !{!14, !6, i64 32}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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

%struct._qNumA_state_s = type { [3 x float] }

; Function Attrs: nounwind uwtable
declare dso_local i32 @qLTISys_IsInitialized(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @qLTISys_SetInitStates(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  %3 = tail call i32 @qLTISys_IsInitialized(ptr noundef %0)
  %4 = icmp eq i32 %3, 1
  br i1 %4, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 96
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %.not22 = icmp eq i64 %6, 0
  br i1 %.not22, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %.not = icmp eq ptr %1, null
  %7 = getelementptr inbounds i8, ptr %0, i64 80
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  br i1 %.not, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %17
  %10 = phi i64 [ %18, %17 ], [ %6, %.lr.ph ]
  %.01621.us = phi i64 [ %19, %17 ], [ 0, %.lr.ph ]
  %11 = load float, ptr %7, align 8, !tbaa !13
  %12 = fcmp ugt float %11, 0.000000e+00
  br i1 %12, label %.cont.us, label %.cont17.us

.cont17.us:                                       ; preds = %.lr.ph.split.us
  %13 = load ptr, ptr %8, align 8, !tbaa !14
  %14 = getelementptr inbounds float, ptr %13, i64 %.01621.us
  store float 0.000000e+00, ptr %14, align 4, !tbaa !15
  br label %17

.cont.us:                                         ; preds = %.lr.ph.split.us
  %15 = load ptr, ptr %9, align 8, !tbaa !16
  %16 = getelementptr inbounds %struct._qNumA_state_s, ptr %15, i64 %.01621.us
  tail call void @qNumA_StateInit(ptr noundef %16, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00) #2
  %.pre24 = load i64, ptr %5, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %.cont.us, %.cont17.us
  %18 = phi i64 [ %.pre24, %.cont.us ], [ %10, %.cont17.us ]
  %19 = add nuw i64 %.01621.us, 1
  %20 = icmp ult i64 %19, %18
  br i1 %20, label %.lr.ph.split.us, label %.loopexit, !llvm.loop !17

.lr.ph.split:                                     ; preds = %.lr.ph, %29
  %21 = phi i64 [ %30, %29 ], [ %6, %.lr.ph ]
  %.01621 = phi i64 [ %31, %29 ], [ 0, %.lr.ph ]
  %22 = getelementptr inbounds float, ptr %1, i64 %.01621
  %23 = load float, ptr %7, align 8, !tbaa !13
  %24 = fcmp ugt float %23, 0.000000e+00
  br i1 %24, label %.else, label %.else19

.else19:                                          ; preds = %.lr.ph.split
  %.else.val20 = load float, ptr %22, align 4, !tbaa !15
  %25 = load ptr, ptr %8, align 8, !tbaa !14
  %26 = getelementptr inbounds float, ptr %25, i64 %.01621
  store float %.else.val20, ptr %26, align 4, !tbaa !15
  br label %29

.else:                                            ; preds = %.lr.ph.split
  %27 = load ptr, ptr %9, align 8, !tbaa !16
  %28 = getelementptr inbounds %struct._qNumA_state_s, ptr %27, i64 %.01621
  %.else.val = load float, ptr %22, align 4, !tbaa !15
  tail call void @qNumA_StateInit(ptr noundef %28, float noundef %.else.val, float noundef %.else.val, float noundef %.else.val) #2
  %.pre = load i64, ptr %5, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %.else, %.else19
  %30 = phi i64 [ %.pre, %.else ], [ %21, %.else19 ]
  %31 = add nuw i64 %.01621, 1
  %32 = icmp ult i64 %31, %30
  br i1 %32, label %.lr.ph.split, label %.loopexit, !llvm.loop !17

.loopexit:                                        ; preds = %29, %17, %.preheader, %2
  %.0 = phi i32 [ 0, %2 ], [ 1, %.preheader ], [ 1, %17 ], [ 1, %29 ]
  ret i32 %.0
}

declare void @qNumA_StateInit(ptr noundef, float noundef, float noundef, 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, !11, i64 96}
!6 = !{!"_qLTISys_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !11, i64 96, !11, i64 104, !11, i64 112, !7, i64 120}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !11, i64 32}
!11 = !{!"long", !8, i64 0}
!12 = !{!"float", !8, i64 0}
!13 = !{!6, !12, i64 80}
!14 = !{!6, !7, i64 24}
!15 = !{!12, !12, i64 0}
!16 = !{!6, !7, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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