; LLVM IR from ctlst-tech/catpilot :: bsp/mcu/periph/usb/stm32/USB_DEVICE/Target (usbd_conf)

; 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.PCD_HandleTypeDef = type { ptr, %struct.USB_OTG_CfgTypeDef, i8, [16 x %struct.USB_OTG_EPTypeDef], [16 x %struct.USB_OTG_EPTypeDef], i32, i32, i32, [12 x i32], i32, i32, i32, i32, ptr }
%struct.USB_OTG_CfgTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.USB_OTG_EPTypeDef = type { i8, i8, i8, i8, i8, i8, i16, i32, ptr, i32, i32, i32 }
%struct._USBD_HandleTypeDef = type { i8, i32, i32, i32, i32, [16 x %struct.USBD_EndpointTypeDef], [16 x %struct.USBD_EndpointTypeDef], i32, i32, i8, i8, i8, i8, i8, i32, i8, %struct.usb_setup_req, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.USBD_EndpointTypeDef = type { i32, i32, i32, i32, i16, i16 }
%struct.usb_setup_req = type { i8, i8, i16, i16, i16 }

@hpcd_USB_OTG_FS = external dso_local global %struct.PCD_HandleTypeDef, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @Error_Handler() #0

; Function Attrs: nounwind uwtable
define dso_local i32 @USBD_LL_Init(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %3, i32 0, i32 0
  %5 = load i8, ptr %4, align 8, !tbaa !9
  %6 = zext i8 %5 to i32
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %19

8:                                                ; preds = %1
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %9, ptr getelementptr inbounds (%struct.PCD_HandleTypeDef, ptr @hpcd_USB_OTG_FS, i32 0, i32 13), align 8, !tbaa !14
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %10, i32 0, i32 21
  store ptr @hpcd_USB_OTG_FS, ptr %11, align 8, !tbaa !17
  store ptr inttoptr (i64 1074266112 to ptr), ptr @hpcd_USB_OTG_FS, align 8, !tbaa !18
  store i32 9, ptr getelementptr inbounds (%struct.PCD_HandleTypeDef, ptr @hpcd_USB_OTG_FS, i32 0, i32 1), align 8, !tbaa !19
  store i32 2, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.PCD_HandleTypeDef, ptr @hpcd_USB_OTG_FS, i32 0, i32 1), i32 0, i32 2), align 8, !tbaa !20
  store i32 1, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.PCD_HandleTypeDef, ptr @hpcd_USB_OTG_FS, i32 0, i32 1), i32 0, i32 3), align 4, !tbaa !21
  store i32 2, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.PCD_HandleTypeDef, ptr @hpcd_USB_OTG_FS, i32 0, i32 1), i32 0, i32 5), align 4, !tbaa !22
  store i32 1, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.PCD_HandleTypeDef, ptr @hpcd_USB_OTG_FS, i32 0, i32 1), i32 0, i32 6), align 8, !tbaa !23
  store i32 0, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.PCD_HandleTypeDef, ptr @hpcd_USB_OTG_FS, i32 0, i32 1), i32 0, i32 7), align 4, !tbaa !24
  store i32 0, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.PCD_HandleTypeDef, ptr @hpcd_USB_OTG_FS, i32 0, i32 1), i32 0, i32 8), align 8, !tbaa !25
  store i32 1, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.PCD_HandleTypeDef, ptr @hpcd_USB_OTG_FS, i32 0, i32 1), i32 0, i32 9), align 4, !tbaa !26
  store i32 1, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.PCD_HandleTypeDef, ptr @hpcd_USB_OTG_FS, i32 0, i32 1), i32 0, i32 10), align 8, !tbaa !27
  store i32 0, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.PCD_HandleTypeDef, ptr @hpcd_USB_OTG_FS, i32 0, i32 1), i32 0, i32 11), align 4, !tbaa !28
  %12 = call i32 @HAL_PCD_Init(ptr noundef @hpcd_USB_OTG_FS)
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %8
  call void @Error_Handler()
  br label %15

15:                                               ; preds = %14, %8
  %16 = call i32 @HAL_PCDEx_SetRxFiFo(ptr noundef @hpcd_USB_OTG_FS, i16 noundef zeroext 128)
  %17 = call i32 @HAL_PCDEx_SetTxFiFo(ptr noundef @hpcd_USB_OTG_FS, i8 noundef zeroext 0, i16 noundef zeroext 64)
  %18 = call i32 @HAL_PCDEx_SetTxFiFo(ptr noundef @hpcd_USB_OTG_FS, i8 noundef zeroext 1, i16 noundef zeroext 128)
  br label %19

19:                                               ; preds = %15, %1
  ret i32 0
}

declare i32 @HAL_PCD_Init(ptr noundef) #1

declare i32 @HAL_PCDEx_SetRxFiFo(ptr noundef, i16 noundef zeroext) #1

declare i32 @HAL_PCDEx_SetTxFiFo(ptr noundef, i8 noundef zeroext, i16 noundef zeroext) #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" }

!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, !7, i64 0}
!10 = !{!"_USBD_HandleTypeDef", !7, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !7, i64 20, !7, i64 340, !11, i64 660, !11, i64 664, !7, i64 668, !7, i64 669, !7, i64 670, !7, i64 671, !7, i64 672, !11, i64 676, !7, i64 680, !12, i64 682, !6, i64 696, !6, i64 704, !6, i64 712, !6, i64 720, !6, i64 728, !6, i64 736, !6, i64 744}
!11 = !{!"int", !7, i64 0}
!12 = !{!"usb_setup_req", !7, i64 0, !7, i64 1, !13, i64 2, !13, i64 4, !13, i64 6}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !6, i64 1424}
!15 = !{!"", !6, i64 0, !16, i64 8, !7, i64 60, !7, i64 64, !7, i64 704, !11, i64 1344, !11, i64 1348, !11, i64 1352, !7, i64 1356, !11, i64 1404, !11, i64 1408, !11, i64 1412, !11, i64 1416, !6, i64 1424}
!16 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48}
!17 = !{!10, !6, i64 728}
!18 = !{!15, !6, i64 0}
!19 = !{!15, !11, i64 8}
!20 = !{!15, !11, i64 16}
!21 = !{!15, !11, i64 20}
!22 = !{!15, !11, i64 28}
!23 = !{!15, !11, i64 32}
!24 = !{!15, !11, i64 36}
!25 = !{!15, !11, i64 40}
!26 = !{!15, !11, i64 44}
!27 = !{!15, !11, i64 48}
!28 = !{!15, !11, 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"

%struct.PCD_HandleTypeDef = type { ptr, %struct.USB_OTG_CfgTypeDef, i8, [16 x %struct.USB_OTG_EPTypeDef], [16 x %struct.USB_OTG_EPTypeDef], i32, i32, i32, [12 x i32], i32, i32, i32, i32, ptr }
%struct.USB_OTG_CfgTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.USB_OTG_EPTypeDef = type { i8, i8, i8, i8, i8, i8, i16, i32, ptr, i32, i32, i32 }

@hpcd_USB_OTG_FS = external dso_local global %struct.PCD_HandleTypeDef, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @Error_Handler() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @USBD_LL_Init(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load i8, ptr %0, align 8, !tbaa !5
  %3 = icmp eq i8 %2, 0
  br i1 %3, label %4, label %12

4:                                                ; preds = %1
  store ptr %0, ptr getelementptr inbounds (i8, ptr @hpcd_USB_OTG_FS, i64 1424), align 8, !tbaa !13
  %5 = getelementptr inbounds i8, ptr %0, i64 728
  store ptr @hpcd_USB_OTG_FS, ptr %5, align 8, !tbaa !16
  store ptr inttoptr (i64 1074266112 to ptr), ptr @hpcd_USB_OTG_FS, align 8, !tbaa !17
  store i32 9, ptr getelementptr inbounds (i8, ptr @hpcd_USB_OTG_FS, i64 8), align 8, !tbaa !18
  store i32 2, ptr getelementptr inbounds (i8, ptr @hpcd_USB_OTG_FS, i64 16), align 8, !tbaa !19
  store i32 1, ptr getelementptr inbounds (i8, ptr @hpcd_USB_OTG_FS, i64 20), align 4, !tbaa !20
  store <4 x i32> <i32 2, i32 1, i32 0, i32 0>, ptr getelementptr inbounds (i8, ptr @hpcd_USB_OTG_FS, i64 28), align 4, !tbaa !21
  store i32 1, ptr getelementptr inbounds (i8, ptr @hpcd_USB_OTG_FS, i64 44), align 4, !tbaa !22
  store i32 1, ptr getelementptr inbounds (i8, ptr @hpcd_USB_OTG_FS, i64 48), align 8, !tbaa !23
  store i32 0, ptr getelementptr inbounds (i8, ptr @hpcd_USB_OTG_FS, i64 52), align 4, !tbaa !24
  %6 = tail call i32 @HAL_PCD_Init(ptr noundef nonnull @hpcd_USB_OTG_FS) #2
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %8, label %7

7:                                                ; preds = %4
  tail call void @Error_Handler()
  br label %8

8:                                                ; preds = %7, %4
  %9 = tail call i32 @HAL_PCDEx_SetRxFiFo(ptr noundef nonnull @hpcd_USB_OTG_FS, i16 noundef zeroext 128) #2
  %10 = tail call i32 @HAL_PCDEx_SetTxFiFo(ptr noundef nonnull @hpcd_USB_OTG_FS, i8 noundef zeroext 0, i16 noundef zeroext 64) #2
  %11 = tail call i32 @HAL_PCDEx_SetTxFiFo(ptr noundef nonnull @hpcd_USB_OTG_FS, i8 noundef zeroext 1, i16 noundef zeroext 128) #2
  br label %12

12:                                               ; preds = %8, %1
  ret i32 0
}

declare i32 @HAL_PCD_Init(ptr noundef) local_unnamed_addr #1

declare i32 @HAL_PCDEx_SetRxFiFo(ptr noundef, i16 noundef zeroext) local_unnamed_addr #1

declare i32 @HAL_PCDEx_SetTxFiFo(ptr noundef, i8 noundef zeroext, i16 noundef zeroext) 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, !7, i64 0}
!6 = !{!"_USBD_HandleTypeDef", !7, i64 0, !9, i64 4, !9, i64 8, !9, i64 12, !9, i64 16, !7, i64 20, !7, i64 340, !9, i64 660, !9, i64 664, !7, i64 668, !7, i64 669, !7, i64 670, !7, i64 671, !7, i64 672, !9, i64 676, !7, i64 680, !10, i64 682, !12, i64 696, !12, i64 704, !12, i64 712, !12, i64 720, !12, i64 728, !12, i64 736, !12, i64 744}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"usb_setup_req", !7, i64 0, !7, i64 1, !11, i64 2, !11, i64 4, !11, i64 6}
!11 = !{!"short", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !12, i64 1424}
!14 = !{!"", !12, i64 0, !15, i64 8, !7, i64 60, !7, i64 64, !7, i64 704, !9, i64 1344, !9, i64 1348, !9, i64 1352, !7, i64 1356, !9, i64 1404, !9, i64 1408, !9, i64 1412, !9, i64 1416, !12, i64 1424}
!15 = !{!"", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12, !9, i64 16, !9, i64 20, !9, i64 24, !9, i64 28, !9, i64 32, !9, i64 36, !9, i64 40, !9, i64 44, !9, i64 48}
!16 = !{!6, !12, i64 728}
!17 = !{!14, !12, i64 0}
!18 = !{!14, !9, i64 8}
!19 = !{!14, !9, i64 16}
!20 = !{!14, !9, i64 20}
!21 = !{!9, !9, i64 0}
!22 = !{!14, !9, i64 44}
!23 = !{!14, !9, i64 48}
!24 = !{!14, !9, i64 52}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass