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

; 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] }

; 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
define dso_local i32 @qPID_Reset(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = icmp ne ptr null, %4
  br i1 %5, label %6, label %27

6:                                                ; preds = %1
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.qPID_controller_t, ptr %7, i32 0, i32 28
  %9 = load i8, ptr %8, align 4, !tbaa !11
  %10 = zext i8 %9 to i32
  %11 = icmp ne i32 0, %10
  br i1 %11, label %12, label %27

12:                                               ; preds = %6
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.qPID_controller_t, ptr %13, i32 0, i32 20
  call void @qNumA_StateInit(ptr noundef %14, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.qPID_controller_t, ptr %15, i32 0, i32 21
  call void @qNumA_StateInit(ptr noundef %16, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.qPID_controller_t, ptr %17, i32 0, i32 22
  call void @qNumA_StateInit(ptr noundef %18, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.qPID_controller_t, ptr %19, i32 0, i32 11
  store float 0.000000e+00, ptr %20, align 4, !tbaa !15
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.qPID_controller_t, ptr %21, i32 0, i32 12
  store float 0.000000e+00, ptr %22, align 8, !tbaa !16
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.qPID_controller_t, ptr %23, i32 0, i32 15
  store float 0.000000e+00, ptr %24, align 4, !tbaa !17
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.qPID_controller_t, ptr %25, i32 0, i32 14
  store float 0.000000e+00, ptr %26, align 8, !tbaa !18
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %12, %6, %1
  %28 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret i32 %28
}

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

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, !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, !13, i64 44}
!16 = !{!12, !13, i64 48}
!17 = !{!12, !13, i64 60}
!18 = !{!12, !13, i64 56}


; 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_Reset(ptr noundef %0) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %11, label %2

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

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 88
  tail call void @qNumA_StateInit(ptr noundef nonnull %6, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00) #2
  %7 = getelementptr inbounds i8, ptr %0, i64 100
  tail call void @qNumA_StateInit(ptr noundef nonnull %7, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00) #2
  %8 = getelementptr inbounds i8, ptr %0, i64 112
  tail call void @qNumA_StateInit(ptr noundef nonnull %8, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00) #2
  %9 = getelementptr inbounds i8, ptr %0, i64 44
  store <2 x float> zeroinitializer, ptr %9, align 4, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  store <2 x float> zeroinitializer, ptr %10, align 8, !tbaa !13
  br label %11

11:                                               ; preds = %5, %2, %1
  %.0 = phi i32 [ 1, %5 ], [ 0, %2 ], [ 0, %1 ]
  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, !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 = !{!7, !7, i64 0}


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